Skip to content

Commit ecc0f18

Browse files
committed
Regen BigQuery Model API classes. (googleapis#493)
* Regen BigQuery Model API classes. This commit is auto-generated by: SYNTHTOOL_GOOGLEAPIS=$HOME/src/googleapis-private python -m synthtool * Update test for Model to new representation of TrainingRun.startTime.
1 parent 0dd27b9 commit ecc0f18

6 files changed

Lines changed: 477 additions & 83 deletions

File tree

bigquery/google/cloud/bigquery_v2/gapic/enums.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ class DataSplitMethod(enum.IntEnum):
4040
NO_SPLIT = 4
4141
AUTO_SPLIT = 5
4242

43+
class DistanceType(enum.IntEnum):
44+
"""
45+
Distance metric used to compute the distance between two points.
46+
47+
Attributes:
48+
DISTANCE_TYPE_UNSPECIFIED (int)
49+
EUCLIDEAN (int): Eculidean distance.
50+
COSINE (int): Cosine distance.
51+
"""
52+
53+
DISTANCE_TYPE_UNSPECIFIED = 0
54+
EUCLIDEAN = 1
55+
COSINE = 2
56+
4357
class LearnRateStrategy(enum.IntEnum):
4458
"""
4559
Indicates the learning rate optimization strategy to use.
@@ -76,11 +90,13 @@ class ModelType(enum.IntEnum):
7690
MODEL_TYPE_UNSPECIFIED (int)
7791
LINEAR_REGRESSION (int): Linear regression model.
7892
LOGISTIC_REGRESSION (int): Logistic regression model.
93+
KMEANS (int): [Beta] K-means clustering model.
7994
"""
8095

8196
MODEL_TYPE_UNSPECIFIED = 0
8297
LINEAR_REGRESSION = 1
8398
LOGISTIC_REGRESSION = 2
99+
KMEANS = 3
84100

85101

86102
class StandardSqlDataType(object):

bigquery/google/cloud/bigquery_v2/proto/model.proto

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ package google.cloud.bigquery.v2;
2020
import "google/cloud/bigquery/v2/model_reference.proto";
2121
import "google/cloud/bigquery/v2/standard_sql.proto";
2222
import "google/protobuf/empty.proto";
23-
import "google/protobuf/field_mask.proto";
23+
import "google/protobuf/timestamp.proto";
2424
import "google/protobuf/wrappers.proto";
2525
import "google/api/annotations.proto";
2626

@@ -176,6 +176,15 @@ message Model {
176176
repeated ConfusionMatrix confusion_matrix_list = 2;
177177
}
178178

179+
// Evaluation metrics for clustering models.
180+
message ClusteringMetrics {
181+
// Davies-Bouldin index.
182+
google.protobuf.DoubleValue davies_bouldin_index = 1;
183+
184+
// Mean of squared distances between each sample to its cluster centroid.
185+
google.protobuf.DoubleValue mean_squared_distance = 2;
186+
}
187+
179188
// Evaluation metrics of a model. These are either computed on all
180189
// training data or just the eval data based on whether eval data was used
181190
// during training.
@@ -189,6 +198,9 @@ message Model {
189198

190199
// Populated for multi-class classification models.
191200
MultiClassClassificationMetrics multi_class_classification_metrics = 3;
201+
202+
// [Beta] Populated for clustering models.
203+
ClusteringMetrics clustering_metrics = 4;
192204
}
193205
}
194206

@@ -254,10 +266,29 @@ message Model {
254266
// Weights associated with each label class, for rebalancing the
255267
// training data.
256268
map<string, double> label_class_weights = 17;
269+
270+
// [Beta] Distance type for clustering models.
271+
DistanceType distance_type = 20;
272+
273+
// [Beta] Number of clusters for clustering models.
274+
int64 num_clusters = 21;
257275
}
258276

259277
// Information about a single iteration of the training run.
260278
message IterationResult {
279+
// Information about a single cluster for clustering model.
280+
message ClusterInfo {
281+
// Centroid id.
282+
int64 centroid_id = 1;
283+
284+
// Cluster radius, the average distance from centroid
285+
// to each point assigned to the cluster.
286+
google.protobuf.DoubleValue cluster_radius = 2;
287+
288+
// Cluster size, the total number of points assigned to the cluster.
289+
google.protobuf.Int64Value cluster_size = 3;
290+
}
291+
261292
// Index of the iteration, 0 based.
262293
google.protobuf.Int32Value index = 1;
263294

@@ -272,14 +303,17 @@ message Model {
272303

273304
// Learn rate used for this iteration.
274305
double learn_rate = 7;
306+
307+
// [Beta] Information about top clusters for clustering models.
308+
repeated ClusterInfo cluster_infos = 8;
275309
}
276310

277311
// Options that were used for this training run, includes
278312
// user specified and default options that were used.
279313
TrainingOptions training_options = 1;
280314

281-
// The start time of this training run, in milliseconds since epoch.
282-
int64 start_time = 2;
315+
// The start time of this training run.
316+
google.protobuf.Timestamp start_time = 8;
283317

284318
// Output of each iteration run, results.size() <= max_iterations.
285319
repeated IterationResult results = 6;
@@ -298,6 +332,9 @@ message Model {
298332

299333
// Logistic regression model.
300334
LOGISTIC_REGRESSION = 2;
335+
336+
// [Beta] K-means clustering model.
337+
KMEANS = 3;
301338
}
302339

303340
// Loss metric to evaluate model training performance.
@@ -311,6 +348,17 @@ message Model {
311348
MEAN_LOG_LOSS = 2;
312349
}
313350

351+
// Distance metric used to compute the distance between two points.
352+
enum DistanceType {
353+
DISTANCE_TYPE_UNSPECIFIED = 0;
354+
355+
// Eculidean distance.
356+
EUCLIDEAN = 1;
357+
358+
// Cosine distance.
359+
COSINE = 2;
360+
}
361+
314362
// Indicates the method to split input data into multiple tables.
315363
enum DataSplitMethod {
316364
DATA_SPLIT_METHOD_UNSPECIFIED = 0;
@@ -413,13 +461,13 @@ message GetModelRequest {
413461
}
414462

415463
message PatchModelRequest {
416-
// Project ID of the model to patch
464+
// Project ID of the model to patch.
417465
string project_id = 1;
418466

419-
// Dataset ID of the model to patch
467+
// Dataset ID of the model to patch.
420468
string dataset_id = 2;
421469

422-
// Model ID of the model to patch
470+
// Model ID of the model to patch.
423471
string model_id = 3;
424472

425473
// Patched model.
@@ -429,13 +477,13 @@ message PatchModelRequest {
429477
}
430478

431479
message DeleteModelRequest {
432-
// Project ID of the requested model.
480+
// Project ID of the model to delete.
433481
string project_id = 1;
434482

435-
// Dataset ID of the requested model.
483+
// Dataset ID of the model to delete.
436484
string dataset_id = 2;
437485

438-
// Model ID of the requested model.
486+
// Model ID of the model to delete.
439487
string model_id = 3;
440488
}
441489

0 commit comments

Comments
 (0)