saritha5 commited on
Commit
cc1c4e2
1 Parent(s): e20b94f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -1
app.py CHANGED
@@ -1,4 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
2
 
 
 
 
 
 
 
 
 
3
 
4
- st.title("Prection of Maimum Number of Repais")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # import required libraries
3
+
4
+ import pandas as pd
5
+ import numpy as np
6
+ import matplotlib.pyplot as plt
7
+ import seaborn as sns
8
+
9
+ from datetime import datetime
10
+ from datetime import timedelta
11
+ from sklearn.model_selection import RandomizedSearchCV, GridSearchCV, train_test_split
12
+ from sklearn.ensemble import RandomForestRegressor
13
+ from sklearn.metrics import r2_score
14
+ from sklearn.preprocessing import LabelEncoder
15
+ from sklearn.preprocessing import StandardScaler
16
  import streamlit as st
17
+ import warnings
18
+ warnings.filterwarnings('ignore')
19
+
20
+
21
+
22
+ st.title("Prection of Maimum Number of Repais")
23
+
24
+ import pandas as pd
25
+ import numpy as np
26
+ import pickle
27
 
28
+ # load the saved model using pickle
29
+ with open('max_repair_model.pkl', 'rb') as file:
30
+ model = pickle.load(file)
31
+
32
+ # Load the saved manufacturer label encoder object using pickle
33
+ with open('manufacturer_le.pkl', 'rb') as file1:
34
+ le = pickle.load(file1)
35
+
36
 
37
+ # define the prediction function
38
+ 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):
39
+
40
+ # encode the manufacturer using the loaded LabelEncoder object
41
+ manufacturer_encoded = le.transform([manufacturer])[0]
42
+
43
+ # create a DataFrame with the input variables
44
+ input_data = pd.DataFrame({'Manufacturer': [manufacturer_encoded],
45
+ 'Component_Age': [component_age],
46
+ 'Total_Operating_Hours': [total_operating_hours],
47
+ 'Operating_Temperature': [operating_temperature],
48
+ 'Humidity': [humidity],
49
+ 'Vibration_Level': [vibration_level],
50
+ 'Pressure': [pressure],
51
+ 'Power_Input_Voltage': [power_input_voltage],
52
+ 'Previous_number_of_repairs': [previous_number_of_repairs],
53
+ 'Load_Factor': [load_factor],
54
+ 'Engine_Speed': [engine_speed],
55
+ 'Oil_Temperature': [oil_temperature]})
56
+
57
+ # make the prediction using the loaded model and input data
58
+ predicted_max_number_of_repairs = model.predict(input_data)
59
+
60
+ # return the predicted max number of repairs as output
61
+ return np.round(predicted_max_number_of_repairs[0])
62
+ # Function calling
63
+ print(predict_max_number_of_repairs('ABC Company',100.00,1135,70.0,65,3.43,29.90,120,4,0.59,7398,170))