Skip to content

Commit 9cdc10a

Browse files
committed
Set model reference
1 parent ffbb054 commit 9cdc10a

File tree

1 file changed

+18
-31
lines changed

1 file changed

+18
-31
lines changed

notebooks/1_task_and_model.ipynb

Lines changed: 18 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -165,34 +165,35 @@
165165
"outputs": [],
166166
"source": [
167167
"# TO COMPLETE\n",
168+
"\n",
168169
"data_schema = ml3_models.DataSchema(\n",
169170
" columns=[\n",
170171
" # METADATA - SAMPLE ID\n",
171172
" ml3_models.ColumnInfo(\n",
172173
" name='sample_id',\n",
173-
" data_type='float',\n",
174-
" role='id',\n",
174+
" data_type=ml3_enums.DataType.STRING,\n",
175+
" role=ml3_enums.ColumnRole.ID,\n",
175176
" is_nullable=False\n",
176177
" ),\n",
177178
" # METADATA - TIMESTAMP\n",
178179
" ml3_models.ColumnInfo(\n",
179180
" name='timestamp',\n",
180-
" data_type='string',\n",
181-
" role='time_id',\n",
181+
" data_type=ml3_enums.DataType.FLOAT,\n",
182+
" role=ml3_enums.ColumnRole.TIME_ID,\n",
182183
" is_nullable=False\n",
183184
" ),\n",
184185
" # FEATURE\n",
185186
" ml3_models.ColumnInfo(\n",
186187
" name='feature_0',\n",
187-
" data_type='float',\n",
188-
" role='input',\n",
188+
" data_type=ml3_enums.DataType.FLOAT,\n",
189+
" role=ml3_enums.ColumnRole.INPUT,\n",
189190
" is_nullable=False\n",
190191
" ),\n",
191192
" # TARGET\n",
192193
" ml3_models.ColumnInfo(\n",
193194
" name='target',\n",
194-
" data_type='float',\n",
195-
" role='target',\n",
195+
" data_type=ml3_enums.DataType.FLOAT,\n",
196+
" role=ml3_enums.ColumnRole.TARGET,\n",
196197
" is_nullable=False\n",
197198
" )\n",
198199
" ]\n",
@@ -209,7 +210,9 @@
209210
"**Historical data**\n",
210211
"\n",
211212
"Ok, now that you inserted the data schema for your Task you are able to upload data.\n",
212-
"The first category of data that we suggest you to send is the *historical* that will improve retraining report quality.\n",
213+
"There are two classes of data: *historical* and *production*.\n",
214+
"Historical data represents data you had before the model was in production while, production data are data that comes from the production environment.\n",
215+
"Model reference data are selected from historical one by specifying the time range.\n",
213216
"\n",
214217
"This is the first time you send data to ML cube Platform, therefore, we have some things to explain:\n",
215218
"\n",
@@ -229,7 +232,7 @@
229232
"outputs": [],
230233
"source": [
231234
"# TO COMPLETE\n",
232-
"inputs_data_soure = ml3_models.LocalDataSource(\n",
235+
"inputs_data_source = ml3_models.LocalDataSource(\n",
233236
" data_structure=ml3_enums.DataStructure.TABULAR,\n",
234237
" file_path=\"path/to/file.csv\",\n",
235238
" file_type=ml3_enums.FileType.CSV,\n",
@@ -248,7 +251,7 @@
248251
"logger.info(f'API - Add historical data')\n",
249252
"job_id = ml3_client.add_historical_data(\n",
250253
" task_id=task_id,\n",
251-
" inputs=ml3_models.TabularData(source=inputs_data_soure),\n",
254+
" inputs=ml3_models.TabularData(source=inputs_data_source),\n",
252255
" target=ml3_models.TabularData(source=target_data_source)\n",
253256
")\n",
254257
"logger.info(f'Job created, id {job_id}')\n",
@@ -299,7 +302,7 @@
299302
"**Model reference**\n",
300303
"\n",
301304
"In the previous cell you created the model but it is not complete because it misses the training dataset that in ML cube Platform is called *reference*.\n",
302-
"Here you add the reference data of the model by sending its data like you did for the historical data."
305+
"Here you add the reference data of the model by specifying the time range, ML cube Platform automatically select from all the previously uploaded data the reference data."
303306
]
304307
},
305308
{
@@ -310,27 +313,11 @@
310313
"outputs": [],
311314
"source": [
312315
"# TO COMPLETE\n",
313-
"inputs_data_soure = ml3_models.LocalDataSource(\n",
314-
" data_structure=ml3_enums.DataStructure.TABULAR,\n",
315-
" file_path=\"path/to/file.csv\",\n",
316-
" file_type=ml3_enums.FileType.CSV,\n",
317-
" is_folder=False,\n",
318-
" folder_type=None\n",
319-
")\n",
320-
"target_data_source = ml3_models.GCSDataSource(\n",
321-
" dataset_type=ml3_enums.DatasetType.TABULAR,\n",
322-
" object_path=\"gs://path/to/file.csv\",\n",
323-
" credentials_id='gcp_credentials_id',\n",
324-
" file_type=ml3_enums.FileType.CSV,\n",
325-
" is_folder=False,\n",
326-
" folder_type=None\n",
327-
")\n",
328-
"\n",
329316
"logger.info(f'API - Add model reference')\n",
330-
"job_id = ml3_client.add_model_reference(\n",
317+
"job_id = ml3_client.set_model_reference(\n",
331318
" model_id=model_id,\n",
332-
" inputs=ml3_models.TabularData(source=inputs_data_soure),\n",
333-
" target=ml3_models.TabularData(source=target_data_source)\n",
319+
" from_timestamp=0.,\n",
320+
" to_timestamp=0.,\n",
334321
")\n",
335322
"logger.info(f'Job created, id {job_id}')\n",
336323
"\n",

0 commit comments

Comments
 (0)