Created
February 11, 2019 09:55
-
-
Save nithyadurai87/f09984303f976ca6eb8a64a4b7f0e391 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import numpy as np | |
import pandas as pd | |
from sklearn.feature_extraction.text import TfidfVectorizer | |
from sklearn.linear_model.logistic import LogisticRegression | |
from sklearn.model_selection import train_test_split, cross_val_score | |
df = pd.read_csv('./spam.csv', delimiter=',',header=None) | |
X_train_raw, X_test_raw, y_train, y_test = train_test_split(df[1],df[0]) | |
vectorizer = TfidfVectorizer() | |
X_train = vectorizer.fit_transform(X_train_raw) | |
X_test = vectorizer.transform(X_test_raw) | |
classifier = LogisticRegression() | |
classifier.fit(X_train, y_train) | |
predictions = classifier.predict(X_test) | |
print(predictions) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment