I have a system where i get as input array of feature strings:
["kol","bol","sol","nol"]
The length of this array is dynamic, i can get 2, 4 or 6 etc, total features <20
I need to make a decision according to this array, the decision is another string:
x = ["feature1","feature5","feature3","feature8"] #in
y = "john" #decide
What I end up doing is creating a table, 1 if exist, 0 otherwise, for each training set (dataframe pandas
):
feature1 feature2 feature3 feature4 feature5... decision
1 0 1 0 1 1 (john mapped to 1, Ly to 2, etc)
I feed this into a Decision Tree Classifier using sklearn
. (DecisionTreeClassifier
)
I train it with 100+ input feature arrays and desired outcomes.
It works, but i do have a feeling that it won't really provide value if the input will be different than trained data, because there is no real meaning/weight to these binary values.
These features strings comes from a Bag of Words in which if appear on a text, i extract it, to create a well defined set of features to train/predict.
- can I, or should I change the values from 1/0 to a more weighted ones? how do i get them?
- Is this a right approach assuming i have a bag of words in which i look for in a text and produce features that both in the text and the bag.