{"id":13652345,"url":"https://github.com/scikit-learn-contrib/skope-rules","last_synced_at":"2025-05-15T10:03:18.804Z","repository":{"id":40725323,"uuid":"121955511","full_name":"scikit-learn-contrib/skope-rules","owner":"scikit-learn-contrib","description":"machine learning with logical rules in Python","archived":false,"fork":false,"pushed_at":"2024-01-31T14:01:51.000Z","size":5892,"stargazers_count":633,"open_issues_count":36,"forks_count":101,"subscribers_count":25,"default_branch":"master","last_synced_at":"2025-04-14T16:53:57.917Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://skope-rules.readthedocs.io","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scikit-learn-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-18T13:42:47.000Z","updated_at":"2025-04-09T13:28:47.000Z","dependencies_parsed_at":"2024-06-18T13:45:17.650Z","dependency_job_id":"31ab22e7-c636-4e35-a603-d73f081324ce","html_url":"https://github.com/scikit-learn-contrib/skope-rules","commit_stats":{"total_commits":194,"total_committers":16,"mean_commits":12.125,"dds":0.5567010309278351,"last_synced_commit":"35553e98558c728e063c4d4dab3941ce8f6e3609"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scikit-learn-contrib%2Fskope-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scikit-learn-contrib%2Fskope-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scikit-learn-contrib%2Fskope-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scikit-learn-contrib%2Fskope-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scikit-learn-contrib","download_url":"https://codeload.github.com/scikit-learn-contrib/skope-rules/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254319716,"owners_count":22051072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T02:00:58.486Z","updated_at":"2025-05-15T10:03:12.841Z","avatar_url":"https://github.com/scikit-learn-contrib.png","language":"Jupyter Notebook","funding_links":[],"categories":["Interpretability / Explainable AI","Jupyter Notebook","Sklearn实用程序","Python Libraries(sort in alphabeta order)","Technical Resources"],"sub_categories":["Evaluation methods","Open Source/Access Responsible AI Software Packages"],"readme":".. -*- mode: rst -*-\n\n|Travis|_  |Coveralls|_ |CircleCI|_ |Python27|_ |Python35|_\n\n.. |Travis| image:: https://api.travis-ci.org/skope-rules/skope-rules.svg?branch=master\n.. _Travis: https://travis-ci.org/skope-rules/skope-rules\n\n.. |Coveralls| image:: https://coveralls.io/repos/github/skope-rules/skope-rules/badge.svg?branch=master\n.. _Coveralls: https://coveralls.io/github/skope-rules/skope-rules?branch=master\n\n.. |CircleCI| image:: https://circleci.com/gh/skope-rules/skope-rules/tree/master.svg?style=shield\u0026circle-token=:circle-token\n.. _CircleCI: https://circleci.com/gh/skope-rules/skope-rules\n\n.. |Python27| image:: https://img.shields.io/badge/python-2.7-blue.svg\n.. _Python27: https://badge.fury.io/py/skope-rules\n\n.. |Python35| image:: https://img.shields.io/badge/python-3.5-blue.svg\n.. _Python35: https://badge.fury.io/py/skope-rules\n\n.. image:: logo.png\n\nskope-rules\n===========\n\nSkope-rules is a Python machine learning module built on top of\nscikit-learn and distributed under the 3-Clause BSD license.\n\nSkope-rules aims at learning logical, interpretable rules for \"scoping\" a target\nclass, i.e. detecting with high precision instances of this class.\n\nSkope-rules is a trade off between the interpretability of a Decision Tree\nand the modelization power of a Random Forest.\n\nSee the `AUTHORS.rst \u003cAUTHORS.rst\u003e`_ file for a list of contributors.\n\n.. image:: schema.png\n\n\nInstallation\n------------\n\nYou can get the latest sources with pip :\n\n    pip install skope-rules\n\n   \nQuick Start\n------------\n\nSkopeRules can be used to describe classes with logical rules :\n\n.. code:: python\n\n    from sklearn.datasets import load_iris\n    from skrules import SkopeRules\n    \n    dataset = load_iris()\n    feature_names = ['sepal_length', 'sepal_width', 'petal_length', 'petal_width']\n    clf = SkopeRules(max_depth_duplication=2,\n                     n_estimators=30,\n                     precision_min=0.3,\n                     recall_min=0.1,\n                     feature_names=feature_names)\n    \n    for idx, species in enumerate(dataset.target_names):\n        X, y = dataset.data, dataset.target\n        clf.fit(X, y == idx)\n        rules = clf.rules_[0:3]\n        print(\"Rules for iris\", species)\n        for rule in rules:\n            print(rule)\n        print()\n        print(20*'=')\n        print()\n::\n\nSkopeRules can also be used as a predictor if you use the \"score_top_rules\" method :\n\n.. code:: python\n\n    from sklearn.datasets import load_boston\n    from sklearn.metrics import precision_recall_curve\n    from matplotlib import pyplot as plt\n    from skrules import SkopeRules\n    \n    dataset = load_boston()\n    clf = SkopeRules(max_depth_duplication=None,\n                     n_estimators=30,\n                     precision_min=0.2,\n                     recall_min=0.01,\n                     feature_names=dataset.feature_names)\n    \n    X, y = dataset.data, dataset.target \u003e 25\n    X_train, y_train = X[:len(y)//2], y[:len(y)//2]\n    X_test, y_test = X[len(y)//2:], y[len(y)//2:]\n    clf.fit(X_train, y_train)\n    y_score = clf.score_top_rules(X_test) # Get a risk score for each test example\n    precision, recall, _ = precision_recall_curve(y_test, y_score)\n    plt.plot(recall, precision)\n    plt.xlabel('Recall')\n    plt.ylabel('Precision')\n    plt.title('Precision Recall curve')\n    plt.show()\n::\n\n\nFor more examples and use cases please check our `documentation \u003chttp://skope-rules.readthedocs.io/en/latest/\u003e`_.\nYou can also check the `demonstration notebooks \u003cnotebooks/\u003e`_.\n\nLinks with existing literature\n-------------------------------\n\nThe main advantage of decision rules is that they are offering interpretable models. The problem of generating such rules has been widely considered in machine learning, see e.g. RuleFit [1], Slipper [2], LRI [3], MLRules[4].\n\nA decision rule is a logical expression of the form \"IF conditions THEN response\". In a binary classification setting, if an instance satisfies conditions of the rule, then it is assigned to one of the two classes. If this instance does not satisfy conditions, it remains unassigned.\n\n1) In [2, 3, 4], rules induction is done by considering each single decision rule as a base classifier in an ensemble, which is built by greedily minimizing some loss function.\n\n2) In [1], rules are extracted from an ensemble of trees; a weighted combination of these rules is then built by solving a L1-regularized optimization problem over the weights as described in [5].\n\nIn this package, we use the second approach. Rules are extracted from tree ensemble, which allow us to take advantage of existing fast algorithms (such as bagged decision trees, or gradient boosting) to produce such tree ensemble. Too similar or duplicated rules are then removed, based on a similarity threshold of their supports..\nThe main goal of this package is to provide rules verifying precision and recall conditions. It still implement a score (`decision_function`) method, but which does not solve the L1-regularized optimization problem as in [1]. Instead, weights are simply proportional to the OOB associated precision of the rule.\n\nThis package also offers convenient methods to compute predictions with the k most precise rules (cf score_top_rules() and predict_top_rules() functions).\n\n\n[1] Friedman and Popescu, Predictive learning via rule ensembles,Technical Report, 2005.\n\n[2] Cohen and Singer, A simple, fast, and effective rule learner, National Conference on Artificial Intelligence, 1999.\n\n[3] Weiss and Indurkhya, Lightweight rule induction, ICML, 2000.\n\n[4] Dembczyński, Kotłowski and Słowiński, Maximum Likelihood Rule Ensembles, ICML, 2008.\n\n[5] Friedman and Popescu, Gradient directed regularization, Technical Report, 2004.\n\nDependencies\n------------\n\nskope-rules requires:\n\n- Python (\u003e= 2.7 or \u003e= 3.3)\n- NumPy (\u003e= 1.10.4)\n- SciPy (\u003e= 0.17.0)\n- Pandas (\u003e= 0.18.1)\n- Scikit-Learn (\u003e= 0.17.1)\n\nFor running the examples Matplotlib \u003e= 1.1.1 is required.\n\n    \nDocumentation\n--------------\n\nYou can access the full project documentation `here \u003chttp://skope-rules.readthedocs.io/en/latest/\u003e`_\n\n\nYou can also check the notebooks/ folder which contains some examples of utilization.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscikit-learn-contrib%2Fskope-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscikit-learn-contrib%2Fskope-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscikit-learn-contrib%2Fskope-rules/lists"}