import { Scikit1D, Scikit2D, Tensor2D } from '../types'; import { Serialize } from '../simpleSerializer'; export interface PipelineParams { steps?: Array<[string, any]>; } /** Construct a pipeline of transformations, with the final one being an estimator. * Usually this is used to perform some cleaning of the data in the early stages of the pipeline * (ie. StandardScaling, or SimpleImputer), and then ending with the fitted estimator. * * * ```js * import { Pipeline } from 'scikitjs' * * const X = [ [2, 2], // [1, .5] [2, NaN], // [1, 0] [NaN, 4], // [0, 1] [1, 0] // [.5, 0] ] const y = [5, 3, 4, 1.5] const pipeline = new Pipeline({ steps: [ [ 'simpleImputer', new SimpleImputer({ strategy: 'constant', fillValue: 0 }) ], ['minmax', new MinMaxScaler()], ['lr', new LinearRegression({ fitIntercept: false })] ] }) await pipeline.fit(X, y) * ``` */ export declare class Pipeline extends Serialize { steps: Array<[string, any]>; /** Useful for pipelines and column transformers to have a default name for transforms */ name: string; constructor({ steps }?: PipelineParams); /** Checks if the input is a Transformer or the string "passthrough" */ isTransformer(possibleTransformer: any): boolean; /** Checks if the input is an Estimator or the string "passthrough" */ isEstimator(possibleTransformer: any): boolean; /** Checks if the steps are valid. Each of the elements in the array (except for the last) * must be a Transformer. That means they need a "fit" and "transform" method. The only special case * is the string "passthrough" which leaves the input untouched. The sklearn pipeline uses that feature * a lot when it grid searches through everything. * * I call validateSteps in the constructor as well as every call to fit/predict. In the case of grid search * the steps can be changed at runtime and so you need to check on every call if your value for steps is still * valid */ validateSteps(steps: Array<[string, any]>): void; transformExceptLast(X: Scikit2D): Scikit2D; fitTransformExceptLast(X: Scikit2D): Scikit2D; getLastEstimator(): any; assertEstimatorHasFunction(estimator: any, funcName: string): void; fit(X: Scikit2D, y: Scikit1D): Promise; transform(X: Scikit2D): Tensor2D; fitTransform(X: Scikit2D, y: Scikit1D): Tensor2D; predict(X: Scikit2D): any; fitPredict(X: Scikit2D, y: Scikit1D): Promise; } /** * * Shorthand for making a Pipeline class. Just pass your Estimators as function arguments. * * @example * ```typescript * import {makePipeline, SimpleImputer, MinMaxScaler, LinearRegression} from 'scikitjs' * const X = [ [2, 2], [2, NaN], [NaN, 4], [1, 0] ] const y = [5, 3, 4, 1.5] const pipeline = makePipeline( new SimpleImputer({ strategy: 'constant', fillValue: 0 }), new MinMaxScaler(), new LinearRegression({ fitIntercept: false }) ) await pipeline.fit(X, y) ``` */ export declare function makePipeline(...args: any[]): Pipeline;