From 742581715fa0c2f68668f167b9de01d0504c3198 Mon Sep 17 00:00:00 2001 From: Kristian Perriu <92625983+21Christian@users.noreply.github.com> Date: Sun, 16 Oct 2022 21:56:10 +0200 Subject: [PATCH] Create GDP Predictor Predicting the GDP of a country using linear regression. The code is made to handle the year and the GDP of the country --- GDP Predictor | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 GDP Predictor diff --git a/GDP Predictor b/GDP Predictor new file mode 100644 index 00000000..3fec1412 --- /dev/null +++ b/GDP Predictor @@ -0,0 +1,18 @@ +# importing the needed libraries +import pandas as pd +from sklearn import linear_model +from sklearn.tree import DecisionTreeClassifier +import matplotlib.pyplot as plt + +# loading the data +df = pd.read_csv('the path of your file in csv format') + +# building the graph do visualize the data +plt.xlabel('Year') +plt.ylabel('Per Capita Income') +plt.scatter(df.year, df.income) + +# making prediction using linear regression +reg = linear_model.LinearRegression() +reg.fit(df[['year']].values, df.income) +reg.predict([[2022]])