我创建了一个数据集并在automl表上,我想训练模型,但是我在文档中看不到 tableId 和 columnId 在文档的任何地方,我都能找到这些参数的定义。 请问如何通过API创建和训练模型?
const automl = require('@google-cloud/automl');
const client = new automl.v1beta1.AutoMlClient();
/**
* Demonstrates using the AutoML client to create a model.
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = '[PROJECT_ID]' e.g., "my-gcloud-project";
// const computeRegion = '[REGION_NAME]' e.g., "us-central1";
// const datasetId = '[DATASET_ID]' e.g., "TBL2246891593778855936";
// const tableId = '[TABLE_ID]' e.g., "1991013247762825216";
// const columnId = '[COLUMN_ID]' e.g., "773141392279994368";
// const modelName = '[MODEL_NAME]' e.g., "testModel";
// const trainBudget = '[TRAIN_BUDGET]' e.g., "1000",
// `Train budget in milli node hours`;
// A resource that represents Google Cloud Platform location.
const projectLocation = client.locationPath(projectId, computeRegion);
// Get the full path of the column.
const columnSpecId = client.columnSpecPath(
projectId,
computeRegion,
datasetId,
tableId,
columnId
);
// Set target column to train the model.
const targetColumnSpec = {name: columnSpecId};
// Set tables model metadata.
const tablesModelMetadata = {
targetColumnSpec: targetColumnSpec,
trainBudgetMilliNodeHours: trainBudget,
};
// Set datasetId, model name and model metadata for the dataset.
const myModel = {
datasetId: datasetId,
displayName: modelName,
tablesModelMetadata: tablesModelMetadata,
};
// Create a model with the model metadata in the region.
client
.createModel({parent: projectLocation, model: myModel})
.then(responses => {
const initialApiResponse = responses[1];
console.log(`Training operation name: ${initialApiResponse.name}`);
console.log('Training started...');
})
.catch(err => {
console.error(err);
});