# `AdaptoLogit` package
## Introduction
`AdaptoLogit` is a python package that proposes the implementation of adaptive lasso to solve logistic regression models.
## Dependencies
`AdaptoLogit` requires:
- Numpy >= 1.2
- SciPy >= 1.7.0
- Scikit-learn >= 1.0
## User installation
If you already have a working installation of numpy, scipy and scikit-learn, the easiest way to install **AdaptoLogit** is using pip:
```sh
pip install AdaptoLogit
```
## Usage Example
In the following example, the package is used to apply adaptive lasso logistic regression on simulated binary data. Cross validation is carried out to get the optimal subset of parameters for the data.
```py
from sklearn.model_selection import GridSearchCV
import numpy as np
import AdaptoLogit as al
from sklearn.datasets import make_classification
# Generate data
X, y = make_classification(random_state=8) # 100 samples, 20 features, 2 informative
# Estimate weights
weight = al.AdaptiveWeights(power_weight=(0.5,1,1.5))
weight.fit(X, y)
# Build model
model = al.AdaptiveLogistic()
# Cross validation for best subset of parameters
param_grid = {'C':[1e-3, 1e-2, 1e-1, 1, 10, 100, 1000], 'weight_array': weight.lasso_weights_,
'solver': ['saga','liblinear'], 'max_iter': [1000, 10000]}
grid_search = GridSearchCV(model, param_grid, cv=3, scoring='accuracy', n_jobs=8)
grid_search.fit(X, y)
final_model = grid_search.best_estimator_
# Model coefficients
print("Model coefficients ", final_model.coef_)
```
Raw data
{
"_id": null,
"home_page": "https://github.com/fernandezmaria/AdaptoLogit",
"name": "AdaptoLogit",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "adaptive-lasso,logistic-regression,weights",
"author": "Mar\u00eda Fernandez Mor\u00edn; \u00c1lvaro M\u00e9ndez Civieta; Rosa E. Lillo Rodriguez",
"author_email": "100483781@alumnos.uc3m.es",
"download_url": "https://files.pythonhosted.org/packages/38/17/239b6ac60a526a79c0a4c1263e2fa9dcffd569916efb0a5eeadafbf60938/AdaptoLogit-0.0.1.tar.gz",
"platform": null,
"description": "# `AdaptoLogit` package\r\n\r\n## Introduction\r\n`AdaptoLogit` is a python package that proposes the implementation of adaptive lasso to solve logistic regression models. \r\n\r\n## Dependencies\r\n`AdaptoLogit` requires:\r\n- Numpy >= 1.2\r\n- SciPy >= 1.7.0\r\n- Scikit-learn >= 1.0\r\n\r\n## User installation\r\nIf you already have a working installation of numpy, scipy and scikit-learn, the easiest way to install **AdaptoLogit** is using pip:\r\n\r\n```sh\r\npip install AdaptoLogit\r\n```\r\n\r\n## Usage Example\r\nIn the following example, the package is used to apply adaptive lasso logistic regression on simulated binary data. Cross validation is carried out to get the optimal subset of parameters for the data. \r\n```py\r\nfrom sklearn.model_selection import GridSearchCV\r\nimport numpy as np\r\nimport AdaptoLogit as al\r\nfrom sklearn.datasets import make_classification\r\n\r\n# Generate data\r\nX, y = make_classification(random_state=8) # 100 samples, 20 features, 2 informative\r\n\r\n# Estimate weights\r\nweight = al.AdaptiveWeights(power_weight=(0.5,1,1.5))\r\nweight.fit(X, y)\r\n\r\n# Build model \r\nmodel = al.AdaptiveLogistic()\r\n\r\n# Cross validation for best subset of parameters\r\nparam_grid = {'C':[1e-3, 1e-2, 1e-1, 1, 10, 100, 1000], 'weight_array': weight.lasso_weights_,\r\n 'solver': ['saga','liblinear'], 'max_iter': [1000, 10000]} \r\ngrid_search = GridSearchCV(model, param_grid, cv=3, scoring='accuracy', n_jobs=8)\r\ngrid_search.fit(X, y)\r\nfinal_model = grid_search.best_estimator_\r\n\r\n# Model coefficients\r\nprint(\"Model coefficients \", final_model.coef_)\r\n```\r\n\r\n\r\n",
"bugtrack_url": null,
"license": "GNU General Public License",
"summary": "A package implementing adaptive lasso for logistic regression",
"version": "0.0.1",
"project_urls": {
"Download": "https://github.com/fernandezmaria/AdaptoLogit/archive/0.0.1.tar.gz",
"Homepage": "https://github.com/fernandezmaria/AdaptoLogit"
},
"split_keywords": [
"adaptive-lasso",
"logistic-regression",
"weights"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3817239b6ac60a526a79c0a4c1263e2fa9dcffd569916efb0a5eeadafbf60938",
"md5": "4dd8c630f60cea577256b80a98b2b7bf",
"sha256": "0265f2796db3c00c10c79a3b2fe57a458524f36e34981f5c2c01e41803876fa1"
},
"downloads": -1,
"filename": "AdaptoLogit-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "4dd8c630f60cea577256b80a98b2b7bf",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 20029,
"upload_time": "2023-06-21T08:31:48",
"upload_time_iso_8601": "2023-06-21T08:31:48.943579Z",
"url": "https://files.pythonhosted.org/packages/38/17/239b6ac60a526a79c0a4c1263e2fa9dcffd569916efb0a5eeadafbf60938/AdaptoLogit-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-06-21 08:31:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fernandezmaria",
"github_project": "AdaptoLogit",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "adaptologit"
}