Pranavadhar commited on
Commit
377dfb9
·
1 Parent(s): 1c37de2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -22
app.py CHANGED
@@ -1,29 +1,31 @@
 
1
  import gradio as gr
2
- import pickle
3
- import pickletools
4
 
5
 
6
- def make_prediction(MEAN, VARIANCE, KURTOSIS):
7
- with open("decision.pkl", "rb") as f:
8
- rot = pickle.load(f)
9
- preds = rot.predict([[MEAN, VARIANCE, KURTOSIS]])
10
- print(preds)
11
- return preds
12
 
 
 
13
 
14
- MEAN_input = gr.Number(label="Enter the mean value:")
15
- VARIANCE_input = gr.Number(label="Enter the variance value:")
16
- KURTOSIS_input = gr.Number(label="Enter the kurtosis value:")
17
- output = gr.Textbox(label="CONDITION OF THE MACHINE")
18
 
19
- app = gr.Interface(fn=make_prediction, inputs=[
20
- MEAN_input, VARIANCE_input, KURTOSIS_input], outputs=output, title="MOTOR FAULT DETECTION",
21
- description="This is an END to END EMBEDDED DIGITAL SIGNAL PROCESSING(EDSP) project done to predict the condition of the motor by giving the inputs in the prompt. \n\n"
22
- "This fault detection project has been deployed to showcase the main objective of the condition of the machine wheather it is in a healthy or in an unhealthy condition. \n\n"
23
- # "MODEL DEVELOPMENT AND MODEL DEPLOYMENT: PRANAVADHAR A. \n\n"
24
- "DEPLOYMENT TOOL: GRADIO \n\n"
25
- # "GITHUB: https://github.com/Pranavadhar \n\n"
26
- # "LINKED IN: https://www.linkedin.com/in/pranavadhar-a-b19525289/ \n\n")
27
- )
28
 
29
- app.launch(share=True)
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
  import gradio as gr
3
+ from sklearn.tree import DecisionTreeClassifier
4
+ from sklearn.model_selection import train_test_split
5
 
6
 
7
+ def fault_predictor(mean, variance, kurtosis):
8
+ df = pd.read_csv('final_feat_xtract.csv')
9
+ X = df[['Mean', 'Variance', 'Kurtosis']]
10
+ y = df['Condition']
11
+ X_train, _, y_train, _ = train_test_split(
12
+ X, y, test_size=0.2, random_state=42)
13
 
14
+ model = DecisionTreeClassifier()
15
+ model.fit(X_train, y_train)
16
 
17
+ user_input_df = pd.DataFrame(
18
+ {'Mean': [mean], 'Variance': [variance], 'Kurtosis': [kurtosis]})
19
+ prediction = model.predict(user_input_df)
20
+ return prediction[0]
21
 
 
 
 
 
 
 
 
 
 
22
 
23
+ iface = gr.Interface(fn=fault_predictor,
24
+ inputs=["number", "number", "number"],
25
+ outputs=gr.Textbox(label="Condition of the Machine"),
26
+ live=True,
27
+ title="MACHINE CONDITION DETECTION - AN EDSP END SEM PROJECT",
28
+ description="This is an END to END EMBEDDED DIGITAL SIGNAL PROCESSING(EDSP) project done to predict the condition of the motor by giving the inputs in the prompt. \n\n"
29
+ "This fault detection project has been deployed to showcase the main objective of the condition of the machine whether it is in a healthy or in an unhealthy condition. \n\n"
30
+ "DEPLOYMENT TOOL: GRADIO \n\n")
31
+ iface.launch(share=True)