Skip to content

MLPRegressor

Defined in: ml/estimators/MLPRegressor.js:30

Extends

  • Regressor

Constructors

Constructor

new MLPRegressor(params?): MLPRegressor

Defined in: ml/estimators/MLPRegressor.js:45

Parameters

params?
activation?

string

of the hidden layers

batchSize?

number

dropout?

number

rate, applied after each hidden layer

epochs?

number

iterations, for L-BFGS

layerSizes?

number[]

[inputs, ...hidden, outputs]; by default one hidden layer of max(4, 2 · inputs) units and one output

learningRate?

number

normalizeY?

boolean

standardize the targets for training

optimizer?

"adam" | "sgd" | "momentum" | "rmsprop" | "lbfgs"

seed?

number

for initialization, shuffles and masks

verbose?

boolean

Returns

MLPRegressor

Overrides

Regressor.constructor

Properties

_state

_state: object

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

Inherited from

Regressor._state


_warnings

_warnings: any[]

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

Inherited from

Regressor._warnings


fitted

fitted: boolean

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

Inherited from

Regressor.fitted


history

history: any

Defined in: ml/estimators/MLPRegressor.js:50


model

model: any

Defined in: ml/estimators/MLPRegressor.js:49


params

params: object

Defined in: ml/estimators/MLPRegressor.js:48

activation

activation: string = 'relu'

batchSize

batchSize: number = 32

dropout

dropout: number = 0

epochs

epochs: number = 100

layerSizes

layerSizes: any = null

learningRate

learningRate: number = 0.01

normalizeY

normalizeY: boolean = true

omit_missing

omit_missing: boolean = true

optimizer

optimizer: string = 'adam'

seed

seed: any = null

verbose

verbose: boolean = false

Inherited from

Regressor.params

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: 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

Regressor._prepareArgsForFit


_r2()

_r2(yTrue, yPred): number

Defined in: core/estimators/estimator.js:489

Parameters

yTrue

any

yPred

any

Returns

number

Inherited from

Regressor._r2


_repr_html_()

_repr_html_(): string

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

Observable/Jupyter HTML representation

Returns

string

HTML representation

Inherited from

Regressor._repr_html_


clearWarnings()

clearWarnings(): void

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

Clear all warnings

Returns

void

Inherited from

Regressor.clearWarnings


evaluate()

evaluate(X, y): number

Defined in: ml/estimators/MLPRegressor.js:115

Mean squared error on the target scale.

Parameters

X

any

y

any

Returns

number


fit()

fit(X, y?, opts?): MLPRegressor

Defined in: ml/estimators/MLPRegressor.js:57

Fit on (X, y), or on a declarative spec { X, columns, y, data, omit_missing }.

Parameters

X

any

y?

any = null

opts?

Returns

MLPRegressor

Overrides

Regressor.fit


getMemoryUsage()

getMemoryUsage(): string

Defined in: 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

Regressor.getMemoryUsage


getParams()

getParams(): any

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

Get a shallow copy of parameters.

Returns

any

Inherited from

Regressor.getParams


getState()

getState(): any

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

Get comprehensive model state

Returns

any

State information including fitted status, memory estimate, warnings

Inherited from

Regressor.getState


getWarnings()

getWarnings(): any[]

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

Get all warnings

Returns

any[]

Array of warning objects

Inherited from

Regressor.getWarnings


getWarningsByType()

getWarningsByType(type): any[]

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

Get warnings of a specific type

Parameters

type

string

Warning type

Returns

any[]

Filtered warnings

Inherited from

Regressor.getWarningsByType


hasWarnings()

hasWarnings(): boolean

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

Check if model has warnings

Returns

boolean

Inherited from

Regressor.hasWarnings


isFitted()

isFitted(): boolean

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

Check if model is fitted

Returns

boolean

Inherited from

Regressor.isFitted


predict()

predict(X, options): any

Defined in: ml/estimators/MLPRegressor.js:99

Predict: a flat array for one output, rows otherwise. With { samples: k } and a dropout rate, Monte Carlo dropout’s { mean, std, epistemic, aleatoric }.

Parameters

X

any

options

any

Returns

any

Overrides

Regressor.predict


predictGradient()

predictGradient(x): any

Defined in: ml/estimators/MLPRegressor.js:109

d prediction / d x at one row, on the target scale.

Parameters

x

any

Returns

any


save()

save(): string

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

Save model to JSON string

Returns

string

JSON representation of the model

Inherited from

Regressor.save


score()

score(yTrueOrOpts, yPred, _opts?, …args?): number

Defined in: core/estimators/estimator.js:461

Default R^2 scoring implementation: 1 - SS_res / SS_tot

Accepts either:

  • arrays: score(yTrue, yPred)
  • table-style: score({ X, y, data }) where predict will be called internally

Parameters

yTrueOrOpts

any

yPred

any

_opts?
args?

…any[] = {}

Returns

number

Inherited from

Regressor.score


setParams()

setParams(params?): MLPRegressor

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

Set parameters (mutates instance).

Parameters

params?

any = {}

Returns

MLPRegressor

Inherited from

Regressor.setParams


summary()

summary(): object

Defined in: ml/estimators/MLPRegressor.js:125

Returns

object

epochs

epochs: any

finalLoss

finalLoss: any

initialLoss

initialLoss: any

layerSizes

layerSizes: any

losses

losses: any = loss

network

network: any

stopped

stopped: any


toJSON()

toJSON(): object

Defined in: ml/estimators/MLPRegressor.js:134

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

Returns

object

__class__

__class__: string = 'MLPRegressor'

fitted

fitted: boolean

history

history: any

model

model: any

params

params: any

Overrides

Regressor.toJSON


transform()

transform(): void

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

Transform should be implemented by transformers.

Returns

void

Inherited from

Regressor.transform


fromJSON()

static fromJSON(obj?): MLPRegressor

Defined in: ml/estimators/MLPRegressor.js:138

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

Parameters

obj?

Returns

MLPRegressor

Overrides

Regressor.fromJSON


load()

static load(jsonString): Estimator

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

Load model from JSON string

Parameters

jsonString

string

JSON representation

Returns

Estimator

Reconstructed estimator instance

Inherited from

Regressor.load