Method: projects.locations.models.predict

Perform an online prediction. The prediction result will be directly returned in the response.

Provide UTF-8 NFC encoded content in the TextSnippet field. You can provide up to the following maximums:

  • Classification - 60,000 characters.

  • Entity Extraction - 30,000 characters.

  • Sentiment Analysis - 500 characters.

HTTP request

POST https://automl.googleapis.com/v1beta1/{name}:predict

Path parameters

Parameters
name

string

Name of the model requested to serve the prediction.

Authorization requires the following Google IAM permission on the specified resource name:

  • automl.models.predict

Request body

The request body contains data with the following structure:

JSON representation
{
  "payload": {
    object(ExamplePayload)
  },
  "params": {
    string: string,
    ...
  }
}
Fields
payload

object(ExamplePayload)

Required. Payload to perform a prediction on. The payload must match the problem type that the model was trained to solve.

params

map (key: string, value: string)

Additional domain-specific parameters, any string must be up to 25000 characters long.

Response body

If successful, the response body contains data with the following structure:

Response message for PredictionService.Predict.

JSON representation
{
  "payload": [
    {
      object(AnnotationPayload)
    }
  ],
  "metadata": {
    string: string,
    ...
  }
}
Fields
payload[]

object(AnnotationPayload)

Prediction result.

metadata

map (key: string, value: string)

Additional domain-specific prediction response metadata.

Authorization Scopes

Requires the following OAuth scope:

  • https://www.googleapis.com/auth/cloud-platform

For more information, see the Authentication Overview.

ExamplePayload

Example data used for training or prediction.

JSON representation
{

  // Union field payload can be only one of the following:
  "textSnippet": {
    object(TextSnippet)
  },
  "document": {
    object(Document)
  },
  "row": {
    object(Row)
  }
  // End of list of possible types for union field payload.
}
Fields
Union field payload. Required. Input only. The example data. payload can be only one of the following:
textSnippet

object(TextSnippet)

Example text.

document

object(Document)

Example document.

row

object(Row)

Example relational table row.

TextSnippet

A representation of a text snippet.

JSON representation
{
  "content": string,
  "mimeType": string,
  "contentUri": string
}
Fields
content

string

Required. The content of the text snippet as a string. Up to 250000 characters long.

mimeType

string

The format of the source text. Currently the only two allowed values are "text/html" and "text/plain". If left blank the format is automatically determined from the type of the uploaded content.

contentUri

string

Output only. HTTP URI where you can download the content.

Document

A structured text document e.g. a PDF.

JSON representation
{
  "inputConfig": {
    object(DocumentInputConfig)
  }
}
Fields
inputConfig

object(DocumentInputConfig)

An input config specifying the content of the document.

DocumentInputConfig

Input configuration of a Document.

JSON representation
{
  "gcsSource": {
    object(GcsSource)
  }
}
Fields
gcsSource

object(GcsSource)

The Google Cloud Storage location of the document file. Only a single path should be given. Max supported size: 512MB. Supported extensions: .PDF.

Row

A representation of a row in a relational table.

JSON representation
{
  "columnSpecIds": [
    string
  ],
  "values": [
    value
  ]
}
Fields
columnSpecIds[]

string

The resource IDs of the column specs describing the columns of the row. If set must contain, but possibly in a different order, all input feature

columnSpecIds of the Model this row is being passed to. Note: The below values field must match order of this field, if this field is set.

values[]

value (Value format)

Required. The values of the row cells, given in the same order as the columnSpecIds, or, if not set, then in the same order as input feature

columnSpecs of the Model this row is being passed to.

AnnotationPayload

Contains annotation information that is relevant to AutoML.

JSON representation
{
  "annotationSpecId": string,
  "displayName": string,

  // Union field detail can be only one of the following:
  "classification": {
    object(ClassificationAnnotation)
  },
  "textExtraction": {
    object(TextExtractionAnnotation)
  },
  "textSentiment": {
    object(TextSentimentAnnotation)
  }
  // End of list of possible types for union field detail.
}
Fields
annotationSpecId

string

Output only . The resource ID of the annotation spec that this annotation pertains to. The annotation spec comes from either an ancestor dataset, or the dataset that was used to train the model in use.

displayName

string

Output only. The value of displayName when the model was trained. Because this field returns a value at model training time, for different models trained using the same dataset, the returned value could be different as model owner could update the displayName between any two model training.

Union field detail. Output only . Additional information about the annotation specific to the AutoML domain. detail can be only one of the following:
classification

object(ClassificationAnnotation)

Annotation details for classification predictions.

textExtraction

object(TextExtractionAnnotation)

Annotation details for text extraction.

textSentiment

object(TextSentimentAnnotation)

Annotation details for text sentiment.

ClassificationAnnotation

Contains annotation details specific to classification.

JSON representation
{
  "score": number
}
Fields
score

number

Output only. A confidence estimate between 0.0 and 1.0. A higher value means greater confidence that the annotation is positive. If a user approves an annotation as negative or positive, the score value remains unchanged. If a user creates an annotation, the score is 0 for negative or 1 for positive.

TextExtractionAnnotation

Annotation for identifying spans of text.

JSON representation
{
  "score": number,
  "textSegment": {
    object(TextSegment)
  }
}
Fields
score

number

Output only. A confidence estimate between 0.0 and 1.0. A higher value means greater confidence in correctness of the annotation.

textSegment

object(TextSegment)

Required. The part of the original text to which this annotation pertains.

TextSegment

A contiguous part of a text (string), assuming it has an UTF-8 NFC encoding.

JSON representation
{
  "content": string,
  "startOffset": string,
  "endOffset": string
}
Fields
content

string

Output only. The content of the TextSegment.

startOffset

string (int64 format)

Required. Zero-based character index of the first character of the text segment (counting characters from the beginning of the text).

endOffset

string (int64 format)

Required. Zero-based character index of the first character past the end of the text segment (counting character from the beginning of the text). The character at the endOffset is NOT included in the text segment.

TextSentimentAnnotation

Contains annotation details specific to text sentiment.

JSON representation
{
  "sentiment": number
}
Fields
sentiment

number

Output only. The sentiment with the semantic, as given to the AutoMl.ImportData when populating the dataset from which the model used for the prediction had been trained. The sentiment values are between 0 and Dataset.text_sentiment_dataset_metadata.sentiment_max (inclusive), with higher value meaning more positive sentiment. They are completely relative, i.e. 0 means least positive sentiment and sentimentMax means the most positive from the sentiments present in the train data. Therefore e.g. if train data had only negative sentiment, then sentimentMax, would be still negative (although least negative). The sentiment shouldn't be confused with "score" or "magnitude" from the previous Natural Language Sentiment Analysis API.

Was this page helpful? Let us know how we did:

Send feedback about...

AutoML Natural Language Sentiment Analysis