README.md 6.6 KB
Newer Older
P
pycaret 已提交
1 2
## PyCaret
PyCaret is end-to-end open source machine learning library for python programming language. Its primary objective is to reduce the cycle time of hypothesis to insights by providing an easy to use high level unified API. PyCaret's vision is to become defacto standard for teaching machine learning and data science. Our strength is in our easy to use unified interface for both supervised and unsupervised learning. It saves time and effort that citizen data scientists, students and researchers spent on coding or learning to code using different interfaces, so that now they can focus on business problem.
P
pycaret 已提交
3

P
pycaret 已提交
4
## Current Release
P
pycaret 已提交
5
The current release is beta 0.0.21 (as of 23/01/2020). A full release is targetted in the first week of February 2020.
P
pycaret 已提交
6 7

## Features Currently Available
P
pycaret 已提交
8
As per beta 0.0.21 following modules are generally available:
P
pycaret 已提交
9
* pycaret.datasets <br/>
P
pycaret 已提交
10
* pycaret.classification (binary and multiclass) <br/>
P
pycaret 已提交
11 12 13 14 15
* pycaret.regression <br/>
* pycaret.nlp <br/>
* pycaret.arules <br/>
* pycaret.anamoly <br/>
* pycaret.clustering <br/>
P
pycaret 已提交
16
* pycaret.preprocess <br/>
P
pycaret 已提交
17 18

## Future Release
P
pycaret 已提交
19
Full public release is targetted to be released in first week of Feb 2020.
P
pycaret 已提交
20

P
pycaret 已提交
21 22 23 24 25 26 27
## Installation

#### Dependencies
Please read requirements.txt for list of requirements. They are automatically installed when pycaret is installed using pip.

#### User Installation
The easiest way to install pycaret is using pip.
P
pycaret 已提交
28

P
pycaret 已提交
29 30
```python
pip install pycaret
P
pycaret 已提交
31
```
P
pycaret 已提交
32 33

## Quick Start
P
pycaret 已提交
34
As of beta 0.0.21 classification, regression, nlp, arules, anomaly and clustering modules are available.
P
pycaret 已提交
35

P
pycaret 已提交
36
### Classification / Regression
P
pycaret 已提交
37 38 39 40 41

Getting data from pycaret repository

```python
from pycaret.datasets import get_data
P
pycaret 已提交
42
juice = get_data('juice') #classification dataset
P
pycaret 已提交
43 44
```

P
pycaret 已提交
45
1. Initializing the pycaret environment setup
P
pycaret 已提交
46 47

```python
P
pycaret 已提交
48 49
from pycaret.classification import * #for classification
from pycaret.regression import * #for regression
P
pycaret 已提交
50 51 52
exp1 = setup(juice, 'Purchase')
```

P
pycaret 已提交
53
2. Creating a simple logistic regression (includes fitting, CV and metric evaluation)
P
pycaret 已提交
54 55 56 57 58 59
```python
lr = create_model('lr')
```

List of available estimators:

P
pycaret 已提交
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
Logistic Regression (lr) <br/>
K Nearest Neighbour (knn) <br/>
Naive Bayes (nb) <br/>
Decision Tree (dt) <br/>
Support Vector Machine - Linear (svm) <br/>
SVM Radial Function (rbfsvm) <br/>
Gaussian Process Classifier (gpc) <br/>
Multi Level Perceptron (mlp) <br/>
Ridge Classifier (ridge) <br/>
Random Forest (rf) <br/>
Quadtratic Discriminant Analysis (qda) <br/>
Adaboost (ada) <br/>
Gradient Boosting Classifier (gbc) <br/>
Linear Discriminant Analysis (lda) <br/>
Extra Trees Classifier (et) <br/>
Extreme Gradient Boosting - xgboost (xgboost) <br/>
Light Gradient Boosting - Microsoft LightGBM (lightgbm) <br/>
P
pycaret 已提交
77

P
pycaret 已提交
78 79 80 81 82 83
3. Compare all models at once
```python
compare_models()
```

4. Tuning a model using pre-built search grids.
P
pycaret 已提交
84
```python
P
pycaret 已提交
85
tuned_xgb = tune_model('xgboost')
P
pycaret 已提交
86 87
```

