I've this code in Python in order to calculate the precision of my model and to print confusion matrix using Decision Trees Classifier:
coef_gini = DecisionTreeClassifier(criterion = "gini", random_state = 100, max_depth = 3, min_samples_leaf = 5) coef_gini.fit(training_features, training_target) y_pred = coef_gini.predict(test_features) y_pred for name, importance in zip(training_features.columns, coef_gini.feature_importances_): print(name, importance) print ( "Train Accuracy using Decision Trees Classifier is : ", accuracy_score(training_target, coef_gini.predict(training_features))) print ( "Test Accuracy using Decision Trees Classifier is : ", accuracy_score(test_target, y_pred)) print ( "Confusion matrix using Decision Trees Classifier is ", confusion_matrix(test_target, y_pred))
What is the cost matrix? Is this the money that company will lost for each wrong predictive target value? Anyone have an example?