Skip to content

Instantly share code, notes, and snippets.

@ken333135
Created May 23, 2018 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ken333135/b7bf31da0027e427382dac8ea0fca7ed to your computer and use it in GitHub Desktop.
Save ken333135/b7bf31da0027e427382dac8ea0fca7ed to your computer and use it in GitHub Desktop.
#Define a pipeline combining a text feature extractor with multi label classifer
NB_pipeline = Pipeline([
('tfidf',TfidfVectorizer()),
('clf', OneVsRestClassifier(MultinomialNB(fit_prior=True,class_prior=None))),
])
#Train the model and get the prediction
score = []
for code in label:
# train the model
NB_pipeline.fit(x_train,train[code])
#compute the testing accuracy
prediction = NB_pipeline.predict(x_test)
score.append(roc_auc_score(test[code],prediction))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment