import matplotlib.pyplot as plt

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import sklearn.linear_model as sk

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import sklearn.linear_model as sk
from sklearn import preprocessing
full_data_set = pd.read_csv('../input/nflplaybyplay2015.csv', low_memory=False)

Pass_Plays = full_data_set.loc[full_data_set.PlayType == 'Pass']
Sack_Plays = full_data_set.loc[full_data_set.PlayType == 'Sack']
P_S_data = pd.concat([Pass_Plays, Sack_Plays])

good_columns = ['Drive', 'qtr', 'down', 'TimeUnder', 'TimeSecs', 'PlayTimeDiff', 'yrdline100', 'ydstogo']
good_columns += ['ScoreDiff', 'PosTeamScore', 'DefTeamScore']
good_columns += ['Sack']
uncleaned_data = P_S_data[good_columns]

uncleaned_data.qtr.unique()

def quarter_binary(df, name, number):
    df[name] = np.where(df['qtr'] == number, 1, 0)
    return df
for x in [['qt1', 1], ['qt2', 2], ['qt3', 3], ['qt4', 4], ['qt5', 5]]:
    uncleaned_data = quarter_binary(uncleaned_data, x[0], x[1])
del uncleaned_data['qtr']

logreg = sk.LogisticRegressionCV()
logreg.fit(X_all, y_all)
coef_array = np.abs(logreg.coef_)

x = np.arange(1, coef_array.shape[1] + 1, 1)

plt.scatter(x, coef_array, marker='x', color='r')
plt.axhline(0, color='b')