ML - MLModelBuilder
ML.MLModelBuilderA builder to define (and optionally train) a machine learning model.
Example
// use a DictType stream
const training_stream = Stream(
"My Stream",
DictType(
StringType,
StructType({
x: FloatType,
y: FloatType,
})
)
);
// create a gradient boosted tree
const ml_model = new MLModelBuilder("ML Training")
.feature("x", FloatType)
.output(FloatType)
.model({ type: "boosted_trees", noise: "none" })
.trainFromStream({
output_name: "y",
input: training_stream,
});
Type parameters
Name | Type |
---|---|
Name | extends string |
Features | extends Record = |
ML
constructor
• new MLModelBuilder(name
, module?
):
MLModelBuilder
Construct a new ML model with a given name
Type parameters
Name | Type |
---|---|
Name | extends string |
Features | extends Record = |
Parameters
Name | Type |
---|---|
name | Name |
module? | ModulePath | ModuleBuilder |
Returns
MLModelBuilder
Example
// use a DictType stream
const training_stream = Stream(
"My Stream",
DictType(
StringType,
StructType({
x: FloatType,
y: FloatType,
})
)
);
// create a gradient boosted tree
const ml_model = new MLModelBuilder("ML Training")
.feature("x", FloatType)
.output(FloatType)
.model({ type: "boosted_trees", noise: "none" })
.trainFromStream({
output_name: "y",
input: training_stream,
});
feature
▸ feature(name
, type
):
MLModelBuilder
<Name
, Features
& { [K in string]: T }>
Define an input feature for the model.
Type parameters
Name | Type |
---|---|
FeatureName | extends string |
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
name | FeatureName | the name of the feature |
type | T | the EastType of the feature |
Returns
MLModelBuilder
<Name
, Features
& { [K in string]: T }>
Example
// create a gradient boosted tree
const ml_model = new MLModelBuilder("ML Training")
.feature("x", FloatType)
.output(FloatType)
output
▸ output(type
): T
extends
FloatType
? FloatMLBuilder
<Name
, Features
, { noise
: "gaussian"
; type
: "gaussian_process"
}> : StringMLBuilder
<Name
, Features
, { noise
: "weighted"
; type
: "boosted_trees_string"
}>
Define the EastType the model will predict.
Type parameters
Name | Type |
---|---|
T | extends FloatType | StringType |
Parameters
Name | Type | Description |
---|---|---|
type | T | the EastType of the output |
Returns
T
extends
FloatType
? FloatMLBuilder
<Name
, Features
, { noise
: "gaussian"
; type
: "gaussian_process"
}> : StringMLBuilder
<Name
, Features
, { noise
: "weighted"
; type
: "boosted_trees_string"
}>
Example
// create a gradient boosted tree
const ml_model = new MLModelBuilder("ML Training")
.output(FloatType)