Spaces:
Runtime error
Runtime error
File size: 2,586 Bytes
cc1c4e2 d84cbc8 cc1c4e2 d84cbc8 cc1c4e2 d84cbc8 cc1c4e2 |
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 Repais")
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)) |