Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import joblib
|
2 |
+
import pandas as pd
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
CL_DICT = {'Red': 1,
|
6 |
+
'Blue': 2,
|
7 |
+
'White': 3,
|
8 |
+
'Yellow': 4,
|
9 |
+
'Orange': 5
|
10 |
+
}
|
11 |
+
|
12 |
+
SC_DICT = {'M': 1,
|
13 |
+
'B': 2,
|
14 |
+
'O': 3,
|
15 |
+
'A': 4,
|
16 |
+
'F': 5,
|
17 |
+
'K': 6,
|
18 |
+
'G': 7
|
19 |
+
}
|
20 |
+
|
21 |
+
model = joblib.load('model_star.joblib')
|
22 |
+
unique_values = joblib.load('unique_values_star.joblib')
|
23 |
+
|
24 |
+
unique_CL = unique_values["Color"]
|
25 |
+
unique_SC = unique_values["Temperature"]
|
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.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=1900,max_value=40000)
|
35 |
+
R = st.slider('Relative Radius',min_value=1900,max_value=40000)
|
36 |
+
AM = st.slider('Absolute Magnitude',min_value=1900,max_value=40000)
|
37 |
+
CL = st.selectbox("General Color of Spectrum",options=unique_CL)
|
38 |
+
SC = 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],
|
42 |
+
"Relative Luminosity": [L],
|
43 |
+
"Relative Radiusducation": [R],
|
44 |
+
"Absolute Magnitude": [AM],
|
45 |
+
"General Color of Spectrum": [CL_DICT[CL]],
|
46 |
+
"Spectral_Class": [SC_DICT[SC]]
|
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 finished income is "+result)
|
63 |
+
|
64 |
+
if __name__=="__main__":
|
65 |
+
main()
|