Skip to main content

ML - MLPredictionBuilder

ML.MLPredictionBuilder

A 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

NameType
namestring
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

NameType
Featuresextends Record
Textends EastType

Parameters

NameTypeDescription
modelAbstractMLBuilderthe 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);

On this page