<jupyter_start><jupyter_text>My prediction is that the RandomForest model will perform better as it is more focused on accuracy and does well with categorical datasets. RandomForest is also less prone to overfitting. Logistic Regression Model<jupyter_code># Train the Logistic Regression model on the unscaled data and print the model score
from sklearn.linear_model import LogisticRegression
classifier = LogisticRegression()
classifier
classifier.fit(X_train,y_train)
log_unscaled=classifier.fit(X_train, y_train)
#print model scores
print(f'Training Score: {classifier.score(X_train, y_train)}')
print(f'Testing Score: {classifier.score(X_test, y_test)}')
#report
from sklearn.metrics import classification_report
y_true = y_test
y_pred = classifier.predict(X_test)
print(classification_report(y_true, y_pred))<jupyter_output>precision    recall  f1-score   support

   high_risk       0.53      0.30      0.39      2351
    low_risk       0.51      0.73      0.60      2351

    accuracy                           0.52      4702
   macro avg       0.52      0.52      0.49      4702
weighted avg       0.52      0.52      0.49      4702<jupyter_text>Random Forest Classifier<jupyter_code># Train a Random Forest Classifier model and print the model score
from sklearn.ensemble import RandomForestClassifier
from sklearn.preprocessing import StandardScaler
classifier = RandomForestClassifier(random_state=1,n_estimators=400).fit(X_train, y_train)
print(f'Training Score: {classifier.score(X_train, y_train)}')
print(f'Testing Score: {classifier.score(X_test, y_test)}')
# classification Report
from sklearn.metrics import classification_report
y_true = y_test
y_pred = classifier.predict(X_test)
print(classification_report(y_true, y_pred))<jupyter_output>precision    recall  f1-score   support

   high_risk       0.61      0.81      0.70      2351
    low_risk       0.72      0.48      0.57      2351

    accuracy                           0.64      4702
   macro avg       0.66      0.64      0.63      4702
weighted avg       0.66      0.64      0.63      4702<jupyter_text>Between the LogisticRegression and the the RandomForest Classifier models, the RandomForest had a better training and testing score than the LogisticRegression. Also when looking at their classification reports, RandomForest's f1-score was higher or more close to 1.<jupyter_code>#scaled data
scaler = StandardScaler().fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)

X_test_scaled<jupyter_output><empty_output><jupyter_text>Normalizing the data is to help with optimization. It does not really affect RandomForest models. However, with LogisticRegression, normalized data makes it easier to interpret expected values. My prediction will be again that LogisticRegression model will perform better than RandomForest.<jupyter_code># Scale the data
# Train the Logistic Regression model on the scaled data and print the model score
classifier=LogisticRegression().fit(X_train_scaled, y_train)
print(f'Training Score: {classifier.score(X_train_scaled, y_train)}')
print(f'Testing Score: {classifier.score(X_test_scaled, y_test)}')
#LogisticRegression Scaled Classification Report
from sklearn.metrics import classification_report
y_true = y_test
y_pred = classifier.predict(X_test)
print(classification_report(y_true, y_pred))
# Train a Random Forest Classifier model on the scaled data and print the model score
classifier = RandomForestClassifier(random_state=1, n_estimators=400).fit(X_train_scaled, y_train)
print(f'Training Score: {classifier.score(X_train_scaled, y_train)}')
print(f'Testing Score: {classifier.score(X_test_scaled, y_test)}')
#RandomForest Scaled Classification Report
from sklearn.metrics import classification_report
y_true = y_test
y_pred = classifier.predict(X_test)
print(classification_report(y_true, y_pred))<jupyter_output>precision    recall  f1-score   support

   high_risk       0.33      0.00      0.00      2351
    low_risk       0.50      1.00      0.67      2351

    accuracy                           0.50      4702
   macro avg       0.42      0.50      0.33      4702
weighted avg       0.42      0.50      0.33      4702
{'fraction_non_alphanumeric': 0.06746126340882003, 'fraction_numerical': 0.04529201430274136, 'mean_word_length': 3.7736063708759953, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '476342', 'license': 'ADSL', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1291, 'n_words': 372, 'path': 'Credit Risk Evaluator.ipynb', 'repo_name': 'ravjolt/Supervised-Machine-Learning', 'size': '4195'}