Time Based Early Stopping for Non-Model Trainer | RandomSearch | teradataml - Example 5.2: Time Based Early Stopping for Non-Model Trainer Function - Teradata Package for Python

Teradata® Package for Python User Guide

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Teradata Package for Python
Release Number
20.00
Published
March 2024
Language
English (United States)
Last Update
2024-04-09
dita:mapPath
nvi1706202040305.ditamap
dita:ditavalPath
plt1683835213376.ditaval
dita:id
rkb1531260709148
Product Category
Teradata Vantage

This example shows time based early stopping for non-model trainer function Antiselect.

  1. Define hyperparameter tuning for Antiselect.
    1. Define the non-model trainer function parameter space.
      >>> non_model_trainer_params = {"data":data, "exclude":(
      ...                             ['petal_length', 'petal_width'], 
      ...                             ['sepal_length', 'sepal_width', 'petal_length'],
      ...                             ['id', 'sepal_length', 'sepal_width'],
      ...                             ['petal_width'], 
      ...                             ['petal_width', 'species'],
      ...                             ['sepal_width', 'petal_length', 'petal_width', 'species'],
      ...                             ['sepal_width', 'petal_length', 'petal_width', 'species', 'id'],
      ...                             ['sepal_length', 'sepal_width'])}
    2. Import non-model trainer function and optimizer.
      >>> from teradataml import Antiselect, RandomSearch
    3. Initialize the GridSearch optimizer with non-model trainer function and parameter space required for non-model training.
      >>> rs_obj = RandomSearch(func=Antiselect, params=non_model_trainer_params, n_iter=5)
  2. Run Antiselect with max_time set to 4 seconds.
    >>> rs_obj.fit(max_time=4, verbose=2)
    Model_id:ANTISELECT_3 - Run time:4.588s - Status:PASS                             
    Model_id:ANTISELECT_2 - Run time:4.619s - Status:PASS                              
    Model_id:ANTISELECT_0 - Run time:4.621s - Status:PASS                              
    Model_id:ANTISELECT_1 - Run time:4.621s - Status:PASS                              
    Computing: |⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫿⫾⫾⫾⫾⫾⫾⫾⫾⫾⫾⫾⫾| 80% - 4/5
  3. View the result of hyperparameter tunning using models property.
    >>> rs_obj.models
          MODEL_ID                                             PARAMETERS    STATUS
    0    ANTISELECT_3    {'data': '"ALICE"."ml__td_sqlmr_out__171014558...    PASS
    1    ANTISELECT_4    {'data': '"ALICE"."ml__td_sqlmr_out__171014558...    SKIP
    2    ANTISELECT_2    {'data': '"ALICE"."ml__td_sqlmr_out__171014558...    PASS
    3    ANTISELECT_0    {'data': '"ALICE"."ml__td_sqlmr_out__171014558...    PASS
    4    ANTISELECT_1    {'data': '"ALICE"."ml__td_sqlmr_out__171014558...    PASS