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