from sklearn.cross_validation import train_test_split

from sklearn.ensemble import RandomForestClassifier

"""
Boiler-Plate/Feature-Engineering to get frame into a testable format
"""
used_downs = [1, 2, 3]
df = df[df['down'].isin(used_downs)]
valid_plays = ['Pass', 'Run', 'Sack']
df = df[df['PlayType'].isin(valid_plays)]
pass_plays = ['Pass', 'Sack']
df['is_pass'] = df['PlayType'].isin(pass_plays).astype('int')
df = df[['down', 'yrdline100', 'ScoreDiff', 'PosTeamScore', 'DefTeamScore', 'ydstogo', 'TimeSecs', 'ydsnet', 'is_pass', 'Drive']]
(X, test) = train_test_split(df, test_size=0.2)
y = X.pop('is_pass')
test_y = test.pop('is_pass')

parameters = {}
clf = RandomForestClassifier(n_jobs=-1, oob_score=True, n_estimators=100, min_samples_leaf=12, max_features=0.8)

clf.fit(X, y)

clf.score(test, test_y)