I have made a classification engine with only one independent field (Comments) and classified them in multiple dependent variables. Now I want to have multiple independent variables in training data (comments,state,age,gender etc).
Currently i am using python 3.6.
Example of what I have done:
Comments Classified
(The car wash service is good) Positive
Example of what I want to do:
Comments Gender City Age Classified
(The car wash service is good) Male LA 40 Positive
As you can see in the second example we have 4 independent variables affecting the outcome(Classified sentiment). I want to implement a classification engine based on this use case. Please suggest how should i move ahead...???
Edit:- I have used SGDClassifier from sklearn.linear_model.
I have first passed list of comments as vectors which i have vectorized using TfidfVectorizer. Below is the code of vectorization:-
from sklearn.feature_extraction.text import TfidfVectorizer
vectorizer = TfidfVectorizer(min_df=5,
max_df = 0.8,
sublinear_tf=True,
use_idf=True)
train_vectors = vectorizer.transform(Train_data_Comments_list)
then I pass these vectors to train along with their classified labels. Below is the code(I have used partial_fit as i want to train again and again):-
classifier = SGDClassifier.partial_fit(train_vectors, Train_Labels)
Then I use the the classifier to classify rest of the vectors.
test_vectors = vectorizer.transform(Test_data_comments_list)
prediction_liblinear = classifier.predict(test_vectors)
If I combine all the fields value in my second Example and then form a single vector from that and then pass those vectors for classification, would that be the ideal way of doing it?
TfidfVectorizer
creates a slightly more sophisticated version of "bag of words" where the words are scored according to frequency. $\endgroup$