/** * @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 { Scikit1D, Tensor1D } from '../types'; import { Serialize } from '../simpleSerializer'; /** * Encode target labels with value between 0 and n_classes-1. * @example * ```js * import { LabelEncoder } from 'scikitjs' * * const sf = [1, 2, 2, 'boy', 'git', 'git'] const scaler = new LabelEncoder() scaler.fit(sf) console.log(scaler.classes) // [1, 2, "boy", "git"] scaler.transform([2, 2, "boy"]) // [1, 1, 2] * ``` */ export declare class LabelEncoder extends Serialize { /** Unique classes that we see in this single array of data */ classes: Array; /** Useful for pipelines and column transformers to have a default name for transforms */ name: string; tf: any; constructor(); convertTo1DArray(X: Scikit1D): Iterable; classesToMapping(classes: Array): Map; /** * Maps values to unique integer labels between 0 and n_classes-1. * @example * ```js * const encoder = new LabelEncoder() * encoder.fit(["a", "b", "c", "d"]) * ``` */ fit(X: Scikit1D): LabelEncoder; /** * Encode labels with value between 0 and n_classes-1. * @example * ```js * const encoder = new LabelEncoder() * encoder.fit(["a", "b", "c", "d"]) * console.log(encoder.transform(["a", "b", "c", "d"])) * // [0, 1, 2, 3] * ``` */ transform(X: Scikit1D): Tensor1D; fitTransform(X: Scikit1D): Tensor1D; /** * Inverse transform values back to original values. * @example * ```js * const encoder = new LabelEncoder() * encoder.fit(["a", "b", "c", "d"]) * console.log(encoder.inverseTransform([0, 1, 2, 3])) * // ["a", "b", "c", "d"] * ``` */ inverseTransform(X: Scikit1D): any[]; }