Issue
I don't understand the error: ValueError: Item wrong length 4225 instead of 1409. Not clear to me what is the wrong length and why.
y_pred = model.predict_proba(x_val)[:,1] # we only want the column that predicts churn
churn_descision = (y_pred >= 0.5)
df_val[churn_descision].customerid
--------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-256-48412e0fc159> in <module>
----> 1 df_val[churn_descision].customerid
2 #The company could consider sending promotional material to these customers based on the prediction
1 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/frame.py in _getitem_bool_array(self, key)
3495 elif len(key) != len(self.index):
3496 raise ValueError(
-> 3497 f"Item wrong length {len(key)} instead of {len(self.index)}."
3498 )
3499
ValueError: Item wrong length 4225 instead of 1409.
Solution
Issue is with the df_val and churn_descision having different shapes. After comparing notes with another student, I see both should be 1409
churn_decision.shape, df_val.shape ((1409,), (1409, 20))
Answered By - Gregory Morris
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.