<jupyter_start><jupyter_text>**From here we can conclude that smoking has direct correlation(0.67) with the medical charges, and then age has a correlation of 0.53**<jupyter_code>%config InlineBackend.figure_format = 'png'
sns.pairplot(data[numerical]);
sns.scatterplot(data=data, x="age",y="log_charges", hue="sex_male")<jupyter_output><empty_output><jupyter_text>Standard scaling<jupyter_code>from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
from sklearn.linear_model import Ridge, LinearRegression
from sklearn import metrics
scores = []<jupyter_output><empty_output><jupyter_text>**Linear Regression:**<jupyter_code>modelLinR= LinearRegression(normalize = True)
modelLinR.fit(X_train_scaled,y_train)
y_pred_lin = modelLinR.predict(X_test_scaled)
error_LinR = metrics.mean_absolute_error(y_pred_lin, y_test)
print(error_LinR)
scores.append({"Linear Regression", error_LinR})<jupyter_output>0.3845380978425162<jupyter_text>**Ridge Regression:**<jupyter_code>modelRidR= Ridge()
modelRidR.fit(X_train_scaled,y_train)
y_pred_rid = modelRidR.predict(X_test_scaled)
error_RidR = metrics.mean_absolute_error(y_pred_rid, y_test)
print(error_RidR)
scores.append({"Ridge Regression", error_RidR})<jupyter_output>0.38408577035331914<jupyter_text>**Random Forest Regression:**<jupyter_code>from sklearn.ensemble import RandomForestRegressor, GradientBoostingRegressor, ExtraTreesRegressor, AdaBoostRegressor
model_rf = RandomForestRegressor(max_depth=15, n_estimators=10, max_features=5)
model_rf.fit(X_train_scaled, y_train)
y_pred_rf = model_rf.predict(X_test_scaled)
error_rf = metrics.mean_absolute_error(y_pred_rf, y_test)
print(error_rf)
scores.append({"Random Forest Regression", error_rf})<jupyter_output>0.27814374806538783<jupyter_text>**Gradient Boost Regression:**<jupyter_code>model_gb = GradientBoostingRegressor()
model_gb.fit(X_train_scaled, y_train)
y_pred_gb = model_gb.predict(X_test_scaled)
error_gb = metrics.mean_absolute_error(y_pred_gb, y_test)
print(error_gb)
scores.append({"Gradient Boosting Regression", error_gb})<jupyter_output>0.24506436969876289<jupyter_text>**Extra Trees Regression:**<jupyter_code>model_et = ExtraTreesRegressor()
model_et.fit(X_train_scaled, y_train)
y_pred_et = model_et.predict(X_test_scaled)
error_et = metrics.mean_absolute_error(y_pred_et, y_test)
print(error_et)
scores.append({"Extra Trees Regression", error_et})<jupyter_output>0.26950965687717904
{'fraction_non_alphanumeric': 0.10788216560509555, 'fraction_numerical': 0.03980891719745223, 'mean_word_length': 12.807692307692308, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 24, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '122089', 'license': 'MIT', 'n_tokens_mistral': 1031, 'n_tokens_neox': 956, 'n_words': 128, 'path': 'Regression Medical Cost prediction/medical-cost-prediction.ipynb', 'repo_name': 'krishnapalS/ML-Gallery', 'size': '2512'}