from sklearn.cross_validation import train_test_split

from sklearn.ensemble import RandomForestClassifier,GradientBoostingClassifier

df = df[df['posteam'] == 'CHI']
df = df[df['DefensiveTeam'] == 'GB']
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', 'ydstogo', 'TimeSecs', 'is_pass']]
(X, test) = train_test_split(df, test_size=0.2)
y = X.pop('is_pass')

rf = RandomForestClassifier(n_estimators=1000)
rf.fit(X, y)