Update app.py
Browse files
app.py
CHANGED
@@ -24,16 +24,14 @@ unique_values = joblib.load('unique_values _star.joblib')
|
|
24 |
unique_CL = unique_values["Color"]
|
25 |
unique_SC = unique_values["Spectral_Class"]
|
26 |
|
27 |
-
st.title("My star type")
|
28 |
-
st.image("https://study.com/academy/lesson/star-formation-main-sequence-dwarf-giant-stars.html")
|
29 |
-
|
30 |
def main():
|
31 |
-
st.
|
|
|
32 |
with st.form("questionaire"):
|
33 |
-
K = st.slider('Temperature',min_value=
|
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 |
-
|
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")
|
@@ -41,39 +39,25 @@ def main():
|
|
41 |
result = model.predict(pd.DataFrame({"Temperature(K)": [K],
|
42 |
"Relative Luminosity(Watts)": [L],
|
43 |
"Relative Radius(m)": [R],
|
44 |
-
"Absolute Magnitude": [
|
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 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
elif result[0] ==
|
66 |
-
|
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 |
-
|
75 |
|
76 |
-
st.write("My star type is...", result
|
77 |
|
78 |
if __name__=="__main__":
|
79 |
main()
|
|
|
24 |
unique_CL = unique_values["Color"]
|
25 |
unique_SC = unique_values["Spectral_Class"]
|
26 |
|
|
|
|
|
|
|
27 |
def main():
|
28 |
+
st.title("My star type")
|
29 |
+
st.image("https://img.freepik.com/free-vector/different-types-stars-dark-space_1308-37762.jpg")
|
30 |
with st.form("questionaire"):
|
31 |
+
K = st.slider('Temperature',min_value=1500,max_value=40000)
|
32 |
L = st.slider('Relative Luminosity',min_value=0,max_value=1000000)
|
33 |
R = st.slider('Relative Radius',min_value=0,max_value=2000)
|
34 |
+
AM = st.slider('Absolute Magnitude',min_value=0,max_value=25)
|
35 |
Color = st.selectbox("General Color of Spectrum",options=unique_CL)
|
36 |
Spectral_Class = st.selectbox("Spectral_Class",options=unique_SC)
|
37 |
clicked = st.form_submit_button("Predict type")
|
|
|
39 |
result = model.predict(pd.DataFrame({"Temperature(K)": [K],
|
40 |
"Relative Luminosity(Watts)": [L],
|
41 |
"Relative Radius(m)": [R],
|
42 |
+
"Absolute Magnitude": [AM],
|
43 |
+
"Color": [CL_DICT[Color]],
|
44 |
+
"Spectral_Class": [SC_DICT[Spectral_Class]]})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
)
|
46 |
|
47 |
+
if result[0] == 0:
|
48 |
+
result = 'Red Dwarf'
|
49 |
+
elif result[0] == 1:
|
50 |
+
result ='Brown Dwarf'
|
51 |
+
elif result[0] == 2:
|
52 |
+
result ='White Dwarf'
|
53 |
+
elif result[0] == 3:
|
54 |
+
result ='Main Sequence'
|
55 |
+
elif result[0] == 4:
|
56 |
+
result ='Super Giants'
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
else:
|
58 |
+
result ='Hyper Giants'
|
59 |
|
60 |
+
st.write("My star type is...", result)
|
61 |
|
62 |
if __name__=="__main__":
|
63 |
main()
|