July 2017
Intermediate to advanced
254 pages
6h 29m
English
Recall that accuracy measures the fraction of the classifier's predictions that are correct. LogisticRegression.score predicts and scores labels for a test set using accuracy. Let's evaluate our classifier's accuracy:
# In[1]:import numpy as npimport pandas as pdfrom sklearn.feature_extraction.text import TfidfVectorizerfrom sklearn.linear_model.logistic import LogisticRegressionfrom sklearn.model_selection import train_test_split, cross_val_scorefrom sklearn.metrics import roc_curve, aucimport matplotlib.pyplot as pltdf = pd.read_csv('./sms.csv')X_train_raw, X_test_raw, y_train, y_test = train_test_split(df['message'], df['label'], random_state=11)vectorizer = TfidfVectorizer()X_train = vectorizer.fit_transform(X_train_raw)X_test ...
Read now
Unlock full access