From d8414ecee0f30fc0cf3c9ce046443afb6867103b Mon Sep 17 00:00:00 2001 From: Rebecca Merrett Date: Thu, 7 Mar 2019 01:38:37 +0000 Subject: [PATCH] Upload New File --- Getting Started/lm_model.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Getting Started/lm_model.py diff --git a/Getting Started/lm_model.py b/Getting Started/lm_model.py new file mode 100644 index 0000000..f730a48 --- /dev/null +++ b/Getting Started/lm_model.py @@ -0,0 +1,26 @@ +from sklearn import linear_model +from pandas import DataFrame +import pandas as pd +import pandas +import matplotlib.pyplot as plt + +input_data = pandas.read_table("height.csv", sep=",", header=0, names=("weight", "height")) + +plt.scatter(input_data["weight"], input_data["height"]) +#plt.show() + +predictor = pd.DataFrame(input_data, columns=["weight"]) +outcome = pd.DataFrame(input_data, columns=["height"]) + +lm = linear_model.LinearRegression() +lm_model = lm.fit(predictor, outcome) + +predicted_heights = lm.predict(predictor) + +#print("Predicted:") +#print(predicted_heights[0:6]) +#print("Actual:") +#print(outcome[0:6]) + +r_squared = lm.score(predictor, outcome) +print(r_squared) \ No newline at end of file -- libgit2 0.26.0