Spaces:
Runtime error
Runtime error
File size: 2,026 Bytes
3352236 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
import streamlit as st
import pandas as pd
import numpy as np
import pickle
import base64
import seaborn as sns
import matplotlib.pyplot as plt
st.write("""
# Stellar Detection App
Stellar detection App adalah aplikasi untuk mendeteksi bintang star dan galaxy.
Aplikasi ini mendeteksi bintang menggunakan data Stellar Classification.
""")
url_dataset = f'<a href="churn_data.csv">Download Dataset CSV File</a>'
st.markdown(url_dataset, unsafe_allow_html=True)
def user_input_features() :
alpha = st.sidebar.slider('Alpha', 0.005528,359.99981)
delta = st.sidebar.slider('Delta', -18.785328,83.000519)
u = st.sidebar.slider('U', -9999.0,32.78139)
g = st.sidebar.slider('G', -9999.0,31.60224)
r = st.sidebar.slider('R', 9.82207,29.57186)
i = st.sidebar.slider('I', 9.469903,32.14147)
z = st.sidebar.slider('Z', -9999.0,29.38374)
redshift = st.sidebar.slider('Redshift', -0.009971,7.011245)
data = {'alpha':[alpha],
'delta':[delta],
'u':[u],
'g':[g],
'r':[r],
'i':[i],
'z':[z],
'redshift':[redshift]}
features = pd.DataFrame(data)
return features
input_df = user_input_features()
star_raw = pd.read_csv('star_classification.csv')
star_raw.fillna(0, inplace=True)
star = star_raw.drop(columns=['class'])
df = pd.concat([input_df,star],axis=0)
df = df[:1] # Selects only the first row (the user input data)
df.fillna(0, inplace=True)
features = ['alpha', 'delta', 'u', 'g', 'r', 'i', 'z', 'redshift']
df = df[features]
st.subheader('User Input features')
st.write(df)
load_clf = pickle.load(open('stellar_clf.pkl', 'rb'))
detect = load_clf.predict(df)
detect_proba = load_clf.predict_proba(df)
star_labels = np.array(['Not Star','Star'])
st.subheader('Detection')
st.write(star_labels[detect[0]])
st.subheader('Detection Probability')
df_prob = pd.DataFrame(data = detect_proba,
index = ['Probability'],
columns = star_labels)
st.write(df_prob) |