Boston Housing: Prediction of House Price

Boston Housing Data set load (Head And Tail )Lookup

Tail view of Dataset

EDA- Exploratory Data Analysis

Summary

Summary of Boston Dataset

Correlation

Heatmap

Linear Regression

plt.figure(figsize=(12,10));
sns.regplot(X, y,robust=True);
plt.xlabel(‘average number of rooms per dwelling’)
plt.ylabel(“Median value of owner-occupied homes in $1000's”)
plt.show();

sns.jointplot(x=’RM’, y=’MEDV’, data=df, kind=’reg’, size=10);
plt.show();

X = df[‘LSTAT’].values.reshape(-1,1)
y = df[‘MEDV’].values
model.fit(X, y)
plt.figure(figsize=(12,10));
sns.regplot(X, y);
plt.xlabel(‘% Lower status of the population’)
plt.ylabel(“Median value of owner-occupied homes in $1000's”)
plt.show();

sns.jointplot(x=’LSTAT’, y=’MEDV’, data=df, kind=’reg’, size=10);
plt.show();

Robust Regression

Performance Evaluation of Regression Model

Method 1: Residual Analysis

plt.figure(figsize=(12,8))
plt.scatter(y_train_pred, y_train_pred — y_train, c=’blue’, marker=’o’, label=’Training data’)
plt.scatter(y_test_pred, y_test_pred — y_test, c=’red’, marker=’*’, label=’Test data’)
plt.xlabel(‘Predicted values’)
plt.ylabel(‘Residuals’)
plt.legend(loc=’upper left’)
plt.hlines(y=0, xmin=-10, xmax=50, lw=2, color=’k’)
plt.xlim([-10, 50])
plt.show()

Method 2: Mean Squared Error (MSE)

Method 3: Coefficient of Determination

SSE: Sum of squared errors

SST: Total sum of squares

Thank you

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Harsh

Harsh

Data Scientist|Machine Learning|Python|R|MYSQL•|AI-NLP