1

I am using linearsvc for prediction. I want to use two columns to predict the class of an item. I have written code by using only one column how to inlcude two columns for that.

labels_T = df_T['Asso_Sub']
text_T=df_T['Title']
count_vect = CountVectorizer()
model= LinearSVC()


#######Title#######
X_train_T, X_test_T, y_train_T, y_test_T = train_test_split(text_T, labels_T, random_state = 0, test_size =0.3)

X_train_counts_T = count_vect.fit_transform(X_train_T)
tf_transformer_T = TfidfTransformer().fit(X_train_counts_T)
X_train_tfidf_T = tf_transformer_T.transform(X_train_counts_T)

X_test_counts_T = count_vect.transform(X_test_T)
X_test_tfidf_T = tf_transformer_T.transform(X_test_counts_T)

y_test_counts_T = count_vect.transform(y_test_T)
y_test_tfidf_T = tf_transformer_T.transform(y_test_counts_T)

labels_T=LabelEncoder()
y_train_labels_fit_T=labels_T.fit(y_train_T)
y_train_labels_trf_T=labels_T.transform(y_train_T)


clf_T=model.fit(X_train_tfidf_T,y_train_labels_trf_T)
##################################################################################

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.