File size: 583 Bytes
98b0379
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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]}')