Skater icon indicating copy to clipboard operation
Skater copied to clipboard

can't replicate rule_lists_titanic_dataset.ipynb

Open Naviden opened this issue 5 years ago • 0 comments

I'm trying to run the examples/rule_lists_titanic_dataset.ipynb I've found a couple of problems which I was able to resolve by doing minor modifications of the code. Unfortunately, I can't pass this line:

false_predictions = query_for_false_predictions(y_hat, y_new_test)

which gives the following error:


Traceback (most recent call last):
  File "/Users/navid/Google Drive/PhD/Repositories/XAI-2016/py/rule_lists_titanic_dataset.py", line 228, in <module>
    false_predictions = query_for_false_predictions(y_hat, y_new_test)
  File "/Users/navid/Google Drive/PhD/Repositories/XAI-2016/py/rule_lists_titanic_dataset.py", line 223, in <lambda>
    query_for_false_predictions = lambda predictions, ground_truth:  np.where(ground_truth != predictions)
  File "/Users/navid/opt/anaconda3/envs/skater-test/lib/python3.6/site-packages/pandas/core/ops/__init__.py", line 1207, in wrapper
    raise ValueError("Lengths must match to compare")
ValueError: Lengths must match to compare

The reason is that y_hat has a wrong shape, which is coming from : _, y_hat = sbrl_inst.predict(new_X_test)

The new_X_test is correct, a DataFrame with [143 rows x 10 columns]. The problem is that sbrl_inst.predict is returning a wrong shape [2 x 1] instead of [143 x 1] . I tried to follow the predict function but to make predictions it's using sbrl R library and that's as far as I could get. Any suggestion?

Naviden avatar Jan 23 '20 13:01 Naviden