Created
April 24, 2019 20:12
-
-
Save alinazhanguwo/1004885f9cd06a43854e378291c487c0 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
def train_classifier(X_train, y_train): | |
""" | |
X_train, y_train — training text and sentiment | |
return: trained classifier | |
""" | |
# Create and fit LogisticRegression wraped into OneVsRestClassifier. | |
model = OneVsRestClassifier(LogisticRegression(penalty='l2', C=1.0)) | |
model.fit(X_train, y_train) | |
return model | |
classifier_tfidf = train_classifier(X_train_tfidf, y_train) | |
y_val_predicted_labels_tfidf = classifier_tfidf.predict(X_val_tfidf) | |
y_val_predicted_scores_tfidf = classifier_tfidf.decision_function(X_val_tfidf) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment