# what features can I get from the sample?

I have dataset of 100 000 words labeled by surname(is last name / not last name) Example:

kitchen | 0

kennedy | 1

etc.

I tried extract lenth of word, count of each letter and such simple features to build random forest classifier, but it didn't work. How to solve this task?

• Please specify what you are trying to classify (what does 0 and 1 denotes?). Feature engineering is a task that requires domain expertise. – Yohanes Alfredo Nov 18 at 8:36
• 1 denote that the word is last name (Smith, Johnson, Williams, Jones, Brown etc.) 0 denote that the word is not last name (card, phone, computer, airplane etc.) – mender1 Nov 18 at 8:47
• Do you really need to use randomforest? for this case you will lose the sense (tech and chet is essentially similar using feature generated like that) of each of your sample and hence poor performance. – Yohanes Alfredo Nov 18 at 9:07
• I have no idea how to generate feature another way, becouse I have no context for the words. But I need to solve this using ML – mender1 Nov 18 at 9:14
• You can use RNN, if that is the case. Simply use RNN and use letters as your input. That is the simplest working approach I can think of. – Yohanes Alfredo Nov 18 at 9:16

from keras.preprocessing.text import Tokenizer
from keras.models import Sequential
from keras.layers import LSTM, Embedding, GlobalAveragePooling1D, Dense
from keras import backend as K
import numpy as np

words = ['kennedy','smith','kitchen','caterpillar']
label = [1,1,0,0]

tokens = Tokenizer(30, char_level=True)
tokens.fit_on_texts(words)

X = tokens.texts_to_sequences(words)