image_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

data = pd.read_csv('/kaggle/input/salary-dataset-simple-linear-regression/Salary_dataset.csv')

data.isnull().sum()

data.isnull().sum().to_frame().rename(columns={0: 'Total No. of Missing Values'})

x = data.YearsExperience
y = data.Salary

w = 9909
b = 21641.1797

def linearRegression(x, w, b):
    pre_y = []
    m = len(x)
    for i in range(m):
        f_wb = w * x[i] + b
        pre_y.append(f_wb)
    return pre_y

y_pred = linearRegression(x, w, b)

plt.plot(x, y_pred, c='b', label='Our Prediction')
plt.scatter(x, y, marker='x', c='r', label='Actual Values')
plt.title('Housing Prices')
plt.ylabel('Price (in 1000s of dollars)')
plt.xlabel('Size (1000 sqft)')
plt.legend()
plt.show()