Scaler
class atom.data_cleaning.Scaler(strategy="standard", include_binary=False, device="cpu", engine=None, verbose=0, **kwargs)[source]
Scale the data.
Apply one of sklearn's scaling strategies. Categorical columns are ignored.
This class can be accessed from atom through the scale method. Read more in the user guide.
Parameters |
strategy: str, default="standard"
Strategy with which to scale the data. Choose from:
include_binary: bool, default=False
Whether to scale binary columns (only 0s and 1s).
device: str, default="cpu"
Device on which to run the estimators. Use any string that
follows the SYCL_DEVICE_FILTER filter selector, e.g.
engine: str or None, default=Nonedevice="gpu" to use the GPU. Read more in the
user guide.
Execution engine to use for estimators.
If None, the default value is used. Choose from:
verbose: int, default=0
Verbosity level of the class. Choose from:
**kwargs
Additional keyword arguments for the strategy estimator.
|
Attributes | {#scaler-[strategy]}
[strategy]: sklearn transformer
Object with which the data is scaled, e.g.,
feature_names_in_: np.ndarrayscaler.standard for the default strategy.
Names of features seen during
n_features_in_: intfit .
Number of features seen during fit .
|
See Also
Balance the number of samples per class in the target column.
Transform the data to follow a Normal/Gaussian distribution.
Scale the data.
Example
>>> from atom import ATOMClassifier
>>> from sklearn.datasets import load_breast_cancer
>>> X, y = load_breast_cancer(return_X_y=True, as_frame=True)
>>> atom = ATOMClassifier(X, y, random_state=1)
>>> print(atom.dataset)
mean radius mean texture mean perimeter mean area mean smoothness mean compactness mean concavity mean concave points mean symmetry ... worst perimeter worst area worst smoothness worst compactness worst concavity worst concave points worst symmetry worst fractal dimension target
0 13.48 20.82 88.40 559.2 0.10160 0.12550 0.10630 0.05439 0.1720 ... 107.30 740.4 0.1610 0.42250 0.5030 0.22580 0.2807 0.10710 0
1 18.31 20.58 120.80 1052.0 0.10680 0.12480 0.15690 0.09451 0.1860 ... 142.20 1493.0 0.1492 0.25360 0.3759 0.15100 0.3074 0.07863 0
2 17.93 24.48 115.20 998.9 0.08855 0.07027 0.05699 0.04744 0.1538 ... 135.10 1320.0 0.1315 0.18060 0.2080 0.11360 0.2504 0.07948 0
3 15.13 29.81 96.71 719.5 0.08320 0.04605 0.04686 0.02739 0.1852 ... 110.10 931.4 0.1148 0.09866 0.1547 0.06575 0.3233 0.06165 0
4 8.95 15.76 58.74 245.2 0.09462 0.12430 0.09263 0.02308 0.1305 ... 63.34 270.0 0.1179 0.18790 0.1544 0.03846 0.1652 0.07722 1
.. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
564 14.34 13.47 92.51 641.2 0.09906 0.07624 0.05724 0.04603 0.2075 ... 110.40 873.2 0.1297 0.15250 0.1632 0.10870 0.3062 0.06072 1
565 13.17 21.81 85.42 531.5 0.09714 0.10470 0.08259 0.05252 0.1746 ... 105.50 740.7 0.1503 0.39040 0.3728 0.16070 0.3693 0.09618 0
566 17.30 17.08 113.00 928.2 0.10080 0.10410 0.12660 0.08353 0.1813 ... 130.90 1222.0 0.1416 0.24050 0.3378 0.18570 0.3138 0.08113 0
567 17.68 20.74 117.40 963.7 0.11150 0.16650 0.18550 0.10540 0.1971 ... 132.90 1302.0 0.1418 0.34980 0.3583 0.15150 0.2463 0.07738 0
568 14.80 17.66 95.88 674.8 0.09179 0.08890 0.04069 0.02260 0.1893 ... 105.90 829.5 0.1226 0.18810 0.2060 0.08308 0.3600 0.07285 1
[569 rows x 31 columns]
>>> atom.scale(verbose=2)
Fitting Scaler...
Scaling features...
>>> # Note the reduced number of rows
>>> print(atom.dataset)
mean radius mean texture mean perimeter mean area mean smoothness mean compactness mean concavity mean concave points mean symmetry ... worst perimeter worst area worst smoothness worst compactness worst concavity worst concave points worst symmetry worst fractal dimension target
0 -0.181875 0.356669 -0.147122 -0.270991 0.340268 0.381628 0.214571 0.125567 -0.345050 ... 0.000933 -0.246244 1.240292 1.077359 1.116229 1.667157 -0.162964 1.326816 0
1 1.162216 0.300578 1.159704 1.097856 0.707625 0.368288 0.852572 1.148598 0.172744 ... 1.025723 1.042996 0.719898 -0.011475 0.500961 0.537309 0.280594 -0.308640 0
2 1.056470 1.212060 0.933833 0.950360 -0.581659 -0.670877 -0.407166 -0.051653 -1.018183 ... 0.817241 0.746639 -0.060694 -0.482078 -0.311813 -0.027615 -0.666328 -0.259812 0
3 0.277287 2.457753 0.188054 0.174273 -0.959614 -1.132432 -0.534892 -0.562913 0.143156 ... 0.083151 0.080948 -0.797185 -1.010314 -0.569828 -0.750385 0.544735 -1.284055 0
4 -1.442482 -0.825921 -1.343434 -1.143186 -0.152840 0.358760 0.042209 -0.672815 -1.879941 ... -1.289891 -1.052061 -0.660471 -0.435018 -0.571280 -1.162598 -2.081728 -0.389638 1
.. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
564 0.057446 -1.361124 0.018651 -0.043220 0.160827 -0.557108 -0.404013 -0.087607 0.967929 ... 0.091960 -0.018751 -0.140077 -0.663228 -0.528681 -0.101629 0.260659 -1.337478 1
565 -0.268141 0.588045 -0.267318 -0.347933 0.025188 -0.014753 -0.084382 0.077883 -0.248889 ... -0.051921 -0.245730 0.768409 0.870422 0.485954 0.683827 1.308918 0.699518 0
566 0.881154 -0.517419 0.845098 0.753978 0.283751 -0.026187 0.470528 0.868616 -0.001087 ... 0.693914 0.578760 0.384728 -0.095926 0.316526 1.061450 0.386915 -0.165028 0
567 0.986900 0.337972 1.022568 0.852586 1.039660 1.162956 1.213182 1.426285 0.583281 ... 0.752641 0.715804 0.393548 0.608690 0.415763 0.544861 -0.734440 -0.380446 0
568 0.185455 -0.381865 0.154577 0.050111 -0.352767 -0.315850 -0.612688 -0.685055 0.294796 ... -0.040176 -0.093611 -0.453195 -0.433728 -0.321494 -0.488617 1.154420 -0.640672 1
[569 rows x 31 columns]
>>> from atom.data_cleaning import Scaler
>>> from sklearn.datasets import load_breast_cancer
>>> X, y = load_breast_cancer(return_X_y=True, as_frame=True)
>>> scaler = Scaler(verbose=2)
>>> X = scaler.fit_transform(X)
Fitting Scaler...
Scaling features...
>>> # Note the reduced number of rows
>>> print(X)
mean radius mean texture mean perimeter mean area mean smoothness mean compactness mean concavity mean concave points mean symmetry ... worst texture worst perimeter worst area worst smoothness worst compactness worst concavity worst concave points worst symmetry worst fractal dimension
0 1.097064 -2.073335 1.269934 0.984375 1.568466 3.283515 2.652874 2.532475 2.217515 ... -1.359293 2.303601 2.001237 1.307686 2.616665 2.109526 2.296076 2.750622 1.937015
1 1.829821 -0.353632 1.685955 1.908708 -0.826962 -0.487072 -0.023846 0.548144 0.001392 ... -0.369203 1.535126 1.890489 -0.375612 -0.430444 -0.146749 1.087084 -0.243890 0.281190
2 1.579888 0.456187 1.566503 1.558884 0.942210 1.052926 1.363478 2.037231 0.939685 ... -0.023974 1.347475 1.456285 0.527407 1.082932 0.854974 1.955000 1.152255 0.201391
3 -0.768909 0.253732 -0.592687 -0.764464 3.283553 3.402909 1.915897 1.451707 2.867383 ... 0.133984 -0.249939 -0.550021 3.394275 3.893397 1.989588 2.175786 6.046041 4.935010
4 1.750297 -1.151816 1.776573 1.826229 0.280372 0.539340 1.371011 1.428493 -0.009560 ... -1.466770 1.338539 1.220724 0.220556 -0.313395 0.613179 0.729259 -0.868353 -0.397100
.. ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
564 2.110995 0.721473 2.060786 2.343856 1.041842 0.219060 1.947285 2.320965 -0.312589 ... 0.117700 1.752563 2.015301 0.378365 -0.273318 0.664512 1.629151 -1.360158 -0.709091
565 1.704854 2.085134 1.615931 1.723842 0.102458 -0.017833 0.693043 1.263669 -0.217664 ... 2.047399 1.421940 1.494959 -0.691230 -0.394820 0.236573 0.733827 -0.531855 -0.973978
566 0.702284 2.045574 0.672676 0.577953 -0.840484 -0.038680 0.046588 0.105777 -0.809117 ... 1.374854 0.579001 0.427906 -0.809587 0.350735 0.326767 0.414069 -1.104549 -0.318409
567 1.838341 2.336457 1.982524 1.735218 1.525767 3.272144 3.296944 2.658866 2.137194 ... 2.237926 2.303601 1.653171 1.430427 3.904848 3.197605 2.289985 1.919083 2.219635
568 -1.808401 1.221792 -1.814389 -1.347789 -3.112085 -1.150752 -1.114873 -1.261820 -0.820070 ... 0.764190 -1.432735 -1.075813 -1.859019 -1.207552 -1.305831 -1.745063 -0.048138 -0.751207
[569 rows x 30 columns]
Methods
fit | Fit to data. |
fit_transform | Fit to data, then transform it. |
get_feature_names_out | Get output feature names for transformation. |
get_metadata_routing | Get metadata routing of this object. |
get_params | Get parameters for this estimator. |
inverse_transform | Apply the inverse transformation to the data. |
set_fit_request | Request metadata passed to the fit method. |
set_output | Set output container. |
set_params | Set the parameters of this estimator. |
transform | Perform standardization by centering and scaling. |
method fit(X, y=None, sample_weight=None)[source]
Fit to data.
method fit_transform(X=None, y=None, **fit_params)[source]
Fit to data, then transform it.
method get_feature_names_out(input_features=None)[source]
Get output feature names for transformation.
method get_metadata_routing()[source]
Get metadata routing of this object.
Returns |
routing : MetadataRequest
A :class: ~sklearn.utils.metadata_routing.MetadataRequest encapsulating
routing information.
|
method get_params(deep=True)[source]
Get parameters for this estimator.
Parameters |
deep : bool, default=True
If True, will return the parameters for this estimator and
contained subobjects that are estimators.
|
Returns |
params : dict
Parameter names mapped to their values.
|
method inverse_transform(X, y=None)[source]
Apply the inverse transformation to the data.
method set_fit_request(sample_weight="$UNCHANGED$")[source]
Request metadata passed to the fit
method.
Parameters |
sample_weight : str, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for sample_weight parameter in fit .
|
Returns |
self : object
The updated object.
|
method set_output(transform=None)[source]
Set output container.
See sklearn's user guide on how to use the
set_output
API. See here a description
of the choices.
method set_params(**params)[source]
Set the parameters of this estimator.
Parameters |
**params : dict
Estimator parameters.
|
Returns |
self : estimator instance
Estimator instance.
|
method transform(X, y=None)[source]
Perform standardization by centering and scaling.