<jupyter_start><jupyter_text>Prediction:  I think the random forest model will perform more accurately based on the number of variables there are in the data set. Random forest models work better with higher number of variables.<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)
LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
                   intercept_scaling=1, l1_ratio=None, max_iter=100,
                   multi_class='auto', n_jobs=None, penalty='l2',
                   random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
                   warm_start=False)
print(f"Training Data Score: {classifier.score(X_train, y_train)}")
print(f"Testing Data Score: {classifier.score(X_test, y_test)}")
# Train a Random Forest Classifier model and print the model score
from sklearn.ensemble import RandomForestClassifier

clf = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train, y_train)
print(f'Training Score: {clf.score(X_train, y_train)}')
print(f'Testing Score: {clf.score(X_test, y_test)}')<jupyter_output><ipython-input-12-4ae1110f710d>:4: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples,), for example using ravel().
  clf = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train, y_train)<jupyter_text>Results:  The Random Forest Model performed better than the Logistic Regression, but only slightly and both models did not have a very high testing score for predicting loan risk. I would predict that scaling the data will help bring the results up.<jupyter_code># Scale the data
from sklearn.preprocessing import StandardScaler

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_2 = LogisticRegression()
classifier_2.fit(X_train_scaled, y_train)

LogisticRegression(C=1.0, class_weight=None, dual=False, fit_intercept=True,
                   intercept_scaling=1, l1_ratio=None, max_iter=100,
                   multi_class='auto', n_jobs=None, penalty='l2',
                   random_state=None, solver='lbfgs', tol=0.0001, verbose=0,
                   warm_start=False)

print(f"Training Data Score: {classifier.score(X_train_scaled, y_train)}")
print(f"Testing Data Score: {classifier.score(X_test_scaled, y_test)}")
# Train a Random Forest Classifier model on the scaled data and print the model score
clf_2 = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train_scaled, y_train)
print(f'Training Score: {clf_2.score(X_train_scaled, y_train)}')
print(f'Testing Score: {clf_2.score(X_test_scaled, y_test)}')<jupyter_output><ipython-input-16-32f04808c0d3>:2: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples,), for example using ravel().
  clf_2 = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train_scaled, y_train)
{'fraction_non_alphanumeric': 0.09189356435643564, 'fraction_numerical': 0.023205445544554455, 'mean_word_length': 5.427435387673956, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '162062', 'license': 'ADSL', 'n_tokens_mistral': 1088, 'n_tokens_neox': 1032, 'n_words': 288, 'path': 'Credit Risk Evaluator.ipynb', 'repo_name': 'JosiahR89/Credit_Risk_Evaluator', 'size': '3232'}