{"id":13487038,"url":"https://github.com/christophM/rulefit","last_synced_at":"2025-03-27T21:31:47.994Z","repository":{"id":40685886,"uuid":"44395554","full_name":"christophM/rulefit","owner":"christophM","description":"Python implementation of the rulefit algorithm","archived":false,"fork":false,"pushed_at":"2023-10-08T11:50:48.000Z","size":116,"stargazers_count":419,"open_issues_count":28,"forks_count":113,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-27T07:46:48.159Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christophM.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2015-10-16T15:56:52.000Z","updated_at":"2025-03-23T16:35:15.000Z","dependencies_parsed_at":"2023-02-15T06:30:55.872Z","dependency_job_id":"9a5e8277-cea0-4c94-8ea3-4a1e371d6fb7","html_url":"https://github.com/christophM/rulefit","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophM%2Frulefit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophM%2Frulefit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophM%2Frulefit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christophM%2Frulefit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christophM","download_url":"https://codeload.github.com/christophM/rulefit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245927288,"owners_count":20695205,"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:54.661Z","updated_at":"2025-03-27T21:31:47.620Z","avatar_url":"https://github.com/christophM.png","language":"Python","funding_links":[],"categories":["The Data Science Toolbox","Machine Learning","Python Libraries(sort in alphabeta order)"],"sub_categories":["General Machine Learning Packages","General Purpose Machine Learning","Automatic Plotting","Evaluation methods"],"readme":"\n! This package is no longer actively maintained. If you are interested in maintaining this package, please feel free to reach out to me via Github issue !\n\n# RuleFit\nImplementation of a rule based prediction algorithm based on [the rulefit algorithm from Friedman and Popescu (PDF)](http://statweb.stanford.edu/~jhf/ftp/RuleFit.pdf)\n\nThe algorithm can be used for predicting an output vector y given an input matrix X. In the first\nstep a tree ensemble is generated with gradient boosting. The trees are then used to form\nrules, where the paths to each node in each tree form one rule. A rule is a binary decision if\nan observation is in a given node, which is dependent on the input features that were used\nin the splits. The ensemble of rules together with the original input features are then being input\n in a L1-regularized linear model, also called Lasso, which estimates the effects of each rule on\nthe output target but at the same time estimating many of those effects to zero.\n\nYou can use rulefit for predicting a numeric response (categorial not yet implemented).\nThe input has to be a numpy matrix with only numeric values.\n\n## Installation\n\nThe latest version can be installed from the master branch using pip:\n\n```\npip install git+https://github.com/christophM/rulefit.git\n```\n\nAnother option is to clone the repository and install using `python setup.py install` or `python setup.py develop`.\n\n## Usage\n\n### Train your model:\n```python\nimport numpy as np\nimport pandas as pd\n\nfrom rulefit import RuleFit\n\nboston_data = pd.read_csv(\"boston.csv\", index_col=0)\n\ny = boston_data.medv.values\nX = boston_data.drop(\"medv\", axis=1)\nfeatures = X.columns\nX = X.as_matrix()\n\nrf = RuleFit()\nrf.fit(X, y, feature_names=features)\n\n```\n\nIf you want to have influence on the tree generator you can pass the generator as argument:\n\n```python\nfrom sklearn.ensemble import GradientBoostingRegressor\ngb = GradientBoostingRegressor(n_estimators=500, max_depth=10, learning_rate=0.01)\nrf = RuleFit(gb)\n\nrf.fit(X, y, feature_names=features)\n\n```\n\n### Predict\n\n```python\n\nrf.predict(X)\n\n```\n\n### Inspect rules:\n\n```python\nrules = rf.get_rules()\n\nrules = rules[rules.coef != 0].sort_values(\"support\", ascending=False)\n\nprint(rules)\n```\n\n## Notes\n- In contrast to the original paper, the generated trees are always fitted with the same maximum depth.\n  In the original implementation the maximum depth of the tree are drawn from a distribution each time\n- This implementation is in progress. If you find a bug, don't hesitate to contact me.\n\n## Changelog\nAll notable changes to this project will be documented here.\n\n### [v0.3] - IN PROGRESS\n- set default of exclude_zero_coef to False in get_rules(): \n- syntax fix (Issue 21)\n\n### [v0.2] - 2017-11-24\n- Introduces classification for RuleFit\n- Adds scaling of variables (Friedscale)\n- Allows random size trees for creating rules\n\n### [v0.1] - 2016-06-18\n- Start changelog and versions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FchristophM%2Frulefit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FchristophM%2Frulefit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FchristophM%2Frulefit/lists"}