<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 GOAL IS TO SHOW IF THERE IS LINEAR RELATIONSHIP BETWEEN HEIGHT AND SHOE SIZE - USING YELLOWBRICK
Step1:  **DATASET WAS TAKEN FROM https
Step2:  Women is coded as 1 vs Man being 0 so that's why there is negative correlation between sex and shoe size
Step3:  SPECIFIC MODEL TUNING
Step4:  RANDOM FOREST REGRESSOR HYPERPARAMETER TUNING
Step5:  USE MODEL THAT HAS ALPHA AS PARAMETERS - RIDGE
<ASSISTANT_TASK:>
Python Code:
from sklearn.model_selection import train_test_split, KFold
from sklearn.linear_model import LinearRegression, Ridge, SGDRegressor, ElasticNet
from sklearn.kernel_ridge import KernelRidge
from sklearn.svm import SVR
from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor
from yellowbrick.features import Rank2D, JointPlotVisualizer
from yellowbrick.regressor import ResidualsPlot, PredictionError, ManualAlphaSelection, CooksDistance
from yellowbrick.model_selection import cv_scores, LearningCurve, FeatureImportances, ValidationCurve
import pandas as pd
import numpy as np
# GET THE CURRENT WORKING DIRECTORY SO YOU CAN LOAD THE PATH TO THE WO_MEN.XLSX FILE
import os
os.getcwd()
Explanation: GOAL IS TO SHOW IF THERE IS LINEAR RELATIONSHIP BETWEEN HEIGHT AND SHOE SIZE - USING YELLOWBRICK
End of explanation
# YOU WILL HAVE TO INSTALL OPENPYXL - pip install openpyxl - TO BE ABLE TO OPEN EXCEL FILES WITH PANDAS
df = pd.read_excel('data/wo_men.xlsx', sheet_name='wo_men')
df.head(2)
ds = df.drop(['time', 'sex', 'height', 'shoe_size - German', 'height in feet - String', 'height in inches'], axis=1)
ds.shape
ds.columns
X = ds.drop(['shoe_size-american'], axis=1)
y = ds['shoe_size-american']
Explanation: **DATASET WAS TAKEN FROM https://osf.io/ja9dw/ AND CONVERTED TO AMERICAN SHOE SIZES MANUALLY. SEE OTHER TABS IN WO_MEN.XLSX
End of explanation
viz = Rank2D(algorithm='pearson')
viz.fit_transform(ds)
viz.show()
viz = JointPlotVisualizer(columns=['Height in Feet', 'shoe_size-american'])
viz.fit_transform(ds)
viz.show()
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4, random_state=42)
models = [
    LinearRegression(),
    Ridge(alpha=2),
    SGDRegressor(max_iter=100),
    KernelRidge(alpha=2),
    SVR(),
    RandomForestRegressor(n_estimators=5),
    GradientBoostingRegressor(n_estimators=5)
]
def visualize_model(X, y, estimator, **kwargs):
    viz = ResidualsPlot(estimator, **kwargs)
    viz.fit(X.values, y)
    viz.score(X.values, y)
    viz.show()
    viz = PredictionError(model)
    viz.fit(X_train.values, y_train)
    viz.score(X_test.values, y_test)
    viz.show()
for model in models:
    visualize_model(X, y, model)
Explanation: Women is coded as 1 vs Man being 0 so that's why there is negative correlation between sex and shoe size
End of explanation
model = RandomForestRegressor(n_estimators=5)
cv = KFold(n_splits=5, shuffle=True, random_state=42)
viz = cv_scores(model, X, y, cv=cv, scoring='r2')
viz = LearningCurve(model, cv=cv, scoring='r2', )
viz.fit(X, y)
viz.show()
viz = FeatureImportances(model, stack=True, relative=False)
viz.fit(X, y)
viz.show()
Explanation: SPECIFIC MODEL TUNING
End of explanation
viz = ValidationCurve(RandomForestRegressor(), param_name='n_estimators', param_range=range(1, 10), cv=cv, scoring='r2')
viz.fit(X, y)
viz.show()
Explanation: RANDOM FOREST REGRESSOR HYPERPARAMETER TUNING
End of explanation
alphas = np.logspace(1, 2, 20)
viz = ManualAlphaSelection(Ridge(), alphas=alphas, cv=cv, scoring='r2')
viz.fit(X, y)
viz.show()
viz = CooksDistance()
viz.fit(X, y)
viz.show()
Explanation: USE MODEL THAT HAS ALPHA AS PARAMETERS - RIDGE
End of explanation
<END_TASK>