ML - MLPredictionBuilder
ML.MLPredictionBuilderA builder to create ML predictions made from provided features
Example
// use a DictType stream
const training_stream = Stream(
"My Training Stream",
DictType(
StringType,
StructType({
x: FloatType,
y: FloatType,
})
)
);
const prediction_stream = Stream(
"My Prediction Stream",
DictType(
StringType,
StructType({
x: 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,
});
// predict the model outputs from features
const ml_prediction = new MLPredictionBuilder("ML Prediction")
.model(ml_model)
.predict(prediction_stream);
ML
constructor
• new MLPredictionBuilder(name
, module?
):
MLPredictionBuilder
Construct a new ML prediction task with a given name
Parameters
Name | Type |
---|---|
name | string |
module? | ModulePath | ModuleBuilder |
Returns
MLPredictionBuilder
Example
// use a DictType stream
const training_stream = Stream(
"My Training Stream",
DictType(
StringType,
StructType({
x: FloatType,
y: FloatType,
})
)
);
const prediction_stream = Stream(
"My Prediction Stream",
DictType(
StringType,
StructType({
x: 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,
});
// predict the model outputs from features
const ml_prediction = new MLPredictionBuilder("ML Prediction")
.model(ml_model)
.predict(prediction_stream);
model
▸ model(model
):
MLModelEvaluatorBuilder
Specify the ML model to use for prediction
Type parameters
Name | Type |
---|---|
Features | extends Record |
T | extends EastType |
Parameters
Name | Type | Description |
---|---|---|
model | AbstractMLBuilder | the MLModelBuilder to apply in prediction |
Returns
MLModelEvaluatorBuilder
Example
// use a DictType stream
const training_stream = Stream(
"My Training Stream",
DictType(
StringType,
StructType({
x: FloatType,
y: FloatType,
})
)
);
const prediction_stream = Stream(
"My Prediction Stream",
DictType(
StringType,
StructType({
x: 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,
});
// predict the model outputs from features
const ml_prediction = new MLPredictionBuilder("ML Prediction")
.model(ml_model)
.predict(prediction_stream);