text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.metrics import confusion_matrix

from sklearn.linear_model import LogisticRegression
model = LogisticRegression()
model.fit(X_train, y_train.ravel())
y_pred = model.predict(X_test)

from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)

def precision_recall(y_test, y_pred):
    cm = confusion_matrix(y_test, y_pred)
    tp = cm[0, 0]
    fp = cm[0, 1]
    fn = cm[1, 0]
    prec = tp / (tp + fp)
    rec = tp / (tp + fn)
    return (prec, rec)
precision, recall = precision_recall(y_test, y_pred)
print('Precision: %f Recall %f' % (precision, recall))