<jupyter_start><jupyter_text>while the accuracy was great, the algorithm misclassified more than 4 in 10 fraudulent transactions.So, since accuracy is not the reliable measure of our model’s effectiveness. Instead, we look at other measures like the Cohen Kappa, Recall, and F1 score and we should achieve a score as close to 1 as we can.<jupyter_code># Let's try another model. In this case; RandomForest classifier.
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(n_estimators = 100, n_jobs =4)
cmat, pred = RunModel(rf, X_train, y_train, X_test, y_test)
ShowStats(cmat, y_test, pred)<jupyter_output>[[85296    12]
 [   30   105]]
Accuracy: 99.95%
Cohen Kappa: 0.833
Sensitivity/Recall for Model : 0.78
F1 Score for Model : 0.83
{'fraction_non_alphanumeric': 0.07480314960629922, 'fraction_numerical': 0.047244094488188976, 'mean_word_length': 5.203252032520325, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '449800', 'license': 'MIT', 'n_tokens_mistral': 275, 'n_tokens_neox': 240, 'n_words': 98, 'path': 'Fraud-detection.ipynb', 'repo_name': 'bokal2/Fraud-Detection', 'size': '762'}