Spaces:
Runtime error
Runtime error
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) |