#!/usr/bin/python


"""
    Starter code for the evaluation mini-project.
    Start by copying your trained/tested POI identifier from
    that which you built in the validation mini-project.

    This is the second step toward building your POI identifier!

    Start by loading/formatting the data...
"""

import pickle
import sys
sys.path.append("../tools/")
from feature_format import featureFormat, targetFeatureSplit

data_dict = pickle.load(open("../final_project/final_project_dataset.pkl", "br") )

### add more features to features_list!
features_list = ["poi", "salary"]
data = featureFormat(data_dict, features_list)
labels, features = targetFeatureSplit(data)
sort_keys = '../tools/python2_lesson14_keys.pkl'


### your code goes here 
from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import accuracy_score
from sklearn import cross_validation
features_train,features_test,labels_train,labels_test = cross_validation.train_test_split(features,labels,test_size=0.3,random_state=100)

clf = RandomForestClassifier(max_features=379, n_jobs=10, random_state=100)
clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
print (pred)
acc = accuracy_score(labels_test, pred)
print (acc)
print (features_train.shape)

