-
-
Save amankharwal/f95412e46a0d1fbe87ba132225d24bb8 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
X_train, X_test, y_train, y_test = train_test_split(X_all, y_all, test_size = 0.2, random_state = 123) | |
def train_test(clf, X_train, X_test, y_train, y_test): | |
clf.fit(X_train, y_train) | |
train_acc = accuracy_score(y_train, clf.predict(X_train)) | |
test_acc = accuracy_score(y_test, clf.predict(X_test)) | |
return train_acc, test_acc | |
from sklearn.feature_extraction import DictVectorizer | |
vectorizer = DictVectorizer(sparse = True) | |
X_train = vectorizer.fit_transform(X_train) | |
X_test = vectorizer.transform(X_test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment