from sklearn.metrics import accuracy_score

y_pred = dfvaltest['prediction']
y_true = dfvaltest['status_group']

accuracy_score(y_true,y_pred)

"""
Explanation: <h3>#lets check the accuracy score....</h3>
End of explanation
"""


dftest = pd.read_csv('testsetfix.csv',delimiter=',')

dftest.head()

feat2pred = list(dftest.columns)
selfeat_p = [feat2pred[5],feat2pred[6],feat2pred[9],feat2pred[12],feat2pred[13],feat2pred[14]]
predfeats = dftest[selfeat_p] 

dftest['status_group'] = clf2.predict(predfeats)

dftest.head()

dftest.loc[dftest['status_group']==3]

submission = dftest[['id','status_group']].copy()

submission['status_group'].replace(1,'functional',inplace=True)
submission['status_group'].replace(2,'non functional',inplace=True)
submission['status_group'].replace(3,'functional needs repair',inplace=True)

submission.to_csv('submission6baggedDT_77.csv',sep=',',header=True,index=False)

print "done!"

from sklearn.ensemble import BaggingClassifier

clf3 = BaggingClassifier(n_estimators=50)
clf3 = clf3.fit(X_new,labels)

dftest['status_group'] = clf3.predict(predfeats)

dfvaltest['prediction'] = clf3.predict(valfeats)

accuracy_score(y_true,y_pred)

"""
Explanation: <h3>#open test dataframe</h3>
End of explanation
"""


