Class AutoMLTextTrainingJob (0.7.1)

AutoMLTextTrainingJob(
    display_name: str,
    prediction_type: str,
    multi_label: bool = False,
    sentiment_max: int = 10,
    project: Optional[str] = None,
    location: Optional[str] = None,
    credentials: Optional[google.auth.credentials.Credentials] = None,
    training_encryption_spec_key_name: Optional[str] = None,
    model_encryption_spec_key_name: Optional[str] = None,
)

Constructs a AutoML Text Training Job.

Parameters

Name Description
display_name str

Required. The user-defined name of this TrainingPipeline.

prediction_type str

The type of prediction the Model is to produce, one of: "classification" - A classification model analyzes text data and returns a list of categories that apply to the text found in the data. AI Platform offers both single-label and multi-label text classification models. "extraction" - An entity extraction model inspects text data for known entities referenced in the data and labels those entities in the text. "sentiment" - A sentiment analysis model inspects text data and identifies the prevailing emotional opinion within it, especially to determine a writer's attitude as positive, negative, or neutral.

multi_label bool

Required and only applicable for text classification task. If false, a single-label (multi-class) Model will be trained (i.e. assuming that for each text snippet just up to one annotation may be applicable). If true, a multi-label Model will be trained (i.e. assuming that for each text snippet multiple annotations may be applicable).

sentiment_max int

Required and only applicable for sentiment task. A sentiment is expressed as an integer ordinal, where higher value means a more positive sentiment. The range of sentiments that will be used is between 0 and sentimentMax (inclusive on both ends), and all the values in the range must be represented in the dataset before a model can be created. Only the Annotations with this sentimentMax will be used for training. sentimentMax value must be between 1 and 10 (inclusive).

project str

Optional. Project to run training in. Overrides project set in aiplatform.init.

location str

Optional. Location to run training in. Overrides location set in aiplatform.init.

credentials auth_credentials.Credentials

Optional. Custom credentials to use to run call training service. Overrides credentials set in aiplatform.init.

training_encryption_spec_key_name Optional[str]

Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the training pipeline. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, this TrainingPipeline will be secured by this key. Note: Model trained by this TrainingPipeline is also secured by this key if model_to_upload is not set separately. Overrides encryption_spec_key_name set in aiplatform.init.

model_encryption_spec_key_name Optional[str]

Optional. The Cloud KMS resource identifier of the customer managed encryption key used to protect the model. Has the form: projects/my-project/locations/my-region/keyRings/my-kr/cryptoKeys/my-key. The key needs to be in the same region as where the compute resource is created. If set, the trained Model will be secured by this key. Overrides encryption_spec_key_name set in aiplatform.init.

Inheritance

builtins.object > google.cloud.aiplatform.base.AiPlatformResourceNoun > builtins.object > google.cloud.aiplatform.base.FutureManager > google.cloud.aiplatform.base.AiPlatformResourceNounWithFutureManager > google.cloud.aiplatform.training_jobs._TrainingJob > AutoMLTextTrainingJob

Methods

run

run(
    dataset: google.cloud.aiplatform.datasets.text_dataset.TextDataset,
    training_fraction_split: float = 0.8,
    validation_fraction_split: float = 0.1,
    test_fraction_split: float = 0.1,
    model_display_name: Optional[str] = None,
    sync: bool = True,
)

Runs the training job and returns a model.

Data fraction splits: Any of training_fraction_split, validation_fraction_split and test_fraction_split may optionally be provided, they must sum to up to 1. If the provided ones sum to less than 1, the remainder is assigned to sets as decided by AI Platform. If none of the fractions are set, by default roughly 80% of data will be used for training, 10% for validation, and 10% for test.

Parameters
Name Description
dataset datasets.TextDataset

Required. The dataset within the same Project from which data will be used to train the Model. The Dataset must use schema compatible with Model being trained, and what is compatible should be described in the used TrainingPipeline's [training_task_definition] [google.cloud.aiplatform.v1beta1.TrainingPipeline.training_task_definition].

model_display_name str

Optional. The display name of the managed AI Platform Model. The name can be up to 128 characters long and can consist of any UTF-8 characters. If not provided upon creation, the job's display_name is used.

sync bool

Whether to execute this method synchronously. If False, this method will be executed in concurrent Future and any downstream object will be immediately returned and synced when the Future has completed.

Exceptions
Type Description
RuntimeErro if Training job has already been run or is waiting to run.:
Returns
Type Description
model The trained AI Platform Model resource.