Spaces:
Sleeping
Sleeping
new update
Browse files
app.py
CHANGED
@@ -30,6 +30,7 @@ if uploaded_file is not None:
|
|
30 |
# ✅ Convertir en catégories
|
31 |
data['Product_line'] = data['Product_line'].astype('category')
|
32 |
data['Payment'] = data['Payment'].astype('category')
|
|
|
33 |
|
34 |
# 📌 Afficher un aperçu des données
|
35 |
st.subheader("📊 Aperçu des Données")
|
@@ -46,7 +47,7 @@ if uploaded_file is not None:
|
|
46 |
residuals = model.resid
|
47 |
|
48 |
if len(residuals) > 5000:
|
49 |
-
residuals_sample = residuals.sample(5000, random_state=42)
|
50 |
else:
|
51 |
residuals_sample = residuals
|
52 |
|
@@ -72,11 +73,11 @@ if uploaded_file is not None:
|
|
72 |
|
73 |
st.subheader("📌 Comparaisons Post-Hoc (Tukey HSD)")
|
74 |
|
75 |
-
if
|
76 |
tukey = pairwise_tukeyhsd(data['Rating'], data['Product_line'])
|
77 |
st.write(tukey.summary())
|
78 |
else:
|
79 |
-
st.error("Erreur :
|
80 |
|
81 |
# ============================
|
82 |
# 📊 Visualisation des Résultats
|
@@ -91,7 +92,7 @@ if uploaded_file is not None:
|
|
91 |
st.pyplot(fig)
|
92 |
|
93 |
# 🔹 Heatmap des Moyennes des Évaluations
|
94 |
-
mean_ratings = data.groupby(['Product_line', 'Payment'])['Rating'].mean().unstack()
|
95 |
fig, ax = plt.subplots(figsize=(8, 5))
|
96 |
sns.heatmap(mean_ratings, annot=True, cmap='coolwarm', ax=ax)
|
97 |
st.pyplot(fig)
|
@@ -117,6 +118,6 @@ if uploaded_file is not None:
|
|
117 |
|
118 |
# 🔹 Visualisation du Clustering
|
119 |
fig, ax = plt.subplots(figsize=(8, 5))
|
120 |
-
sns.scatterplot(x='
|
121 |
-
plt.xticks(rotation=45)
|
122 |
st.pyplot(fig)
|
|
|
30 |
# ✅ Convertir en catégories
|
31 |
data['Product_line'] = data['Product_line'].astype('category')
|
32 |
data['Payment'] = data['Payment'].astype('category')
|
33 |
+
data['Rating'] = pd.to_numeric(data['Rating'], errors='coerce') # Convertir en numérique
|
34 |
|
35 |
# 📌 Afficher un aperçu des données
|
36 |
st.subheader("📊 Aperçu des Données")
|
|
|
47 |
residuals = model.resid
|
48 |
|
49 |
if len(residuals) > 5000:
|
50 |
+
residuals_sample = pd.Series(residuals).sample(5000, random_state=42)
|
51 |
else:
|
52 |
residuals_sample = residuals
|
53 |
|
|
|
73 |
|
74 |
st.subheader("📌 Comparaisons Post-Hoc (Tukey HSD)")
|
75 |
|
76 |
+
if data['Rating'].isna().sum() == 0: # Vérifie qu'il n'y a pas de NaN
|
77 |
tukey = pairwise_tukeyhsd(data['Rating'], data['Product_line'])
|
78 |
st.write(tukey.summary())
|
79 |
else:
|
80 |
+
st.error("Erreur : Des valeurs non numériques ont été détectées dans 'Rating'. Vérifiez votre fichier CSV.")
|
81 |
|
82 |
# ============================
|
83 |
# 📊 Visualisation des Résultats
|
|
|
92 |
st.pyplot(fig)
|
93 |
|
94 |
# 🔹 Heatmap des Moyennes des Évaluations
|
95 |
+
mean_ratings = data.groupby(['Product_line', 'Payment'])['Rating'].mean().unstack().fillna(0)
|
96 |
fig, ax = plt.subplots(figsize=(8, 5))
|
97 |
sns.heatmap(mean_ratings, annot=True, cmap='coolwarm', ax=ax)
|
98 |
st.pyplot(fig)
|
|
|
118 |
|
119 |
# 🔹 Visualisation du Clustering
|
120 |
fig, ax = plt.subplots(figsize=(8, 5))
|
121 |
+
sns.scatterplot(x='Product_line_encoded', y='Rating', hue=data['Cluster'].astype(str), palette='viridis', data=data, ax=ax)
|
122 |
+
plt.xticks(ticks=range(len(encoder.classes_)), labels=encoder.classes_, rotation=45)
|
123 |
st.pyplot(fig)
|