<jupyter_start><jupyter_text>Create linreg for house sqt and price<jupyter_code>from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X_1_sqft, y_price, test_size=0.2, random_state=0)
X_train= X_train.values.reshape(-1, 1)
y_train= y_train.values.reshape(-1, 1)
X_test = X_test.values.reshape(-1, 1)
y_test = y_test.values.reshape(-1, 1)
print(" X train shape: {} - X test shape: {}".format(X_train.shape, X_test.shape))
print(" y train shape: {} - y test shape: {}".format(y_train.shape, y_test.shape))
from sklearn.linear_model import LinearRegression
linreg = LinearRegression()
linreg.fit(X_train, y_train)
print(y_price.mean())
y_pred = linreg.predict(X_test)
print(y_pred.shape)
print(house['sqft_living'].mean())
print(house['zipcode'].max())
from sklearn.metrics import mean_squared_error
print('RMSE score: {:.3f}'.format(mean_squared_error(y_test, y_pred, squared = False)))
print('MSE score: {:.3f}'.format(mean_squared_error(y_test, y_pred, squared=True)))
my_props = ['sqft_living', 'bedrooms',  'bathrooms', 'floors', 'zipcode', 'sqft_lot']
X_multi_props = house[my_props]
print(X_multi_props.head(3))
higher_val = house[house.price > 550000]
higher_val.head(3)<jupyter_output>sqft_living  bedrooms  bathrooms  floors  zipcode  sqft_lot
0         1180         3       1.00     1.0    98178    5650.0
1         2570         3       2.25     2.0    98125    7242.0
2          770         2       1.00     1.0    98028   10000.0<jupyter_text>Split the multi variable linear regression set<jupyter_code>X_train_mutli, X_test_multi, y_train_multi, y_test_multi = train_test_split(X_multi_props, y_price, test_size=0.2, random_state=0)
lin_reg_multi = LinearRegression().fit(X_train_mutli, y_train_multi)

print('Coefficient: {}'.format(lin_reg_multi.coef_))
print('Inercept: {}'.format(lin_reg_multi.intercept_))
list(zip(my_props, lin_reg_multi.coef_))
y_pred_multi = lin_reg_multi.predict(X_test_multi)
print('RMSE score: {:.3f}'.format(mean_squared_error(y_test_multi, y_pred_multi, squared = False)))
print('MSE score: {:.3f}'.format(mean_squared_error(y_test_multi, y_pred_multi, squared=True)))<jupyter_output>RMSE score: 244004.774
MSE score: 59538329555.319
{'fraction_non_alphanumeric': 0.13303370786516855, 'fraction_numerical': 0.05078651685393258, 'mean_word_length': 5.585798816568047, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, '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': '301692', 'license': 'MIT', 'n_tokens_mistral': 940, 'n_tokens_neox': 858, 'n_words': 157, 'path': '2_ML_Combined_Courses/Course/Week-1/house_data_pandas.ipynb', 'repo_name': 'syedmeesamali/CourseraPlus', 'size': '2225'}