Commit
·
e771dc2
1
Parent(s):
d833aa2
Upload checkin simple regression model.py
Browse files
checkin simple regression model.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import joblib
|
| 2 |
+
import os
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# file_path = os.path.abspath("first_simple_linear_regression.pkl")
|
| 6 |
+
|
| 7 |
+
current_file_path = os.path.abspath(__file__)
|
| 8 |
+
current_folder_path = os.path.dirname(current_file_path)
|
| 9 |
+
model_filename = f'{current_folder_path}\\first_simple_linear_regression.pkl'
|
| 10 |
+
|
| 11 |
+
def load_model_and_predict(x_value):
|
| 12 |
+
#This function loads the model and predict the y values
|
| 13 |
+
#Load the model
|
| 14 |
+
loaded_model = j100oblib.load(model_filename)
|
| 15 |
+
|
| 16 |
+
x_value = np.array([x_value]).reshape(-1,1)
|
| 17 |
+
|
| 18 |
+
predicted_y = loaded_model.predict(x_value)[0]
|
| 19 |
+
return predicted_y
|
| 20 |
+
|
| 21 |
+
end_val = "0"
|
| 22 |
+
print("Bienvenido!")
|
| 23 |
+
while(end_val!="1"):
|
| 24 |
+
x_proposed_value = int(input("Enter your x value: "))
|
| 25 |
+
predicted_y = load_model_and_predict(x_proposed_value)
|
| 26 |
+
|
| 27 |
+
print(f"Your y returne values is {predicted_y}")
|
| 28 |
+
end_val = input("Press one to end, or enter any key to predict anothe y value")
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
|