Spaces:
Sleeping
Sleeping
| import joblib | |
| import pandas as pd | |
| # 🔁 Kaydedilen modeli ve özellik listesini yükle | |
| model = joblib.load("churn_model.pkl") | |
| model_features = joblib.load("model_features.pkl") | |
| # 🔍 Müşteri verisi (güncel örneğe göre) | |
| customer = { | |
| 'gender': True, # Female → True | |
| 'SeniorCitizen': False, | |
| 'Partner': True, | |
| 'Dependents': False, | |
| 'PhoneService': True, | |
| 'PaperlessBilling': True, | |
| 'tenure': 28, | |
| 'MonthlyCharges': 104.8, | |
| 'TotalCharges': 3046.05, | |
| 'MultipleLines_No': False, | |
| 'MultipleLines_No phone service': False, | |
| 'MultipleLines_Yes': True, | |
| 'InternetService_DSL': False, | |
| 'InternetService_Fiber optic': True, | |
| 'InternetService_No': False, | |
| 'OnlineSecurity_No': True, | |
| 'OnlineSecurity_Yes': False, | |
| 'OnlineSecurity_No internet service': False, | |
| 'OnlineBackup_No': True, | |
| 'OnlineBackup_Yes': False, | |
| 'OnlineBackup_No internet service': False, | |
| 'DeviceProtection_No': False, | |
| 'DeviceProtection_Yes': True, | |
| 'DeviceProtection_No internet service': False, | |
| 'TechSupport_No': False, | |
| 'TechSupport_Yes': True, | |
| 'TechSupport_No internet service': False, | |
| 'StreamingTV_No': False, | |
| 'StreamingTV_Yes': True, | |
| 'StreamingTV_No internet service': False, | |
| 'StreamingMovies_No': False, | |
| 'StreamingMovies_Yes': True, | |
| 'StreamingMovies_No internet service': False, | |
| 'Contract_Month-to-month': True, | |
| 'Contract_One year': False, | |
| 'Contract_Two year': False, | |
| 'PaymentMethod_Bank transfer (automatic)': False, | |
| 'PaymentMethod_Credit card (automatic)': False, | |
| 'PaymentMethod_Electronic check': True, | |
| 'PaymentMethod_Mailed check': False | |
| } | |
| # Eksik kalan tüm özellikleri sıfırla | |
| full_input = {col: customer.get(col, 0) for col in model_features} | |
| X_test = pd.DataFrame([full_input]) | |
| # 🎯 Tahmin ve olasılık | |
| prediction = model.predict(X_test)[0] | |
| proba = model.predict_proba(X_test)[0][1] | |
| # 📝 Sonuç | |
| label = "CHURN edecek" if prediction == 1 else "Kalacak" | |
| print(f"📊 Tahmin: {label}") | |
| print(f"🎯 Churn olasılığı: %{proba * 100:.2f}") | |