image_output_1.png
from sklearn.linear_model import LinearRegression

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import seaborn as sns

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
sns.set
data = pd.read_csv('../input/boston-housing-dataset/HousingData.csv')

X = data.drop('MEDV', axis=1).values
Y = data['MEDV'].values

Room_number = X[:, 5]
Room_number = Room_number.reshape(-1, 1)
Y = Y.reshape(-1, 1)

from sklearn.linear_model import LinearRegression
regression = LinearRegression()
regression.fit(Room_number, Y)
regression_line = np.linspace(min(Room_number), max(Room_number))
plt.scatter(Room_number, Y, color='green')
plt.xlabel('Average Room number')
plt.ylabel('Average price (x1000 $)')
plt.title('The relationship between the number of rooms and the price of the house')
plt.plot(regression_line, regression.predict(regression_line), color='black', linewidth=3)
plt.show()