Created
May 23, 2018 02:18
-
-
Save ken333135/b7bf31da0027e427382dac8ea0fca7ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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