{"id":44336664,"url":"https://github.com/adimajo/lrtree","last_synced_at":"2026-02-11T11:36:32.549Z","repository":{"id":47793791,"uuid":"477784248","full_name":"adimajo/lrtree","owner":"adimajo","description":"Logistic regression trees","archived":false,"fork":false,"pushed_at":"2023-09-14T13:15:21.000Z","size":3387,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-25T04:41:25.432Z","etag":null,"topics":["decision-trees","logistic","regression","tree"],"latest_commit_sha":null,"homepage":"https://adimajo.github.io/lrtree/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adimajo.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}},"created_at":"2022-04-04T16:30:11.000Z","updated_at":"2024-04-25T13:45:50.000Z","dependencies_parsed_at":"2023-02-15T10:16:42.031Z","dependency_job_id":null,"html_url":"https://github.com/adimajo/lrtree","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adimajo/lrtree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adimajo%2Flrtree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adimajo%2Flrtree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adimajo%2Flrtree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adimajo%2Flrtree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adimajo","download_url":"https://codeload.github.com/adimajo/lrtree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adimajo%2Flrtree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29332641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T06:13:03.264Z","status":"ssl_error","status_checked_at":"2026-02-11T06:12:55.843Z","response_time":97,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["decision-trees","logistic","regression","tree"],"created_at":"2026-02-11T11:36:31.978Z","updated_at":"2026-02-11T11:36:32.544Z","avatar_url":"https://github.com/adimajo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![PyPI version](https://badge.fury.io/py/lrtree.svg)](https://badge.fury.io/py/lrtree)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/lrtree.svg)](https://pypi.python.org/pypi/lrtree/)\n[![PyPi Downloads](https://img.shields.io/pypi/dm/lrtree)](https://img.shields.io/pypi/dm/lrtree)\n[![Build Status](https://app.travis-ci.com/adimajo/lrtree.svg?branch=master)](https://app.travis-ci.com/adimajo/lrtree)\n![Python package](https://github.com/adimajo/lrtree/workflows/Python%20package/badge.svg)\n[![codecov](https://codecov.io/gh/adimajo/lrtree/branch/master/graph/badge.svg)](https://codecov.io/gh/adimajo/lrtree)\n\n# Logistic regression trees\n\nTable of Contents\n-----------------\n\n* [Documentation](https://adimajo.github.io/lrtree)\n* [Installation instructions](#-installing-the-package)\n* [Theory](https://adimajo.github.io/logistic_trees.html)\n* [Some examples](#-utilization)\n* [Open an issue](https://github.com/adimajo/lrtree/issues/new/choose)\n* [References](#-references)\n* [Contribute](#-contribute)\n\n## Motivation\n\nThe goal of `lrtree` is to build decision trees with logistic regressions at their leaves, so that the resulting model mixes non parametric VS parametric and stepwise VS linear approaches to have the best predictive results, yet maintaining interpretability.\n\nThis is the implementation of glmtree as described in *Formalization and study of statistical problems in Credit Scoring*, Ehrhardt A. (see [manuscript](https://github.com/adimajo/manuscrit_these) or [web article](https://adimajo.github.io/logistic_trees.html))\n\n## Getting started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes.\n\n### Prerequisites\n\nThis code is supported on Python 3.8, 3.9, 3.10.\n\n### Installing the package\n\n#### Installing the development version\n\nIf `git` is installed on your machine, you can use:\n\n```PowerShell\npipenv install git+https://github.com/adimajo/lrtree.git\n```\n\nIf `git` is not installed, you can also use:\n\n```PowerShell\npipenv install --upgrade https://github.com/adimajo/lrtree/archive/master.tar.gz\n```\n\n#### Installing through the `pip` command\n\nYou can install a stable version from [PyPi](https://pypi.org/project/lrtree/) by using:\n\n```PowerShell\npip install lrtree\n```\n\nTo run the provided scripts, `lrtree-consistency` and `lrtree-realdata`, you need a \nfew additional dependencies:\n```PowerShell\npip install lrtree[scripts]\n```\n\n#### Installation guide for Anaconda\n\nThe installation with the `pip` or `pipenv` command **should** work. If not, please raise an issue.\n\n#### For people behind proxy(ies)...\n\nA lot of people, including myself, work behind a proxy at work...\n\nA simple solution to get the package is to use the `--proxy` option of `pip`:\n\n```PowerShell\npip --proxy=http://username:password@server:port install lrtree\n```\n\nwhere *username*, *password*, *server* and *port* should be replaced by your own values.\n\nIf environment variables `http_proxy` and / or `https_proxy` and / or (unfortunately depending on applications...) \n`HTTP_PROXY` and `HTTPS_PROXY` are set, the proxy settings should be picked up by `pip`.\n\nOver the years, I've found [CNTLM](http://cntlm.sourceforge.net/) to be a great tool in this regard.\n\n## Authors\n\n* [Adrien Ehrhardt](https://adimajo.github.io)\n* [Vincent Vandewalle](https://sites.google.com/site/vvandewa/)\n* [Philippe Heinrich](http://math.univ-lille1.fr/~heinrich/)\n* [Christophe Biernacki](http://math.univ-lille1.fr/~biernack/)\n* Dmitri Gaynullin\n* Elise Bayraktar\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Acknowledgments\n\nThis research has been financed by [Crédit Agricole Consumer Finance](https://www.ca-consumerfinance.com/en.html) through a CIFRE PhD.\n\nThis research was supported by [Inria Lille - Nord-Europe](https://www.inria.fr/centre/lille) and [Lille University](https://www.univ-lille.fr/en/home/) as part of a PhD.\n\n## References\n\nEhrhardt, A. (2019), [Formalization and study of statistical problems in Credit Scoring: Reject inference, discretization and pairwise interactions, logistic regression trees](https://hal.archives-ouvertes.fr/tel-02302691) ([PhD thesis](https://github.com/adimajo/manuscrit_these)).\n\n## Contribute\n\nYou can clone this project using:\n\n```PowerShell\ngit clone https://github.com/adimajo/lrtree.git\n```\n\nYou can install all dependencies, including development dependencies, using (note that \nthis command requires `pipenv` which can be installed by typing `pip install pipenv`):\n\n```PowerShell\npipenv install -d\n```\n\nYou can build the documentation by going into the `docs` directory and typing `make html`.\n\nYou can run the tests by typing `coverage run -m pytest`, which relies on packages \n[coverage](https://coverage.readthedocs.io/en/coverage-5.2/) and [pytest](https://docs.pytest.org/en/latest/).\n\nTo run the tests in different environments (one for each version of Python), install `pyenv` (see [the instructions here](https://github.com/pyenv/pyenv)),\ninstall all versions you want to test (see [tox.ini](tox.ini)), e.g. with `pyenv install 3.7.0` and run \n`pipenv run pyenv local 3.7.0 [...]` (and all other versions) followed by `pipenv run tox`.\n \n## Python Environment \nThe project uses `pipenv`. [An interesting resource](https://realpython.com/pipenv-guide/).\n\nTo download all the project dependencies in order to then port them to a machine that had limited access to the internet, you must use the command\n`pipenv lock -r \u003e requirements.txt` which will transform the `Pipfile` into a `requirements.txt`.\n\n## Installation\nTo install a virtual environment as well as all the necessary dependencies, you must use the `pipenv install` command for production use \nor the command `pipenv install -d` for development use.\n\n## Tests\n\nThe tests are based on `pytest` and are stored in the `tests` folder. They can all be launched with the command\n`pytest` in at the root of the project.\nThe test coverage can be calculated thanks to the `coverage` package, which is also responsible for launching the tests. \nThe command to use is `coverage run -m pytest`. We can then obtain a graphic summary in the form of an HTML page \nusing the `coverage html` command which creates or updates the `htmlcov` folder from which we can open the `index.html` file.\n\n## Utilization\nThe package provides [sklearn-like](https://scikit-learn.org/stable) interface.\n\nLoading [sample data](https://scikit-learn.org/stable/modules/generated/sklearn.datasets.load_boston.html) for regression task:\n\n```python\nfrom sklearn.datasets import load_boston\nfrom sklearn.model_selection import train_test_split\n\nX, y = load_boston(return_X_y=True)\nX_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25)\n```\n\nThe trained model consists of a fitted `sklearn.tree.DecisionTreeClassifier` class for segmentation of a data and\n`sklearn.linear_model.LogisticRegression` regressions for each node a of a tree in a form of python list.\n\nThe snippet to train the model and make a prediction:\n```python\nfrom lrtree import Lrtree\n\nmodel = Lrtree(criterion=\"bic\", ratios=(0.7,), class_num=2, max_iter=100)\n\n# Fitting the model\nmodel.fit(X_train, y_train)\n\n# Make a prediction on a fitted model\nmodel.predict(X_test)\n```\n\nIf you installed the additional dependencies for scripts, you can also run directly from the command line:\n```PowerShell\nLOGURU_LEVEL=\"ERROR\" DEBUG=\"True\" lrtree-consistency\n```\n\nor\n```PowerShell\nLOGURU_LEVEL=\"ERROR\" TQDM_DISABLE=\"1\" lrtree-realdata\n```\n\nBeware: if you don't set `LOGURU_LEVEL` then it is implicitly set on DEBUG\nwhich will yield a lot of prints. Also, both scripts will take very long\nto complete as they test the consistency of the method for various \nhyperparameters and run cross-validation on 3 real datasets respectively.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadimajo%2Flrtree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadimajo%2Flrtree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadimajo%2Flrtree/lists"}