csinva / imodels

Interpretable ML package 🔍 for concise, transparent, and accurate predictive modeling (sklearn-compatible).
https://csinva.io/imodels
MIT License
1.4k stars 124 forks source link

Importing "HSTreeRegressor" gets ImportError #207

Closed 3mMv closed 4 weeks ago

3mMv commented 5 months ago

I'm using matplotlib==3.8.4 scikit-learn==1.4.0 numpy==1.26.0. When I'm trying to import HSTreeRegressor I get a ImportError:

[/usr/local/lib/python3.10/dist-packages/imodels/util/score.py](https://localhost:8080/#) in <module>
      4 import pandas as pd
      5 import numpy as np
----> 6 from sklearn.utils._mask import indices_to_mask
      7 from sklearn.linear_model import Lasso, LogisticRegression
      8 from sklearn.linear_model._coordinate_descent import _alpha_grid

ImportError: cannot import name 'indices_to_mask' from 'sklearn.utils._mask' (/usr/local/lib/python3.10/dist-packages/sklearn/utils/_mask.py)

But if I delete the line from sklearn.utils._mask import indices_to_mask from the score.py I solve the problem. I am not an expert in machine learning and coding, so I not sure what indices_to_mask does in the code.

csinva commented 5 months ago

Sorry about this, sklearn moved indices_to_mask in a recent version so the best current solution for this is just upgrading sklearn with pip install --upgrade scikit-learn. We will find a fix for this function in the meantime...

csinva commented 4 weeks ago

Fixed this in the recent version, let us know if you continue to have any trouble!