text_plain_output_1.png
from sklearn.linear_model import LogisticRegression

from sklearn.metrics import precision_score, recall_score, precision_recall_curve

import matplotlib.pyplot as plt

import pandas as pd

import numpy as np
import pandas as pd
df = pd.read_csv('../input/seattleWeather_1948-2017.csv')

df = df.dropna()
X = df.loc[:, ['PRCP', 'TMAX', 'TMIN']].shift(-1).iloc[:-1].values
y = df.iloc[:-1, -1:].values.astype('int')
from sklearn.linear_model import LogisticRegression
clf = LogisticRegression()
clf.fit(X, y)
y_hat = clf.predict(X)

import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
precision, recall, _ = precision_recall_curve(y, y_hat)
fig, ax = plt.subplots(1, figsize=(12, 6))
ax.step(recall, precision, color='steelblue', where='post')
ax.fill_between(recall, precision, step='post', color='lightgray')
plt.suptitle('Precision-Recall Tradeoff for Seattle Rain Prediction')
plt.xlabel('Recall')
plt.ylabel('Precision')