-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using quantile transformer example #1842
- Loading branch information
1 parent
0593078
commit 6e628f2
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 1,36 @@ | ||
# Using quantile transformer example | ||
|
||
```python | ||
from sklearn import preprocessing | ||
|
||
qt = preprocessing.QuantileTransformer(n_quantiles=3) | ||
data = [[1, 2], [3, 2], [4, 5]] | ||
qt.fit(data) | ||
|
||
transformed = qt.transform(data) | ||
``` | ||
|
||
- `from sklearn import` - import module from [lib:scikit-learn](https://onelinerhub.com/python-scikit-learn/how-to-install-scikit-learn-using-pip) | ||
- `.QuantileTransformer(` - creates [quantile transformer](https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.QuantileTransformer.html) model | ||
- `n_quantiles` - number of quantiles to be computed | ||
- `.fit(` - train transformation model | ||
- `.transform(` - transform original data and return transformed data | ||
|
||
## Example: | ||
```python | ||
from sklearn import preprocessing | ||
|
||
qt = preprocessing.QuantileTransformer(n_quantiles=3) | ||
data = [[1, 2], [3, 2], [4, 5]] | ||
qt.fit(data) | ||
|
||
transformed = qt.transform(data) | ||
print(transformed) | ||
``` | ||
``` | ||
[[0. 0. ] | ||
[0.5 0. ] | ||
[1. 1. ]] | ||
``` | ||
|