Spaces:
Sleeping
Sleeping
GMARTINEZMILLA
commited on
Commit
•
57e8206
1
Parent(s):
ddf19f6
bugfix: added import lgbm
Browse files
app.py
CHANGED
@@ -139,10 +139,33 @@ elif page == "Customer Analysis":
|
|
139 |
model_path = f'models/modelo_cluster_{cluster}.txt'
|
140 |
gbm = lgb.Booster(model_file=model_path)
|
141 |
st.write(f"Loaded model for cluster {cluster}")
|
|
|
142 |
|
143 |
# Load X_predict for that cluster and extract customer-specific data
|
144 |
X_predict_cluster = pd.read_csv(f'predicts/X_predict_cluster_{cluster}.csv')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
X_cliente = X_predict_cluster[X_predict_cluster['cliente_id'] == customer_code]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
if not X_cliente.empty:
|
148 |
# Make Prediction for the selected customer
|
|
|
139 |
model_path = f'models/modelo_cluster_{cluster}.txt'
|
140 |
gbm = lgb.Booster(model_file=model_path)
|
141 |
st.write(f"Loaded model for cluster {cluster}")
|
142 |
+
|
143 |
|
144 |
# Load X_predict for that cluster and extract customer-specific data
|
145 |
X_predict_cluster = pd.read_csv(f'predicts/X_predict_cluster_{cluster}.csv')
|
146 |
+
|
147 |
+
# Debugging information
|
148 |
+
st.write(f"Shape of X_predict_cluster: {X_predict_cluster.shape}")
|
149 |
+
st.write("First few rows of X_predict_cluster:")
|
150 |
+
st.write(X_predict_cluster.head())
|
151 |
+
st.write("Unique cliente_id values in X_predict_cluster:")
|
152 |
+
st.write(X_predict_cluster['cliente_id'].unique())
|
153 |
+
|
154 |
+
st.write(f"Type of customer_code: {type(customer_code)}")
|
155 |
+
st.write(f"Value of customer_code: {customer_code}")
|
156 |
+
|
157 |
X_cliente = X_predict_cluster[X_predict_cluster['cliente_id'] == customer_code]
|
158 |
+
st.write(f"Shape of X_cliente after filtering: {X_cliente.shape}")
|
159 |
+
|
160 |
+
# Additional checks if X_cliente is empty
|
161 |
+
if X_cliente.empty:
|
162 |
+
X_cliente_str = X_predict_cluster[X_predict_cluster['cliente_id'].astype(str) == str(customer_code)]
|
163 |
+
X_cliente_int = X_predict_cluster[X_predict_cluster['cliente_id'].astype(int) == int(customer_code)]
|
164 |
+
st.write(f"Shape of X_cliente_str: {X_cliente_str.shape}")
|
165 |
+
st.write(f"Shape of X_cliente_int: {X_cliente_int.shape}")
|
166 |
+
|
167 |
+
st.write("Data types in X_predict_cluster:")
|
168 |
+
st.write(X_predict_cluster.dtypes)
|
169 |
|
170 |
if not X_cliente.empty:
|
171 |
# Make Prediction for the selected customer
|