<jupyter_start><jupyter_text>Prediction before scaling the dataset- I think that the Random Forest Classifier will perform better prior to scaling the data due to the fact that it is a tree-based model.- Also the Logistic Regression Model could be affected by possible outliers.- Logistic regression performs better when the number of noise variables is less than or equal to the number of explanatory 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(random_state=0)
classifier.fit(X_train, Y_train)
print(f"Training Data Score: {classifier.score(X_train, Y_train).round(5)}")
classifier.fit(X_test, Y_test)
print(f"Testing Data Score: {classifier.score(X_test, Y_test).round(5)}")


# Train a Random Forest Classifier model and print the model score
from sklearn.ensemble import RandomForestClassifier
RFCr = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train, Y_train)
print(f"Training Score: {RFCr.score(X_train, Y_train)}")
print(f"Testing Score: {RFCr.score(X_test, Y_test).round(5)}")<jupyter_output>Training Score: 1.0
Testing Score: 0.56827<jupyter_text>Prediction vs Model Results- Based on the model score results the Logistic Regression Model outperform the Random Forest Classifier.  My prediction was incorrect probably due to the fact that    the data did not have significant outliers that could be stretching the model.- I also learned that the Random Forest model does not perform as well as the Logistic Regression model when the number    of numeric veriables is greater than the the number of categorical verialbles, which is the case with our dataset. Model scores prior to scaling\;  - **Logistic Regression\:**    > Training Data Score\: 0.65074      > Testing Data Score\: 0.82433  - **Random Forest Clasiffier\:**    > Training Score: 1.0      > Testing Score: 0.56827<jupyter_code># Scale the data
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler().fit(X_train)
X_train_scaled = scaler.transform(X_train)
scalert = StandardScaler().fit(X_train)
X_test_scaled = scalert.transform(X_test)
X_train_scaled
X_test_scaled<jupyter_output><empty_output><jupyter_text>Prediction after scaling the data  - I think that the model score will improve for the Logistic Regression model since we are dealing with a Gradient Descent Based      algorithm and these are very sensitive to the range of the data points.  - On the other hand Random Forests Classifier should not see any changes since it is based on tree partitioning algorithms.      Basically a decision given a threshold, and this shouldn't change with scaling.<jupyter_code># Train the Logistic Regression model on the scaled data and print the model score
classifier.fit(X_train_scaled, Y_train)
print(f"Training Scaled Data Score: {classifier.score(X_train_scaled, Y_train).round(5)}")
classifier.fit(X_test_scaled, Y_test)
print(f"Testing Scaled Data Score: {classifier.score(X_test_scaled, Y_test).round(5)}")
# Train a Random Forest Classifier model on the scaled data and print the model score
clff = RandomForestClassifier(random_state=1, n_estimators=500).fit(X_train_scaled, Y_train)
print(f'Training Score: {clff.score(X_train_scaled, Y_train)}')
print(f'Testing Score: {clff.score(X_test_scaled, Y_test).round(5)}')<jupyter_output>Training Score: 1.0
Testing Score: 0.56912
{'fraction_non_alphanumeric': 0.0737300435413643, 'fraction_numerical': 0.014804063860667634, 'mean_word_length': 5.919678714859438, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '176407', 'license': 'MIT', 'n_tokens_mistral': 1056, 'n_tokens_neox': 1005, 'n_words': 383, 'path': 'Credit Risk Evaluator.ipynb', 'repo_name': 'Jorgehdzdata/Supervised-Machine-Learning-Homework-', 'size': '3445'}