Trusted-AI / Trusted-AI/AIX360

Suggestion to improve GLRM sklearn compability

Open
#63 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.8k
Forks
327
Avg merge
1h 13m
Merged PRs (30d)
1

Description

Hello, I'm trying to use the GLRM LogisticRuleRegression and it seems to be compatible with my own code for training/evaluation with sklearn models. However, it fails when I use functions like GridSearchCV for hyperparameter tuning.

TypeError: Cannot clone object '<aix360.algorithms.rbm.logistic_regression.LogisticRuleRegression object at 0x10f731310>' (type <class 'aix360.algorithms.rbm.logistic_regression.LogisticRuleRegression'>): it does not seem to be a scikit-learn estimator as it does not implement a 'get_params' methods. (py37) Jamess-MacBook-Pro-2:sk

If the class inherits from BaseEstimator and ClassifierMixin from sklearn.base instead of just object, then it will inherit get_params() and this will resolve the issue. I've tested this on my local machine. So the change should be:

class LogisticRuleRegression(object):
to
class LogisticRuleRegression(BaseEstimator, ClassifierMixin):

This can also be applied to LinearRuleRegression (replacing ClassifierMixin with RegressorMixin) and any other similar classes and may resolve other sklearn compatability issues I haven't come across yet (e.g. Pipeline may be affected as well)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the LogisticRuleRegression and LinearRuleRegression class definitions and reviewing how they are initialized and used with scikit-learn. Verify compatibility with GridSearchCV and Pipeline, then add or update tests showing that the estimators can be cloned and used for hyperparameter tuning.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, scikit-learn
Domain
machine-learning, testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.