/** * @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, Scikit2D, Tensor2D, Tensor1D } from '../types'; import { ClassifierMixin } from '../mixins'; /** * Supported strategies for this classifier. */ export interface DummyClassifierParams { /** * If strategy is "mostFrequent" than the most frequent class label is chosen no matter the input. * If "uniform" is chosen than a uniformly random class label is chosen for a given input. * If "constant" is chosen than you must supply a constant number and this classifier returns that number * a given input. **default = "mostFrequent"** */ strategy?: 'mostFrequent' | 'uniform' | 'constant'; /** * If strategy is "constant" than this number is returned for every input. **default = undefined** */ constant?: number; } /** * Creates an classifier that guesses a class label based on simple rules. * By setting a strategy (ie 'mostFrequent', 'uniform', or 'constant'), * you can create a simple classifier which can be helpful in determining * if a more complicated classifier is actually more predictive. * * @example * ```js * import { DummyClassifier } from 'scikitjs' * * const clf = new DummyClassifier({ strategy: 'mostFrequent' }) const X = [ [-1, 5], [-0.5, 5], [0, 10] ] const y = [10, 20, 20] // 20 is the most frequent class label clf.fit(X, y) // always predicts 20 clf.predict([ [0, 0], [1000, 1000] ]) // [20, 20] * ``` * */ export declare class DummyClassifier extends ClassifierMixin { constant: number; strategy: string; /**These are the unique class labels that are seen during fit. */ classes: number[] | string[]; /** Useful for pipelines and column transformers to have a default name for transforms */ name: string; tf: any; constructor({ strategy, constant }?: DummyClassifierParams); /** * Fit a DummyClassifier to the data. */ fit(X: Scikit2D, y: Scikit1D): DummyClassifier; predictProba(X: Scikit2D): Tensor2D; predict(X: Scikit2D): Tensor1D; }