# import required libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from datetime import datetime from datetime import timedelta from sklearn.model_selection import RandomizedSearchCV, GridSearchCV, train_test_split from sklearn.ensemble import RandomForestRegressor from sklearn.metrics import r2_score from sklearn.preprocessing import LabelEncoder from sklearn.preprocessing import StandardScaler import streamlit as st import warnings warnings.filterwarnings('ignore') st.title("Prection of Maimum Number of Repairs") import pandas as pd import numpy as np import pickle # load the saved model using pickle with open('max_repair_model.pkl', 'rb') as file: model = pickle.load(file) # Load the saved manufacturer label encoder object using pickle with open('manufacturer_le.pkl', 'rb') as file1: le = pickle.load(file1) # define the prediction function def predict_max_number_of_repairs(manufacturer, component_age, total_operating_hours, operating_temperature, humidity, vibration_level, pressure, power_input_voltage, previous_number_of_repairs, load_factor, engine_speed, oil_temperature): # encode the manufacturer using the loaded LabelEncoder object manufacturer_encoded = le.transform([manufacturer])[0] # create a DataFrame with the input variables input_data = pd.DataFrame({'Manufacturer': [manufacturer_encoded], 'Component_Age': [component_age], 'Total_Operating_Hours': [total_operating_hours], 'Operating_Temperature': [operating_temperature], 'Humidity': [humidity], 'Vibration_Level': [vibration_level], 'Pressure': [pressure], 'Power_Input_Voltage': [power_input_voltage], 'Previous_number_of_repairs': [previous_number_of_repairs], 'Load_Factor': [load_factor], 'Engine_Speed': [engine_speed], 'Oil_Temperature': [oil_temperature]}) # make the prediction using the loaded model and input data predicted_max_number_of_repairs = model.predict(input_data) # return the predicted max number of repairs as output return np.round(predicted_max_number_of_repairs[0]) # Function calling print(predict_max_number_of_repairs('ABC Company',100.00,1135,70.0,65,3.43,29.90,120,4,0.59,7398,170))