I've this code (part of predictive model):

training_features, test_features, training_target, test_target, = train_test_split(df.drop(['target'], axis=1),
                                              test_size = .3,
    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)

How can I export my dataset with the predictive value in order to create a confusion matrix to determine the False Positive value?



1 Answer 1


If you are just looking for generating Confusion Matrix, then you can try using this command:

#for generating confusion matrix    
sklearn.metrics.confusion_matrix(y_true, y_pred, labels=None, sample_weight=None)

If you are just looking for binding predicted and actual values, you can use this command

#For Arrays you can use this

#for dataframe you can use this
DataFrame.append(other, ignore_index=False, verify_integrity=False)[source]

for better understaning you can go through this Link-1,Link-2,Link-3


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.