text_plain_output_1.png
from sklearn.linear_model import LinearRegression

from sklearn.metrics import mean_absolute_error, mean_squared_error, mean_squared_log_error, r2_score

from sklearn.preprocessing import LabelEncoder

import numpy as np # linear algebra

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

Health_df = pd.read_csv('../input/Big_Cities_Health_Data_Inventory.csv')

Health_df.apply(lambda x: len(x.unique()))

Health_df.isna().sum()

Health_df.dropna(subset=['Value'], inplace=True)

from sklearn.preprocessing import LabelEncoder
labelencoder = LabelEncoder()
cat_col = Health_df.select_dtypes(exclude=np.number).drop(['Notes', 'Methods'], axis=1)
num_col = Health_df.select_dtypes(include=np.number)

lm = LinearRegression()

lm.fit(X_train, Y_train)

Y_train_predict = lm.predict(X_train)
Y_test_predict = lm.predict(X_test)

print('MSE Train:', mean_squared_error(Y_train, Y_train_predict))
print('MSE Test:', mean_squared_error(Y_test, Y_test_predict))
print('RMSE Train:', np.sqrt(mean_squared_error(Y_train, Y_train_predict)))
print('RMSE Test:', np.sqrt(mean_squared_error(Y_test, Y_test_predict)))
print('MAE Train', mean_absolute_error(Y_train, Y_train_predict))
print('MAE Test', mean_absolute_error(Y_test, Y_test_predict))
print('R2 Train', r2_score(Y_train, Y_train_predict))
print('R2 Test', r2_score(Y_test, Y_test_predict))