import { Stream, StreamIO } from "../data"; import { DictType, EastType, StringType, StructType } from "../east"; import { TaskDescription } from "../task"; import { Builder, ModulePath, Template } from "../template"; import { ModuleBuilder } from '../template/ModuleBuilder'; import { AbstractMLBuilder, MLModel } from "./MLModelBuilder"; /** @internal */ export type MLPredictionTaskDescription = { task_type: 'ml_prediction'; module: ModulePath; name: string; model: MLModel; inputs: { model: StreamIO; examples: StreamIO; }; outputs: { output: StreamIO; }; }; /** * A builder to create ML predictions made from provided features * * @category ML * * @example * ```typescript * // 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); * * ``` * * */ export declare class MLPredictionBuilder { private name; private module; /** * Construct a new ML prediction task with a given name * * @category ML * * @example * ```typescript * // 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); * * ``` * * */ constructor(name: string, module?: ModuleBuilder | ModulePath); /** * Specify the ML model to use for prediction * * @param model the {@link MLModelBuilder} to apply in prediction * * @category ML * * @example * ```typescript * // 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, T extends EastType>(model: AbstractMLBuilder): MLModelEvaluatorBuilder; } /** * {@inheritDoc MLPredictionBuilder} * * @category ML * */ export declare class MLModelEvaluatorBuilder> { private name; private module; private outputType; private features; private modelType; private modelStream; constructor(name: string, module: ModulePath, outputType: Output, features: Features, modelType: MLModel, modelStream: Stream); /** * Predict outputs from a stream of features * * @category ML * * @example * ```typescript * // 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); * ``` * */ predict(featureStream: Stream>>): MLExamplesEvaluatorBuilder; } /** * {@inheritDoc MLPredictionBuilder} * * @category ML * */ export declare class MLExamplesEvaluatorBuilder> extends Builder { private outputType; private features; private modelType; private modelStream; private examplesStream; constructor(name: string, module: ModulePath, outputType: Output, features: Features, modelType: MLModel, modelStream: Stream, examplesStream: Stream); /** * Return the output stream * * @returns The ouput {@link Stream} * * @category ML * * */ outputStream(): Stream; output: Output; }>>>; /** @internal */ predictionTask(): TaskDescription; /** * Convert the built ML prediction task into an {@link Template}, for inclusion in an EDK project. * * @returns The {@link Template} containing the ML Model * * @category ML * * */ toTemplate(): Template; }