<jupyter_start><jupyter_text>Due to the sheer amount of columns to be treated as variables in the x field, I believe that the logistic regression model will be better for this dataset once it has been scaled. The enormous variety in the different types of information contained in the loan information does not look like it would be reliable without first being scaled.<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)
cl = classifier.fit(X_train, y_train)
# Printing Training score and Testing score for Logistic Regression
print(f'Training Score: {classifier.score(X_train, y_train)}')
print(f'Testing Score: {classifier.score(X_test, y_test)}')<jupyter_output>Training Score: 0.6511494252873563
Testing Score: 0.5163760102084219<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=500).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)}')<jupyter_output>Training Score: 1.0
Testing Score: 0.6433432581880051<jupyter_text>Contrary to my prediction, the Random Forest Classifier model had a more accurate testing score than the Logistic Regression model.<jupyter_code># Scale the data
scaler = StandardScaler().fit(X_train)
X_train_scaled = scaler.transform(X_train)
X_test_scaled = scaler.transform(X_test)
# 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)}')
# Train a Random Forest Classifier model on the scaled data and print the model score
clf = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train_scaled, y_train)
print(f'Training Score: {clf.score(X_train_scaled, y_train)}')
print(f'Testing Score: {clf.score(X_test_scaled, y_test)}')<jupyter_output>Training Score: 1.0
Testing Score: 0.6420672054444917
{'fraction_non_alphanumeric': 0.07917019475021168, 'fraction_numerical': 0.03386960203217612, 'mean_word_length': 7.817164179104478, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '38892', 'license': 'ADSL', 'n_tokens_mistral': 800, 'n_tokens_neox': 734, 'n_words': 230, 'path': 'Credit Risk Evaluator.ipynb', 'repo_name': 'conwaykylej/Supervised-Machine-Learning-Predicting-Credit-Risk', 'size': '2362'}