|
import streamlit as st
|
|
import pandas as pd
|
|
from sklearn.preprocessing import StandardScaler
|
|
|
|
def predict_cluster(model, selected_features):
|
|
st.write("### Predict Cluster")
|
|
|
|
user_input = {}
|
|
for feature in selected_features:
|
|
user_input[feature] = st.number_input(f'Enter {feature}', value=0.0)
|
|
|
|
user_df = pd.DataFrame(user_input, index=[0])
|
|
|
|
scaler = StandardScaler()
|
|
user_df_scaled = scaler.fit_transform(user_df)
|
|
|
|
cluster = model.predict(user_df_scaled)
|
|
st.write(f'The predicted cluster for the input data is: {cluster[0]}')
|
|
|