kirchoof commited on
Commit
def8563
1 Parent(s): c7e7dc0

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -0
app.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit
2
+ import pickle
3
+ import numpy
4
+ import sklearn
5
+ # web app on your desktop local host
6
+ #run on your pycharm terminal ' streamlit run app.py '
7
+ # if using command window ensure the path is correct.. c:\users\idom...\pycharm..\machin learing>
8
+ # that is pionting to your python file
9
+ loaded_model = pickle.load(open('MWmodel.sav','rb'))
10
+ #create function to handle predicition
11
+ def microwave_fault_prediction (user_input_data):
12
+ #convert to array
13
+ Input_array = numpy.asarray(user_input_data)
14
+ Input_array_reshaped = Input_array.reshape(1, -1)
15
+ make_prediction = loaded_model.predict(Input_array_reshaped)
16
+ print(make_prediction) # make_prediction= [10], pos is 0
17
+
18
+ if make_prediction== 0:
19
+ return 'site is up'
20
+ elif make_prediction == 1:
21
+ return'site is down: fault: 1. inteference 2. misalignment 3. one of the odu is faulty'
22
+ elif make_prediction == 2:
23
+ return 'site is down: fault: 1. NO power at remote site(A),2.ODU offline remote site(A)(check alarm \'IF cable open\') '
24
+ elif make_prediction == 3:
25
+ return 'site is down: fault:1.ODu hunged at remote site(A), reset power at both sites(A,B)'
26
+ elif make_prediction == 4:
27
+ return 'site is down: fault: 1. cascaded cable faulty at hub Site (B), 2. ODU/IDU/If cable offline,at remote end'
28
+ elif make_prediction == 5:
29
+ return'site is down: fault: 1 ODU at hub site(B)degraded( reset ODU, reterminate IF cable,check alarm)'
30
+ elif make_prediction == 6:
31
+ return 'site is down: faulty: if power is okay, odu burnt at either remote site (A) OR (B)'
32
+ else: # do feature elimination for data irrelevant to outcome
33
+ return 'case 7: site status cannot be determined by RSL data'
34
+
35
+ #construct interface for user data input
36
+ def main():
37
+ #give a title
38
+ streamlit.title('microwave fault detection web app')
39
+ #get input data from user
40
+ RSLA = streamlit.number_input('Site A Local end: enter RSL of the site, it must be negative number, input zero for no supervision',min_value=-99, max_value=0, value=-30, step=1,key= 'rsla')
41
+ #key= 'rslb' is to distinguish two similar widgets 'text_input' in streamlit
42
+ RSLB = streamlit.number_input('Site B Remote end: enter RSL of the Hub site, it must be negative number, input zero for no supervision',min_value=-99, max_value=0, value=-30, step=1,key= 'rslb')
43
+ #code for prediction
44
+ detection ="" #declare this variable to hold result like empty list
45
+ #mylist = []
46
+ if streamlit.button('click here for fault prediction'):
47
+ detection=microwave_fault_prediction([RSLA,RSLB])
48
+ #convert inputs into a single parameter using list [1,2]
49
+ #microwave_fault_prediction ...call the function to process input
50
+ streamlit.success(detection)
51
+ if __name__ == '__main__':
52
+ main()
53
+
54
+
55
+ # web app on your desktop local host
56
+ #run on your pycharm terminal ' streamlit run microwaveAPP.py '
57
+ # if using command window ensure the path is correct.. c:\users\idom...\pycharm..\machin learing>
58
+ # that is pionting to your python file
59
+