scikit-learn-compatible estimators from Civis Analytics
Project description
scikit-learn-compatible estimators from Civis Analytics
Installation
Installation with pip is recommended:
$ pip install civisml-extensions
For development, a few additional dependencies are needed:
$ pip install -r dev-requirements.txt
Contents and Usage
This package contains scikit-learn-compatible estimators for stacking ( StackedClassifier, StackedRegressor), non-negative linear regression ( NonNegativeLinearRegression), preprocessing pandas DataFrames ( DataFrameETL), and using Hyperband for cross-validating hyperparameters ( HyperbandSearchCV).
Usage of these estimators follows the standard sklearn conventions. Here is an example of using the StackedClassifier:
>>> from sklearn.linear_model import LogisticRegression >>> from sklearn.ensemble import RandomForestClassifier >>> from civismlext.stacking import StackedClassifier >>> >>> # Define some Train data and labels >>> Xtrain, ytrain = <train_features>, <train_labels> >>> >>> # Note that the final estimator 'metalr' is the meta-estimator >>> estlist = [('rf', RandomForestClassifier()), >>> ('lr', LogisticRegression()), >>> ('metalr', LogisticRegression())] >>> >>> mysm = StackedClassifier(estlist) >>> # Set some parameters, if you didn't set them at instantiation >>> mysm.set_params(rf__random_state=7, lr__random_state=8, >>> metalr__random_state=9, metalr__C=10**7) >>> >>> # Fit >>> mysm.fit(Xtrain, ytrain) >>> >>> # Predict! >>> ypred = mysm.predict_proba(Xtest)
You can learn more about stacking and see an example use of the StackedRegressor and NonNegativeLinearRegression estimators in a talk presented at PyData NYC in November, 2017.
See the doc strings of the various estimators for more information.
Contributing
Please see CONTRIBUTING.md for information about contributing to this project.
License
BSD-3
See LICENSE.md for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file civisml-extensions-0.3.1.tar.gz
.
File metadata
- Download URL: civisml-extensions-0.3.1.tar.gz
- Upload date:
- Size: 37.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29ad3b853cc43551dc9bbad22f83ce387ca602b20200251fea90d7c6eda53e6 |
|
MD5 | fc50acee162ae463743543c62bcfb193 |
|
BLAKE2b-256 | 66c00bae3015c5a38298bc8dfff4fb21f94dd2dd8af5962a169e0636d9f62198 |
File details
Details for the file civisml_extensions-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: civisml_extensions-0.3.1-py3-none-any.whl
- Upload date:
- Size: 39.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f4d9cb0c8ec2ed4dbeb47950b4cdd2db197089c4520d909d2ecea98ef8c4d36 |
|
MD5 | 770245200e6c345f159c96e68cd45d70 |
|
BLAKE2b-256 | 8bb488a589ec894ea27f7506de580df1f0fe3c8d2b634547bbbd3cd691d8eb60 |