text_plain_output_1.png
from sklearn.linear_model import LinearRegression

from sklearn.metrics import mean_absolute_error,mean_squared_error,r2_score

import numpy as np

import numpy as np # linear algebra

import pandas as pd

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

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

health_data = health_data.drop(columns=['BCHC Requested Methodology', 'Source', 'Methods', 'Notes'])

health_data.columns

health_data.isna().sum()

categorical_cols = health_data.select_dtypes(exclude=np.number).columns

train_y.shape

model = LinearRegression()
model.fit(train_x, train_y)

model.coef_

model.intercept_

train_predict = model.predict(train_x)
test_predict = model.predict(test_x)

print('MSE - Train :', mean_squared_error(train_y, train_predict))
print('MSE - Test :', mean_squared_error(test_y, test_predict))
print('MAE - Train :', mean_absolute_error(train_y, train_predict))
print('MAE - Test :', mean_absolute_error(test_y, test_predict))
print('R2 - Train :', r2_score(train_y, train_predict))
print('R2 - Test :', r2_score(test_y, test_predict))
print('Mape - Train:', np.mean(np.abs((train_y, train_predict))))
print('Mape - Test:', np.mean(np.abs((test_y, test_predict))))