From 83c1a717ff267cb360c6f3d6eb23a26b80c44758 Mon Sep 17 00:00:00 2001 From: Vinotha10 <153293953+Vinotha10@users.noreply.github.com> Date: Tue, 5 Nov 2024 23:02:35 +0530 Subject: [PATCH] Create ans --- ML/1_linear_reg/Exercise/ans | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 ML/1_linear_reg/Exercise/ans diff --git a/ML/1_linear_reg/Exercise/ans b/ML/1_linear_reg/Exercise/ans new file mode 100644 index 00000000..d2f81e2c --- /dev/null +++ b/ML/1_linear_reg/Exercise/ans @@ -0,0 +1,17 @@ +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +from sklearn import linear_model +df=pd.read_csv(r"C:\Users\Lenovo\Documents\Machine Learning\canada_per_capita_income.csv") +df +reg=linear_model.LinearRegression() +reg.fit(df[['year']],df['per_capita_income (US$)']) +reg.predict([[2020]]) +%matplotlib inline +import matplotlib.pyplot as plt + +plt.xlabel('Year') +plt.ylabel('Per Capita Income') +plt.scatter(df.year, df['per_capita_income (US$)'], color='red', marker='+') +plt.plot(df.year, reg.predict(df[['year']]), color='green') +plt.show()