( projectId = 'YOUR_PROJECT_ID', computeRegion = 'YOUR_REGION_NAME', datasetId = 'YOUR_DATASET_ID', tableId = 'TABLE_ID', columnId = 'COLUMN_ID', modelName = 'MODEL_NAME', trainBudget = 'TRAIN_BUDGET' )
| 14 | |
| 15 | 'use strict'; |
| 16 | async function main( |
| 17 | projectId = 'YOUR_PROJECT_ID', |
| 18 | computeRegion = 'YOUR_REGION_NAME', |
| 19 | datasetId = 'YOUR_DATASET_ID', |
| 20 | tableId = 'TABLE_ID', |
| 21 | columnId = 'COLUMN_ID', |
| 22 | modelName = 'MODEL_NAME', |
| 23 | trainBudget = 'TRAIN_BUDGET' |
| 24 | ) { |
| 25 | // [START automl_tables_create_model] |
| 26 | const automl = require('@google-cloud/automl'); |
| 27 | const client = new automl.v1beta1.AutoMlClient(); |
| 28 | |
| 29 | /** |
| 30 | * Demonstrates using the AutoML client to create a model. |
| 31 | * TODO(developer): Uncomment the following lines before running the sample. |
| 32 | */ |
| 33 | // const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project"; |
| 34 | // const computeRegion = '[REGION_NAME]' e.g., "us-central1"; |
| 35 | // const datasetId = '[DATASET_ID]' e.g., "TBL2246891593778855936"; |
| 36 | // const tableId = '[TABLE_ID]' e.g., "1991013247762825216"; |
| 37 | // const columnId = '[COLUMN_ID]' e.g., "773141392279994368"; |
| 38 | // const modelName = '[MODEL_NAME]' e.g., "testModel"; |
| 39 | // const trainBudget = '[TRAIN_BUDGET]' e.g., "1000", |
| 40 | // `Train budget in milli node hours`; |
| 41 | |
| 42 | // A resource that represents Google Cloud Platform location. |
| 43 | const projectLocation = client.locationPath(projectId, computeRegion); |
| 44 | |
| 45 | // Get the full path of the column. |
| 46 | const columnSpecId = client.columnSpecPath( |
| 47 | projectId, |
| 48 | computeRegion, |
| 49 | datasetId, |
| 50 | tableId, |
| 51 | columnId |
| 52 | ); |
| 53 | |
| 54 | // Set target column to train the model. |
| 55 | const targetColumnSpec = {name: columnSpecId}; |
| 56 | |
| 57 | // Set tables model metadata. |
| 58 | const tablesModelMetadata = { |
| 59 | targetColumnSpec: targetColumnSpec, |
| 60 | trainBudgetMilliNodeHours: trainBudget, |
| 61 | }; |
| 62 | |
| 63 | // Set datasetId, model name and model metadata for the dataset. |
| 64 | const myModel = { |
| 65 | datasetId: datasetId, |
| 66 | displayName: modelName, |
| 67 | tablesModelMetadata: tablesModelMetadata, |
| 68 | }; |
| 69 | |
| 70 | // Create a model with the model metadata in the region. |
| 71 | client |
| 72 | .createModel({parent: projectLocation, model: myModel}) |
| 73 | .then(responses => { |
no outgoing calls
no test coverage detected