|
import joblib |
|
import pandas as pd |
|
import streamlit as st |
|
|
|
model = joblib.load('model (2).joblib') |
|
unique_values = joblib.load('unique_values (2).joblib') |
|
|
|
unique_CL = unique_values["Color"] |
|
unique_SC = unique_values["Spectral_Class"] |
|
|
|
def main(): |
|
st.title("My star type") |
|
st.image("https://img.freepik.com/free-vector/different-types-stars-dark-space_1308-37762.jpg") |
|
with st.form("questionaire"): |
|
K = st.slider('Temperature',min_value=1500,max_value=40000) |
|
L = st.slider('Relative Luminosity',min_value=0,max_value=1000000) |
|
R = st.slider('Relative Radius',min_value=0,max_value=2000) |
|
AM = st.slider('Absolute Magnitude',min_value=0,max_value=25) |
|
Color = st.selectbox("General Color of Spectrum",options=unique_CL) |
|
Spectral_Class = st.selectbox("Spectral_Class",options=unique_SC) |
|
clicked = st.form_submit_button("Predict type") |
|
if clicked: |
|
result = model.predict(pd.DataFrame({"Temperature(K)": [K], |
|
"Relative Luminosity(Watts)": [L], |
|
"Relative Radius(m)": [R], |
|
"Absolute Magnitude": [AM], |
|
"Color": [Color], |
|
"Spectral_Class": [Spectral_Class] |
|
}) |
|
) |
|
if result[0] == 0: |
|
result = "Red " |
|
elif result[0] == 1: |
|
result = "Brown" |
|
elif result[0] == 2: |
|
result = "White" |
|
elif result[0] == 3: |
|
result = "Main Sequence" |
|
elif result[0] == 4: |
|
result = "Main " |
|
else: |
|
result = "Iris-virginica" |
|
|
|
st.write(f"Your predicted class is {result}") |
|
|
|
if __name__=="__main__": |
|
main() |