Skip to content

GridSearchCV

Defined in: ds/src/ml/pipeline.js:137

Simple GridSearchCV for hyperparameter tuning

Extends

  • Estimator

Constructors

Constructor

new GridSearchCV(estimatorFn, paramGrid, scoreFn, cv?): GridSearchCV

Defined in: ds/src/ml/pipeline.js:145

Create grid search

Parameters

estimatorFn

Function

Function that creates estimator: (params) => estimator

paramGrid

any

Grid of parameters: {param1: [val1, val2], …}

scoreFn

Function

Scoring function: (yTrue, yPred) => score

cv?

number = 5

Number of cross-validation folds

Returns

GridSearchCV

Overrides

Estimator.constructor

Properties

_state

_state: object

Defined in: ds/src/core/estimators/estimator.js:27

Inherited from

Estimator._state


_warnings

_warnings: any[]

Defined in: ds/src/core/estimators/estimator.js:29

Inherited from

Estimator._warnings


bestEstimator

bestEstimator: any

Defined in: ds/src/ml/pipeline.js:153


bestParams

bestParams: any

Defined in: ds/src/ml/pipeline.js:151


bestScore

bestScore: number

Defined in: ds/src/ml/pipeline.js:152


cv

cv: number

Defined in: ds/src/ml/pipeline.js:150


cvResults

cvResults: any[]

Defined in: ds/src/ml/pipeline.js:154


estimatorFn

estimatorFn: Function

Defined in: ds/src/ml/pipeline.js:147


fitted

fitted: boolean

Defined in: ds/src/core/estimators/estimator.js:25

Inherited from

Estimator.fitted


paramGrid

paramGrid: any

Defined in: ds/src/ml/pipeline.js:148


params

params: any

Defined in: ds/src/core/estimators/estimator.js:24

Inherited from

Estimator.params


scoreFn

scoreFn: Function

Defined in: ds/src/ml/pipeline.js:149

Methods

_prepareArgsForFit()

_prepareArgsForFit(args?): { columns?: undefined; columnsX: any[]; prepared: boolean; raw?: undefined; rows: any[]; X: any[][]; y: any[]; } | { columns: any[]; columnsX?: undefined; prepared: boolean; raw?: undefined; rows: any[]; X: any[][]; y?: undefined; } | { columns?: undefined; columnsX?: undefined; prepared?: undefined; raw: any[]; rows?: undefined; X?: undefined; y?: undefined; }

Defined in: ds/src/core/estimators/estimator.js:367

Convenience helper: parse arguments passed to fit/predict/transform.

Supports declarative table-style inputs:

  • fit({ X, y, data, omit_missing })
  • fit({ data, columns, … })

Returns an object { X, y, prepared, rows } where X/y are numeric arrays if preparation was required, otherwise returns the original values.

Note: this helper only prepares numeric matrices/vectors using core table utilities; it does not perform encoding of categorical predictors.

Parameters

args?

any[] = []

Returns

{ columns?: undefined; columnsX: any[]; prepared: boolean; raw?: undefined; rows: any[]; X: any[][]; y: any[]; } | { columns: any[]; columnsX?: undefined; prepared: boolean; raw?: undefined; rows: any[]; X: any[][]; y?: undefined; } | { columns?: undefined; columnsX?: undefined; prepared?: undefined; raw: any[]; rows?: undefined; X?: undefined; y?: undefined; }

Inherited from

Estimator._prepareArgsForFit


_repr_html_()

_repr_html_(): string

Defined in: ds/src/core/estimators/estimator.js:201

Observable/Jupyter HTML representation

Returns

string

HTML representation

Inherited from

Estimator._repr_html_


clearWarnings()

clearWarnings(): void

Defined in: ds/src/core/estimators/estimator.js:139

Clear all warnings

Returns

void

Inherited from

Estimator.clearWarnings


fit()

fit(X, y): GridSearchCV

Defined in: ds/src/ml/pipeline.js:189

Perform grid search with cross-validation

Parameters

X

any[]

Feature matrix

y

any[]

Target values

Returns

GridSearchCV

this

Overrides

Estimator.fit


getMemoryUsage()

getMemoryUsage(): string

Defined in: ds/src/core/estimators/estimator.js:97

Get memory usage in human-readable format

Returns

string

Memory usage string (e.g., “2.3 MB” or “145 KB”)

Inherited from

Estimator.getMemoryUsage


getParams()

getParams(): any

Defined in: ds/src/core/estimators/estimator.js:294

Get a shallow copy of parameters.

Returns

any

Inherited from

Estimator.getParams


getResults()

getResults(): any[]

Defined in: ds/src/ml/pipeline.js:273

Get results sorted by score

Returns

any[]

Results


getState()

getState(): any

Defined in: ds/src/core/estimators/estimator.js:65

Get comprehensive model state

Returns

any

State information including fitted status, memory estimate, warnings

Inherited from

Estimator.getState


getWarnings()

getWarnings(): any[]

Defined in: ds/src/core/estimators/estimator.js:124

Get all warnings

Returns

any[]

Array of warning objects

Inherited from

Estimator.getWarnings


getWarningsByType()

getWarningsByType(type): any[]

Defined in: ds/src/core/estimators/estimator.js:148

Get warnings of a specific type

Parameters

type

string

Warning type

Returns

any[]

Filtered warnings

Inherited from

Estimator.getWarningsByType


hasWarnings()

hasWarnings(): boolean

Defined in: ds/src/core/estimators/estimator.js:132

Check if model has warnings

Returns

boolean

Inherited from

Estimator.hasWarnings


isFitted()

isFitted(): boolean

Defined in: ds/src/core/estimators/estimator.js:36

Check if model is fitted

Returns

boolean

Inherited from

Estimator.isFitted


predict()

predict(X): any[]

Defined in: ds/src/ml/pipeline.js:264

Predict using best estimator

Parameters

X

any[]

Feature matrix

Returns

any[]

Predictions

Overrides

Estimator.predict


save()

save(): string

Defined in: ds/src/core/estimators/estimator.js:329

Save model to JSON string

Returns

string

JSON representation of the model

Inherited from

Estimator.save


setParams()

setParams(params?): GridSearchCV

Defined in: ds/src/core/estimators/estimator.js:285

Set parameters (mutates instance).

Parameters

params?

any = {}

Returns

GridSearchCV

Inherited from

Estimator.setParams


toJSON()

toJSON(): object

Defined in: ds/src/core/estimators/estimator.js:302

Serialize minimal model metadata. Subclasses may override to include learned parameters.

Returns

object

fitted

fitted: boolean

params

params: any

state

state: object

warnings

warnings: any[]

Inherited from

Estimator.toJSON


transform()

transform(): void

Defined in: ds/src/core/estimators/estimator.js:431

Transform should be implemented by transformers.

Returns

void

Inherited from

Estimator.transform


fromJSON()

static fromJSON(obj?): Estimator

Defined in: ds/src/core/estimators/estimator.js:317

Basic deserialization. Subclasses should override if they need to restore learned arrays / matrices.

Parameters

obj?

any = {}

Returns

Estimator

Inherited from

Estimator.fromJSON


load()

static load(jsonString): Estimator

Defined in: ds/src/core/estimators/estimator.js:346

Load model from JSON string

Parameters

jsonString

string

JSON representation

Returns

Estimator

Reconstructed estimator instance

Inherited from

Estimator.load