<jupyter_start><jupyter_text>Adjusting data types<jupyter_code>df.price = df.price.astype("int") 
df.bedrooms = df.bedrooms.astype("int8")
df.bathrooms = df.bathrooms.astype("float32")
df.sqft_living = df.sqft_living.astype("int32")
df.sqft_lot = df.sqft_lot.astype("int32")
df.floors = df.floors.astype("float16")
df.waterfront = df.waterfront.fillna(0).astype("int8")
df.view = df.view.fillna(0).astype("int8")
df.grade = df.grade.astype("int8")
df.condition = df.condition.astype("int8")
df.grade = df.grade.astype("int8")
df.sqft_above = df.sqft_above.astype("int32")
df.sqft_basement = pd.to_numeric(df.sqft_basement, errors='coerce').fillna(0).astype("int32")
df.yr_built = df.yr_built.astype("int16")
df.yr_renovated = df.yr_renovated.fillna(0).astype("int16")
df.zipcode = df.zipcode.astype("int32")
df.sqft_living15 = df.sqft_living.astype("int32")
df.sqft_lot15 = df.sqft_lot.astype("int32")

df = df[df.bedrooms < 33]
df = df[df.sqft_living15 < 12000]<jupyter_output><empty_output><jupyter_text>Feature engineering<jupyter_code>Y = df["price"]
X = df[["sqft_living15", "sqft_living", "floors", "waterfront", "yr_renovated",
        "yr_built", "view", "grade", "bedrooms", "bathrooms"]]<jupyter_output><empty_output><jupyter_text>Splitting the data<jupyter_code>print("-----  Splitting the data in train and test ----")
X_train, X_test, y_train, y_test = train_test_split(X, Y, test_size=0.1, random_state=42)<jupyter_output>-----  Splitting the data in train and test ----<jupyter_text>Training the model<jupyter_code># Training the model
print("-----  Training the model ----")
ridge = Ridge(alpha=0.1, normalize=True)
model = ridge.fit(X_train, y_train)
#print_model = model.summary()<jupyter_output>-----  Training the model ----<jupyter_text>Evaluating the model<jupyter_code>print("-----  Evaluating the model ----")
ridge_pred = ridge.predict(X_train)
err_train = np.sqrt(mean_squared_error(y_train, ridge_pred))
ridge_test = model.predict(X_test)
err_test = np.sqrt(mean_squared_error(y_test, ridge_test))

#print(print_model)
print ("-------------")
print (f"RMSE on train data: {err_train}")
print (f"RMSE on test data: {err_test}")<jupyter_output>-----  Evaluating the model ----
-------------
RMSE on train data: 218639.02273763088
RMSE on test data: 188754.29807201738
{'fraction_non_alphanumeric': 0.18193717277486912, 'fraction_numerical': 0.03795811518324607, 'mean_word_length': 5.514204545454546, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 18, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '399329', 'license': 'MIT', 'n_tokens_mistral': 976, 'n_tokens_neox': 898, 'n_words': 146, 'path': 'Second_ML.ipynb', 'repo_name': 'olehansen538/My_First_EDA_King_County', 'size': '2292'}