/** * @license * Copyright 2021, JsData. All rights reserved. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ========================================================================== */ import { Scikit2D, Tensor1D, Tensor2D, Transformer } from '../types'; import { TransformerMixin } from '../mixins'; export interface MinMaxScalerParams { /** Desired range of transformed data. **default = [0, 1] ** */ featureRange?: [number, number]; } /** * Transform features by scaling each feature to a given range. * This estimator scales and translates each feature individually such * that it is in the given range on the training set, e.g. between the maximum and minimum value. * * @example * ```js * import { MinMaxScaler } from 'scikitjs' * * const data = [ [-1, 2], [-0.5, 6], [0, 10], [1, 18] ] const scaler = new MinMaxScaler() const expected = scaler.fitTransform(data) // const expected = [ // [0, 0], // [0.25, 0.25], // [0.5, 0.5], // [1, 1] //] ``` */ export declare class MinMaxScaler extends TransformerMixin implements Transformer { featureRange: [number, number]; /** The per-feature scale that we see in the dataset. */ scale: Tensor1D; min: Tensor1D; /** The per-feature minimum that we see in the dataset. */ dataMin: Tensor1D; /** The per-feature maximum that we see in the dataset. */ dataMax: Tensor1D; /** The per-feature range that we see in the dataset. */ dataRange: Tensor1D; /** The number of features seen during fit */ nFeaturesIn: number; /** The number of samples processed by the Estimator. Will be reset on new calls to fit */ nSamplesSeen: number; /** Names of features seen during fit. Only stores feature names if input is a DataFrame */ featureNamesIn: Array; /** Useful for pipelines and column transformers to have a default name for transforms */ name: string; constructor({ featureRange }?: MinMaxScalerParams); isNumber(value: any): boolean; /** * Fits a MinMaxScaler to the data */ fit(X: Scikit2D): MinMaxScaler; /** * Transform the data using the fitted scaler * */ transform(X: Scikit2D): Tensor2D; /** * Inverse transform the data using the fitted scaler * */ inverseTransform(X: Scikit2D): Tensor2D; }