P
pycaret 已提交
88
4. Ensembling Model
P
pycaret 已提交
89
```python
P
pycaret 已提交
90 91 92
dt = create_model('dt')
dt_bagging = ensemble_model(dt, method='Bagging')
dt_boosting = ensemble_model(dt, method='Boosting')
P
pycaret 已提交
93 94
```

P
pycaret 已提交
95
5. Creating a voting classifier
P
pycaret 已提交
96
```python
P
pycaret 已提交
97
voting_all = blend_models() #creates voting classifier for entire library
P
pycaret 已提交
98 99 100 101 102 103 104

#create voting classifier for specific models
lr = create_model('lr')
svm = create_model('svm')
mlp = create_model('mlp')
xgboost = create_model('xgboost')

P
pycaret 已提交
105
voting_clf2 = blend_models( [ lr, svm, mlp, xgboost ] )
P
pycaret 已提交
106 107
```

P
pycaret 已提交
108
6. Stacking Models in Single Layer
P
pycaret 已提交
109 110 111 112 113 114 115 116 117 118
```python
#create individual classifiers
lr = create_model('lr')
svm = create_model('svm')
mlp = create_model('mlp')
xgboost = create_model('xgboost')

stacker = stack_models( [lr,svm,mlp], meta_model = xgboost )
```

P
pycaret 已提交
119
7. Stacking Models in Multiple Layers
P
pycaret 已提交
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
```python
#create individual classifiers
lr = create_model('lr')
svm = create_model('svm')
mlp = create_model('mlp')
gbc = create_model('gbc')
nb = create_model('nb')
lightgbm = create_model('lightgbm')
knn = create_model('knn')
xgboost = create_model('xgboost')

stacknet = create_stacknet( [ [lr,svm,mlp], [gbc, nb], [lightgbm, knn] ], meta_model = xgboost )
#meta model by default is Logistic Regression
```

P
pycaret 已提交
135
8. Plot Models
P
pycaret 已提交
136 137 138 139 140 141
```python
lr = create_model('lr')
plot_model(lr, plot='auc')
```
List of available plots:

P
pycaret 已提交
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
Area Under the Curve (auc) <br/>
Discrimination Threshold (threshold) <br/>
Precision Recall Curve (pr) <br/>
Confusion Matrix (confusion_matrix) <br/>
Class Prediction Error (error) <br/>
Classification Report (class_report) <br/>
Decision Boundary (boundary) <br/>
Recursive Feature Selection (rfe) <br/>
Learning Curve (learning) <br/>
Manifold Learning (manifold) <br/>
Calibration Curve (calibration) <br/>
Validation Curve (vc) <br/>
Dimension Learning (dimension) <br/>
Feature Importance (feature) <br/>
Model Hyperparameter (parameter) <br/>
P
pycaret 已提交
157 158 159 160 161 162 163 164 165 166 167 168 169 170

9. Evaluate Model
```python
lr = create_model('lr')
evaluate_model(lr) #displays user interface for interactive plotting
```

10. Interpret Tree Based Models
```python
xgboost = create_model('xgboost')
interpret_model(xgboost)
```

11. Saving Model for Deployment
P
pycaret 已提交
171 172 173 174
```python
lr = create_model('lr')
save_model(lr, 'lr_23122019')
```
P
pycaret 已提交
175 176

12. Saving Entire Experiment Pipeline
P
pycaret 已提交
177 178 179
```python
save_experiment('expname1')
```
P
pycaret 已提交
180 181

13. Loading Model / Experiment
P
pycaret 已提交
182 183 184 185
```python
m = load_model('lr_23122019')
e = load_experiment('expname1')
```
P
pycaret 已提交
186 187


P
pycaret 已提交
188
## Getting Started Tutorials
P
pycaret 已提交
189
Tutorials are work in progress. Will be uploaded on our git page by 25/01/2020.
P
pycaret 已提交
190

P
pycaret 已提交
191
## Documentation
P
pycaret 已提交
192
Documentation work is in progress. They will be uploaded on our website http://www.pycaret.org as soon as they are available. (Target Availability : 21/01/2020)
P
pycaret 已提交
193 194 195

## Contributions
Contributions are most welcome. To make contribution please reach out moez.ali@queensu.ca
P
pycaret 已提交
196 197 198

## License

P
pycaret 已提交
199
Copyright 2019-2020 Moez Ali <moez.ali@queensu.ca>
P
pycaret 已提交
200 201 202 203 204 205

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
P
pycaret 已提交
206
© 2020 GitHub, Inc.