MachineLearning class

The Firebase MachineLearning service interface.

Signature:

exportdeclareclassMachineLearning

Properties

PropertyModifiersTypeDescription
appAppThe App associated with the current MachineLearning service instance.

Methods

MethodModifiersDescription
createModel(model)Creates a model in the current Firebase project.
deleteModel(modelId)Deletes a model from the current project.
getModel(modelId)Gets the model specified by the given ID.
listModels(options)Lists the current project's models.
publishModel(modelId)Publishes a Firebase ML model.A published model can be downloaded to client apps.
unpublishModel(modelId)Unpublishes a Firebase ML model.
updateModel(modelId, model)Updates a model's metadata or model file.

MachineLearning.app

The App associated with the current MachineLearning service instance.

Signature:

getapp():App;

MachineLearning.createModel()

Creates a model in the current Firebase project.

Signature:

createModel(model:ModelOptions):Promise<Model>;

Parameters

ParameterTypeDescription
modelModelOptionsThe model to create.

Returns:

Promise<Model>

A Promise fulfilled with the created model.

MachineLearning.deleteModel()

Deletes a model from the current project.

Signature:

deleteModel(modelId:string):Promise<void>;

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to delete.

Returns:

Promise<void>

MachineLearning.getModel()

Gets the model specified by the given ID.

Signature:

getModel(modelId:string):Promise<Model>;

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to get.

Returns:

Promise<Model>

A Promise fulfilled with the model object.

MachineLearning.listModels()

Lists the current project's models.

Signature:

listModels(options?:ListModelsOptions):Promise<ListModelsResult>;

Parameters

ParameterTypeDescription
optionsListModelsOptionsThe listing options.

Returns:

Promise<ListModelsResult>

A promise that resolves with the current (filtered) list of models and the next page token. For the last page, an empty list of models and no page token are returned.

MachineLearning.publishModel()

Publishes a Firebase ML model.

A published model can be downloaded to client apps.

Signature:

publishModel(modelId:string):Promise<Model>;

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to publish.

Returns:

Promise<Model>

A Promise fulfilled with the published model.

MachineLearning.unpublishModel()

Unpublishes a Firebase ML model.

Signature:

unpublishModel(modelId:string):Promise<Model>;

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to unpublish.

Returns:

Promise<Model>

A Promise fulfilled with the unpublished model.

MachineLearning.updateModel()

Updates a model's metadata or model file.

Signature:

updateModel(modelId:string,model:ModelOptions):Promise<Model>;

Parameters

ParameterTypeDescription
modelIdstringThe ID of the model to update.
modelModelOptionsThe model fields to update.

Returns:

Promise<Model>

A Promise fulfilled with the updated model.