nornorr commited on
Commit
51a0c47
·
1 Parent(s): 4ae5228

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -24
app.py CHANGED
@@ -30,36 +30,50 @@ st.image("https://study.com/academy/lesson/star-formation-main-sequence-dwarf-gi
30
  def main():
31
  st.text('For comparing all models of ML It can be used for prediction')
32
  with st.form("questionaire"):
33
- Temperature = st.slider('Temperature',min_value=1900,max_value=40000)
34
  L = st.slider('Relative Luminosity',min_value=0,max_value=1000000)
35
  R = st.slider('Relative Radius',min_value=0,max_value=2000)
36
  A_M = st.slider('Absolute Magnitude',min_value=0,max_value=25)
37
  Color = st.selectbox("General Color of Spectrum",options=unique_CL)
38
  Spectral_Class = st.selectbox("Spectral_Class",options=unique_SC)
39
  clicked = st.form_submit_button("Predict type")
40
- if clicked:
41
- result=model.predict(pd.DataFrame({"Temperature": [Temperature],
42
- "Relative Luminosity": [L],
43
- "Relative Radiusducation": [R],
44
- "Absolute Magnitude": [A_M],
45
- "General Color of Spectrum": [CL_DICT[Color]],
46
- "Spectral_Class": [SC_DICT[Spectral_Class]]
47
- }))
48
- # Show prediction
49
- if result[0] == 0:
50
- result = "Red Dwarf"
51
- elif result[0] == 1:
52
- result = "Brown Dwarf"
53
- elif result[0] == 2:
54
- result = "White Dwarf"
55
- elif result[0] == 3:
56
- result = "Main Sequence"
57
- elif result[0] == 4:
58
- result = "Super Giants"
59
- elif result[0] == 5:
60
- result = "Hyper Giants"
61
-
62
- st.success("Your star type is "+result)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  if __name__=="__main__":
65
  main()
 
30
  def main():
31
  st.text('For comparing all models of ML It can be used for prediction')
32
  with st.form("questionaire"):
33
+ K = st.slider('Temperature',min_value=1900,max_value=40000)
34
  L = st.slider('Relative Luminosity',min_value=0,max_value=1000000)
35
  R = st.slider('Relative Radius',min_value=0,max_value=2000)
36
  A_M = st.slider('Absolute Magnitude',min_value=0,max_value=25)
37
  Color = st.selectbox("General Color of Spectrum",options=unique_CL)
38
  Spectral_Class = st.selectbox("Spectral_Class",options=unique_SC)
39
  clicked = st.form_submit_button("Predict type")
40
+ if clicked:
41
+ result = model.predict(pd.DataFrame({"Temperature(K)": [K],
42
+ "Relative Luminosity(Watts)": [L],
43
+ "Relative Radius(m)": [R],
44
+ "Absolute Magnitude": [A_M],
45
+ "Color": [Color],
46
+ "Spectral_Class": [Spectral_Class]})
47
+ )
48
+
49
+ prob = model.predict_prob(pd.DataFrame({"Temperature(K)": [K],
50
+ "Relative Luminosity(Watts)": [L],
51
+ "Relative Radius(m)": [R],
52
+ "Absolute Magnitude": [A_M],
53
+ "Color": [Color],
54
+ "Spectral_Class": [Spectral_Class]})
55
+ )
56
+
57
+ prob = pd.DataFrame(prob, columns = ["Red Dwarf",'Brown Dwarf','White Dwarf','Main Sequence','Super Giants','Hyper Giants']).reset_index(drop=True)
58
+ prob['Type'] = 'Probability'
59
+ prob = prob.set_index('Type')
60
+
61
+ st.write(prob)
62
+
63
+ if result[0] == '0':
64
+ st.text('Red Dwarf')
65
+ elif result[0] == '1':
66
+ st.text('Brown Dwarf')
67
+ elif result[0] == '2':
68
+ st.text('White Dwarf')
69
+ elif result[0] == '3':
70
+ st.text('Main Sequence')
71
+ elif result[0] == '4':
72
+ st.text('Super Giants')
73
+ else:
74
+ st.text('Hyper Giants')
75
+
76
+ st.write("My star type is...", result[0])
77
 
78
  if __name__=="__main__":
79
  main()