Class Model (7.3.0)

Model objects are returned by methods such as and .

Inheritance

EventEmitter > ServiceObject > Model

Package

@google-cloud/bigquery

Example


const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');

const model = dataset.model('my-model');

Constructors

(constructor)(dataset, id)

constructor(dataset: Dataset, id: string);

Constructs a new instance of the Model class

Parameters
NameDescription
dataset Dataset
id string

Properties

bigQuery

bigQuery: BigQuery;

dataset

dataset: Dataset;

Methods

createExtractJob(destination, options)

createExtractJob(destination: string | File, options?: CreateExtractJobOptions): Promise<JobResponse>;

Export model to Cloud Storage.

See Jobs: insert API Documentation

Parameters
NameDescription
destination string | File

Where the model should be exported to. A string or object.

options CreateExtractJobOptions

The configuration object. For all extract job options, see [CreateExtractJobOptions]https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationExtract.

Returns
TypeDescription
Promise<JobResponse>

{Promise

Example

const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');

const extractedModel = 'gs://my-bucket/extracted-model';

function callback(err, job, apiResponse) {
  // `job` is a Job object that can be used to check the status of the
  // request.
}

//-
// To use the default options, just pass a string or a {@link
https://googleapis.dev/nodejs/storage/latest/File.html File}
object.
//
// Note: The default format is 'ML_TF_SAVED_MODEL'.
//-
model.createExtractJob(extractedModel, callback);

//-
// If you need more customization, pass an `options` object.
//-
const options = {
  format: 'ML_TF_SAVED_MODEL',
  jobId: '123abc'
};

model.createExtractJob(extractedModel, options, callback);

//-
// If the callback is omitted, we'll return a Promise.
//-
model.createExtractJob(extractedModel, options).then((data) => {
  const job = data[0];
  const apiResponse = data[1];
});

createExtractJob(destination, options, callback)

createExtractJob(destination: string | File, options: CreateExtractJobOptions, callback: JobCallback): void;
Parameters
NameDescription
destination string | File
options CreateExtractJobOptions
callback JobCallback
Returns
TypeDescription
void

createExtractJob(destination, callback)

createExtractJob(destination: string | File, callback: JobCallback): void;
Parameters
NameDescription
destination string | File
callback JobCallback
Returns
TypeDescription
void

extract(destination, options)

extract(destination: string | File, options?: CreateExtractJobOptions): Promise<JobMetadataResponse>;

Export model to Cloud Storage.

Parameters
NameDescription
destination string | File

Where the model should be exported to. A string or object.

options CreateExtractJobOptions

The configuration object. For all extract job options, see [CreateExtractJobOptions]https://cloud.google.com/bigquery/docs/reference/rest/v2/Job#JobConfigurationExtract.

Returns
TypeDescription
Promise<JobMetadataResponse>

{Promise

Example

const {BigQuery} = require('@google-cloud/bigquery');
const bigquery = new BigQuery();
const dataset = bigquery.dataset('my-dataset');
const model = dataset.model('my-model');

const extractedModel = 'gs://my-bucket/extracted-model';


//-
function callback(err, job, apiResponse) {
  // `job` is a Job object that can be used to check the status of the
  // request.
}

//-
// To use the default options, just pass a string or a {@link
https://googleapis.dev/nodejs/storage/latest/File.html File}
object.
//
// Note: The default format is 'ML_TF_SAVED_MODEL'.
//-
model.createExtractJob(extractedModel, callback);

//-
// If you need more customization, pass an `options` object.
//-
const options = {
  format: 'ML_TF_SAVED_MODEL',
  jobId: '123abc'
};

model.createExtractJob(extractedModel, options, callback);

//-
// If the callback is omitted, we'll return a Promise.
//-
model.createExtractJob(extractedModel, options).then((data) => {
  const job = data[0];
  const apiResponse = data[1];
});

extract(destination, options, callback)

extract(destination: string | File, options: CreateExtractJobOptions, callback?: JobMetadataCallback): void;
Parameters
NameDescription
destination string | File
options CreateExtractJobOptions
callback JobMetadataCallback
Returns
TypeDescription
void

extract(destination, callback)

extract(destination: string | File, callback?: JobMetadataCallback): void;
Parameters
NameDescription
destination string | File
callback JobMetadataCallback
Returns
TypeDescription
void