In [1]:
from IPython.core.display import HTML
import os
def css_styling():
"""Load default custom.css file from ipython profile"""
base = os.getcwd()
styles = "<style>\n%s\n</style>" % (open(os.path.join(base,'files/custom.css'),'r').read())
return HTML(styles)
css_styling()
Out[1]:
In [4]:
import pandas as pd
import numpy as np
In [5]:
df = pd.read_csv('training.csv')
In [7]:
df.head(1)
Out[7]:
In [10]:
bueno=df['Label'].replace(to_replace=['s','b'],value=[1,0])
df['class_int']= bueno
In [13]:
df.drop('EventId',axis=1,inplace=True)
df.drop('Label',axis=1,inplace=True)
df.drop('class_int',axis=1,inplace=True)
In [29]:
X = df.values
Y = bueno
In [32]:
print(X.shape)
print(Y.shape)
In [33]:
In [34]:
print(X_train.shape)
print(Y_train.shape)
In [45]:
from sklearn.ensemble import RandomForestClassifier
clf = RandomForestClassifier(
max_features=3,
max_depth=10,
min_samples_leaf=50,
n_estimators=5
)
clf.fit(X_train,Y_train)
clf.score(X_test,Y_test)
Out[45]: