#!/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", "r") )

### add more features to features_list!
features_list = ["poi", "salary"]

data = featureFormat(data_dict, features_list)
labels, features = targetFeatureSplit(data)



### your code goes here 

from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
from sklearn.model_selection import train_test_split

features_train, features_test, labels_train, labels_test = train_test_split(features, labels, test_size=0.3, random_state=42)
clf = DecisionTreeClassifier()
clf = clf.fit(features_train, labels_train)
pred = clf.predict(features_test)
accuracy = accuracy_score(labels_test, pred)
print('Accuracy: ' + str(accuracy))

print('Number of POIs in the test data: ' + str(labels_test.count(1)))
print('Total number of people in the test data: ' + str(len(labels_test)))
print('Number of true positives: ' + str(sum([True if predicted == 1 and actual == 1 else False for (predicted, actual) in zip(pred, labels_test)])))

print('Precision Score: ' + str(precision_score(pred, labels_test)))
print('Recall Score: ' + str(recall_score(pred, labels_test)))
print('F1 Score: ' + str(f1_score(pred, labels_test)))
