{"id":13486974,"url":"https://github.com/tmadl/sklearn-expertsys","last_synced_at":"2025-03-27T21:31:43.872Z","repository":{"id":71328378,"uuid":"52333038","full_name":"tmadl/sklearn-expertsys","owner":"tmadl","description":"Highly interpretable classifiers for scikit learn, producing easily understood decision rules instead of black box models","archived":false,"fork":false,"pushed_at":"2017-08-11T09:05:04.000Z","size":81,"stargazers_count":485,"open_issues_count":5,"forks_count":73,"subscribers_count":22,"default_branch":"master","last_synced_at":"2024-08-01T18:28:19.829Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmadl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-02-23T05:31:06.000Z","updated_at":"2024-06-25T13:50:19.000Z","dependencies_parsed_at":null,"dependency_job_id":"a8a5104b-44aa-47cb-bb31-ed21ceda3028","html_url":"https://github.com/tmadl/sklearn-expertsys","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmadl%2Fsklearn-expertsys","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmadl%2Fsklearn-expertsys/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmadl%2Fsklearn-expertsys/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmadl%2Fsklearn-expertsys/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmadl","download_url":"https://codeload.github.com/tmadl/sklearn-expertsys/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222321727,"owners_count":16966432,"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-07-31T18:00:53.954Z","updated_at":"2024-10-30T22:30:21.237Z","avatar_url":"https://github.com/tmadl.png","language":"Python","funding_links":[],"categories":["The Data Science Toolbox","Python","Machine Learning","Table of Contents","Technical Resources"],"sub_categories":["General Machine Learning Packages","General Purpose Machine Learning","Python packages","Automatic Plotting","Open Source/Access Responsible AI Software Packages"],"readme":"Highly interpretable, sklearn-compatible classifier based on decision rules\n===============\n\nThis is a scikit-learn compatible wrapper for the Bayesian Rule List classifier developed by [Letham et al., 2015](http://projecteuclid.org/euclid.aoas/1446488742) (see [Letham's original code](http://lethalletham.com/)), extended by a minimum description length-based discretizer ([Fayyad \u0026 Irani, 1993](http://sci2s.ugr.es/keel/pdf/algorithm/congreso/fayyad1993.pdf)) for continuous data, and by an approach to subsample large datasets for better performance.\n\nIt produces rule lists, which makes trained classifiers **easily interpretable to human experts**, and is competitive with state of the art classifiers such as random forests or SVMs.\n\nFor example, an easily understood Rule List model of the well-known Titanic dataset:\n\n```\nIF male AND adult THEN survival probability: 21% (19% - 23%)\nELSE IF 3rd class THEN survival probability: 44% (38% - 51%)\nELSE IF 1st class THEN survival probability: 96% (92% - 99%)\nELSE survival probability: 88% (82% - 94%)\n``` \n\nLetham et al.'s approach only works on discrete data. However, this approach can still be used on continuous data after discretization. The RuleListClassifier class also includes a discretizer that can deal with continuous data (using [Fayyad \u0026 Irani's](http://sci2s.ugr.es/keel/pdf/algorithm/congreso/fayyad1993.pdf) minimum description length principle criterion, based on an implementation by [navicto](https://github.com/navicto/Discretization-MDLPC)).\n\nThe inference procedure is slow on large datasets. If you have more than a few thousand data points, and only numeric data, try the included `BigDataRuleListClassifier(training_subset=0.1)`, which first determines a small subset of the training data that is most critical in defining a decision boundary (the data points that are hardest to classify) and learns a rule list only on this subset (you can specify which estimator to use for judging which subset is hardest to classify by passing any sklearn-compatible estimator in the `subset_estimator` parameter - see `examples/diabetes_bigdata_demo.py`). \n\nUsage\n===============\n\nThe project requires [pyFIM](http://www.borgelt.net/pyfim.html), [scikit-learn](http://scikit-learn.org/stable/install.html), and [pandas](http://pandas.pydata.org/) to run.\n\nThe included `RuleListClassifier` works as a scikit-learn estimator, with a `model.fit(X,y)` method which takes training data `X` (numpy array or pandas DataFrame; continuous, categorical or mixed data) and labels `y`. \n\nThe learned rules of a trained model can be displayed simply by casting the object as a string, e.g. `print model`, or by using the `model.tostring(decimals=1)` method and optionally specifying the rounding precision.\n\nNumerical data in `X` is automatically discretized. To prevent discretization (e.g. to protect columns containing categorical data represented as integers), pass the list of protected column names in the `fit` method, e.g. `model.fit(X,y,undiscretized_features=['CAT_COLUMN_NAME'])` (entries in undiscretized columns will be converted to strings and used as categorical values - see `examples/hepatitis_mixeddata_demo.py`). \n\nUsage example:\n\n```python\nfrom RuleListClassifier import *\nfrom sklearn.datasets.mldata import fetch_mldata\nfrom sklearn.cross_validation import train_test_split\nfrom sklearn.ensemble import RandomForestClassifier\n\nfeature_labels = [\"#Pregnant\",\"Glucose concentration test\",\"Blood pressure(mmHg)\",\"Triceps skin fold thickness(mm)\",\"2-Hour serum insulin (mu U/ml)\",\"Body mass index\",\"Diabetes pedigree function\",\"Age (years)\"]\n    \ndata = fetch_mldata(\"diabetes\") # get dataset\ny = (data.target+1)/2 # target labels (0 or 1)\nXtrain, Xtest, ytrain, ytest = train_test_split(data.data, y) # split\n\n# train classifier (allow more iterations for better accuracy; use BigDataRuleListClassifier for large datasets)\nmodel = RuleListClassifier(max_iter=10000, class1label=\"diabetes\", verbose=False)\nmodel.fit(Xtrain, ytrain, feature_labels=feature_labels)\n\nprint \"RuleListClassifier Accuracy:\", model.score(Xtest, ytest), \"Learned interpretable model:\\n\", model\nprint \"RandomForestClassifier Accuracy:\", RandomForestClassifier().fit(Xtrain, ytrain).score(Xtest, ytest)\n\"\"\"\n**Output:**\nRuleListClassifier Accuracy: 0.776041666667 Learned interpretable model:\nTrained RuleListClassifier for detecting diabetes\n==================================================\nIF Glucose concentration test : 157.5_to_inf THEN probability of diabetes: 81.1% (72.5%-72.5%)\nELSE IF Body mass index : -inf_to_26.3499995 THEN probability of diabetes: 5.2% (1.9%-1.9%)\nELSE IF Glucose concentration test : -inf_to_103.5 THEN probability of diabetes: 14.4% (8.8%-8.8%)\nELSE IF Age (years) : 27.5_to_inf THEN probability of diabetes: 59.6% (51.8%-51.8%)\nELSE IF Glucose concentration test : 103.5_to_127.5 THEN probability of diabetes: 15.9% (8.0%-8.0%)\nELSE probability of diabetes: 44.7% (29.5%-29.5%)\n=================================================\n\nRandomForestClassifier Accuracy: 0.729166666667\n\"\"\"\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmadl%2Fsklearn-expertsys","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmadl%2Fsklearn-expertsys","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmadl%2Fsklearn-expertsys/lists"}