Streamlit App prognostiziert immer dasselbe Ergebnis [geschlossen]Python

Python-Programme
Anonymous
 Streamlit App prognostiziert immer dasselbe Ergebnis [geschlossen]

Post by Anonymous »

📄 Ausgabe: Streamlit App prognostiziert immer dasselbe Ergebnis, obwohl das Modell in Notebook < /p>

🚀 Zusammenfassung < /H2>
hi All 👋, < /p>
i geschult hat, um eine SVM -Model zu prognostizieren. In meinem Jupyter -Notizbuch funktioniert das Modell gut und zeigt korrekte Vorhersagen und Wahrscheinlichkeiten an. Wenn es jedoch in einer Streamlit -App bereitgestellt wird, prognostiziert es immer das gleiche Ergebnis ((

Code: Select all

Less Employable
) mit nahezu identischen Wahrscheinlichkeiten [/b], egal welche Eingaben ich verwenden. Verhalten.

Code: Select all

Less Employable< /code>) und die Wahrscheinlichkeiten [url=viewtopic.php?t=12045]ändern[/url] sich kaum. />(https://github.com/Quinnchoong/employability_predictors).
It contains:

[*]Training notebook (Train_Employability_Model_Final.ipynb)

[*]Streamlit app (student_Oblequability_app_final.py) 

[*]  Datensatz (Student_Oblequeability_cp2_2025.xlsx) 

  trained model & scaler (personal.predictor.pkl, scaler.pkl) 
< /li>

 requirements.txt
< /li>
< /ul>

 🎓 Trainingscode < /h3>
">from sklearn.svm import SVC
from sklearn.preprocessing import StandardScaler
from imblearn.over_sampling import SMOTE
import joblib
from sklearn.model_selection import train_test_split

# Prepare data
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, stratify=y, random_state=42)

# Balance with SMOTE
smote = SMOTE()
X_train_res, y_train_res = smote.fit_resample(X_train, y_train)

# Scale
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train_res)
X_test_scaled = scaler.transform(X_test)

# Train SVM
svc = SVC(probability=True, C=10, gamma=0.1, kernel='rbf')
svc.fit(X_train_scaled, y_train_res)

# Save model & scaler
joblib.dump(svc, 'employability_predictor.pkl')
joblib.dump(scaler, 'scaler.pkl')
< /code>

 🖥️ Streamlit-Code < /h3>
import streamlit as st
import pandas as pd
import joblib

# Load model & scaler
model = joblib.load('employability_predictor.pkl')
scaler = joblib.load('scaler.pkl')

# Example input
input_df = pd.DataFrame([{
'GENDER': 1,
'GENERAL_APPEARANCE': 5,
'GENERAL_POINT_AVERAGE': 4.0,
'MANNER_OF_SPEAKING': 5,
'PHYSICAL_CONDITION': 5,
'MENTAL_ALERTNESS': 5,
'SELF-CONFIDENCE': 5,
'ABILITY_TO_PRESENT_IDEAS': 5,
'COMMUNICATION_SKILLS': 5,
'STUDENT_PERFORMANCE_RATING': 5,
'NO_SKILLS': 0,
'Year_of_Graduate': 2022
}])

# Scale & predict
scaled_input = scaler.transform(input_df)
prediction = model.predict(scaled_input)
proba = model.predict_proba(scaled_input)

st.write(f"Prediction: {prediction[0]}")
st.write(f"Probabilities: Employable: {proba[0][1]:.2f}, Less Employable: {proba[0][0]:.2f}")
📄 Sample Input
Example slider values :



Feature
Value




GENDER
1


GENERAL_APPEARANCE
5


General_Point_aververs < /td>
4.0
< /tr>

… < /td> < /> … < /td>
< /tr>

< /tr> < /> < /tbody> < /> < /> < /tbody> < /> < /> < /tbody> < /> < /> < /tbodie /> Egal, was ich diese auf diese ändere, die Ausgabe bleibt gleich. Vorbereitung und Skalierung von Eingängen.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post