Skip to content

Commit

Permalink
Using quantile transformer example #1842
Browse files Browse the repository at this point in the history
  • Loading branch information
nonunicorn committed Dec 16, 2022
1 parent 0593078 commit 6e628f2
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions python-scikit-learn/using-quantile-transformer-example.md
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. ]]
```

0 comments on commit 6e628f2

Please sign in to comment.