In [1]:
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
from sklearn import metrics
%matplotlib inline
In [2]:
url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/bikeshare.csv'
bikes = pd.read_csv(url)
bikes.head()
Out[2]:
In [4]:
average_bike_rental = bikes['count'].mean()
print(average_bike_rental)
In [5]:
bikes['above_average'] = bikes['count'] >= average_bike_rental
bikes['above_average'].value_counts(normalize=True)
Out[5]:
In [7]:
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
features_cols = ['temp']
x = bikes[features_cols]
y = bikes['above_average']
x_train, x_test, y_train, y_test = train_test_split(x, y)
logreg = LogisticRegression()
logreg.fit(x_train, y_train)
logreg.score(x_test, y_test)
Out[7]:
In [8]:
bikes.head()
Out[8]:
In [ ]: