gauss-rank-scaler


Namegauss-rank-scaler JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/aldente0630/gauss-rank-scaler.git
SummaryA scikit-learn style transformer that scales numeric variables to normal distributions
upload_time2022-12-22 15:11:50
maintainer
docs_urlNone
authoraldente0630
requires_python
licenseBSD
keywords pypi rank scaler guassian rank guassian rank scaler
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Gauss Rank Scaler
  
A scikit-learn style transformer that scales numeric variables to normal distributions. 

Input normalization for neural networks is very important. Gauss Rank is an effective algorithm for converting numeric variable distributions to normals. It is based on rank transformation. The first step is to assign a spacing between -1 and 1 to the sorted features, then apply the inverse of error function `erfinv` to make it look like a Gaussian. 
  
![](https://aldente0630.github.io/assets/gauss_rank_scaler3.png)
  
This generally works much better than Standard or Min Max Scaler.
  
## Important Links
  
* [Interview of the Kaggle competition winner (Michael Jahrer)](https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629#250927)  
* [Blog post introducing Gauss Rank's concept and simple implementation (Zygmunt ZajÄ…c)](http://fastml.com/preparing-continuous-features-for-neural-networks-with-rankgauss)
  
## Usage

Gauss Rank Scaler is a fully compatible sklearn transformer that can be used in pipelines or existing scripts. Supported input formats include numpy arrays and pandas dataframes. All columns passed to the transformer are properly scaled.

## Example

```python
from gauss_rank_scaler import GaussRankScaler
import pandas as pd
from sklearn.datasets import load_boston
%matplotlib inline

# prepare some data
bunch = load_boston()
df_X_train = pd.DataFrame(bunch.data[:250], columns=bunch.feature_names)
df_X_test = pd.DataFrame(bunch.data[250:], columns=bunch.feature_names)

# plot histograms of two numeric variables
_ = df_X_train[['CRIM', 'DIS']].hist()
```
![](https://aldente0630.github.io/assets/gauss_rank_scaler1.png)
```python
# scale the numeric variables with Gauss Rank Scaler
scaler = GaussRankScaler()
df_X_new_train = scaler.fit_transform(df_X_train[['CRIM', 'DIS']])

# plot histograms of the scaled variables
_ = pd.DataFrame(df_X_new_train, columns=['CRIM', 'DIS']).hist()
```
![](https://aldente0630.github.io/assets/gauss_rank_scaler2.png)
```python
# scale test dataset with the fitted scaler
df_X_new_test = scaler.transform(df_X_test[['CRIM', 'DIS']])
```
## This is a direct copy of the repositopry by Aldente06030 packaged for pip
(https://github.com/aldente0630/gauss-rank-scaler)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aldente0630/gauss-rank-scaler.git",
    "name": "gauss-rank-scaler",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "pypi,rank scaler,guassian rank,guassian rank scaler",
    "author": "aldente0630",
    "author_email": "aldente0630@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c4/c3/0edef4e799d340e9a763e53992f2af135dae68b39883658e40c69ebe4348/gauss-rank-scaler-0.0.3.tar.gz",
    "platform": null,
    "description": "# Gauss Rank Scaler\n  \nA scikit-learn style transformer that scales numeric variables to normal distributions. \n\nInput normalization for neural networks is very important. Gauss Rank is an effective algorithm for converting numeric variable distributions to normals. It is based on rank transformation. The first step is to assign a spacing between -1 and 1 to the sorted features, then apply the inverse of error function `erfinv` to make it look like a Gaussian. \n  \n![](https://aldente0630.github.io/assets/gauss_rank_scaler3.png)\n  \nThis generally works much better than Standard or Min Max Scaler.\n  \n## Important Links\n  \n* [Interview of the Kaggle competition winner (Michael Jahrer)](https://www.kaggle.com/c/porto-seguro-safe-driver-prediction/discussion/44629#250927)  \n* [Blog post introducing Gauss Rank's concept and simple implementation (Zygmunt Zaj\u0105c)](http://fastml.com/preparing-continuous-features-for-neural-networks-with-rankgauss)\n  \n## Usage\n\nGauss Rank Scaler is a fully compatible sklearn transformer that can be used in pipelines or existing scripts. Supported input formats include numpy arrays and pandas dataframes. All columns passed to the transformer are properly scaled.\n\n## Example\n\n```python\nfrom gauss_rank_scaler import GaussRankScaler\nimport pandas as pd\nfrom sklearn.datasets import load_boston\n%matplotlib inline\n\n# prepare some data\nbunch = load_boston()\ndf_X_train = pd.DataFrame(bunch.data[:250], columns=bunch.feature_names)\ndf_X_test = pd.DataFrame(bunch.data[250:], columns=bunch.feature_names)\n\n# plot histograms of two numeric variables\n_ = df_X_train[['CRIM', 'DIS']].hist()\n```\n![](https://aldente0630.github.io/assets/gauss_rank_scaler1.png)\n```python\n# scale the numeric variables with Gauss Rank Scaler\nscaler = GaussRankScaler()\ndf_X_new_train = scaler.fit_transform(df_X_train[['CRIM', 'DIS']])\n\n# plot histograms of the scaled variables\n_ = pd.DataFrame(df_X_new_train, columns=['CRIM', 'DIS']).hist()\n```\n![](https://aldente0630.github.io/assets/gauss_rank_scaler2.png)\n```python\n# scale test dataset with the fitted scaler\ndf_X_new_test = scaler.transform(df_X_test[['CRIM', 'DIS']])\n```\n## This is a direct copy of the repositopry by Aldente06030 packaged for pip\n(https://github.com/aldente0630/gauss-rank-scaler)\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "A scikit-learn style transformer that scales numeric variables to normal distributions",
    "version": "0.0.3",
    "split_keywords": [
        "pypi",
        "rank scaler",
        "guassian rank",
        "guassian rank scaler"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e82bb627545dc9415040ac1ce62502a0",
                "sha256": "770e188e34d6f1635c991c77b7605cccfea4418120057b462a81285840d6ab72"
            },
            "downloads": -1,
            "filename": "gauss-rank-scaler-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "e82bb627545dc9415040ac1ce62502a0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5300,
            "upload_time": "2022-12-22T15:11:50",
            "upload_time_iso_8601": "2022-12-22T15:11:50.827693Z",
            "url": "https://files.pythonhosted.org/packages/c4/c3/0edef4e799d340e9a763e53992f2af135dae68b39883658e40c69ebe4348/gauss-rank-scaler-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-22 15:11:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "aldente0630",
    "github_project": "gauss-rank-scaler.git",
    "lcname": "gauss-rank-scaler"
}
        
Elapsed time: 0.04004s