Spaces:
Sleeping
Sleeping
Update utils.py
Browse filesAñadimos debugging y ajustamos la funcion retroalimentación para aseguranos que está funcionando.
utils.py
CHANGED
@@ -113,15 +113,21 @@ def retroalimentacion(cestas, cesta_nueva):
|
|
113 |
# Convert basket from list to string
|
114 |
cesta_unida = ' '.join(cesta_nueva)
|
115 |
|
|
|
|
|
|
|
116 |
# Add the new basket to the historical baskets if it doesn't already exist
|
117 |
if not cestas['Cestas'].isin([cesta_unida]).any():
|
118 |
cestas.loc[len(cestas)] = cesta_unida
|
119 |
-
|
120 |
|
121 |
# Re-save the updated baskets DataFrame
|
122 |
-
|
|
|
|
|
|
|
123 |
else:
|
124 |
-
|
125 |
|
126 |
# Re-vectorize the basket DataFrame
|
127 |
count_vectorizer = CountVectorizer()
|
@@ -135,5 +141,9 @@ def retroalimentacion(cestas, cesta_nueva):
|
|
135 |
|
136 |
dump(count_vectorizer, count_vectorizer_file)
|
137 |
dump(tf_matrix, tf_matrix_file)
|
|
|
|
|
|
|
|
|
138 |
|
139 |
return None
|
|
|
113 |
# Convert basket from list to string
|
114 |
cesta_unida = ' '.join(cesta_nueva)
|
115 |
|
116 |
+
# Debugging message
|
117 |
+
st.write(f"DEBUG: La nueva cesta es {cesta_unida}")
|
118 |
+
|
119 |
# Add the new basket to the historical baskets if it doesn't already exist
|
120 |
if not cestas['Cestas'].isin([cesta_unida]).any():
|
121 |
cestas.loc[len(cestas)] = cesta_unida
|
122 |
+
st.success("✓ Cesta añadida al DataFrame.")
|
123 |
|
124 |
# Re-save the updated baskets DataFrame
|
125 |
+
file_path = 'RecommendationFiles/cestas_final.csv'
|
126 |
+
cestas.to_csv(file_path, index=False)
|
127 |
+
|
128 |
+
st.write(f"DEBUG: Se ha guardado la nueva cesta en {file_path}")
|
129 |
else:
|
130 |
+
st.warning("⚠️ La cesta ya existe en el DataFrame.")
|
131 |
|
132 |
# Re-vectorize the basket DataFrame
|
133 |
count_vectorizer = CountVectorizer()
|
|
|
141 |
|
142 |
dump(count_vectorizer, count_vectorizer_file)
|
143 |
dump(tf_matrix, tf_matrix_file)
|
144 |
+
|
145 |
+
# Debugging messages
|
146 |
+
st.write(f"DEBUG: Se ha generado la nueva versión del count_vectorizer: {count_vectorizer_file}")
|
147 |
+
st.write(f"DEBUG: Se ha generado la nueva versión del tf_matrix: {tf_matrix_file}")
|
148 |
|
149 |
return None
|