Custom Model Checks

Options
AkshayArora1
AkshayArora1 Partner, Registered Posts: 11 Partner

Can I get some examples of custom model checks

Tagged:

Answers

  • AmandaM
    AmandaM Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 9 Dataiker
    Options

    Hi @AkshayArora1
    ,

    I have provided an example below of a custom python metric and then the corresponding check. The metric returns a boolean if the dataset has been modified that day. The corresponding check will pass if the dataset has been modified that day and fail otherwise.

    Hope this helps!

    ## CUSTOM METRIC ##

    import dataikufrom datetime import datetimedataset = dataiku.Dataset(<YOUR DATASET>)# Define here a function that returns the metric.def process(dataset, partition_id):# dataset is a dataiku.Dataset objectmodifiedDate = dataset.get_files_info()['globalPaths'][0]['lastModified'] / 1000modifiedDate = datetime.utcfromtimestamp(modifiedDate).date()today = datetime.now().date()modified_today = modifiedDate >= todayreturn {'modified_today' : modified_today}
    ## CUSTOM CHECK ##
    import dataikudataset = dataiku.Dataset(<YOUR DATASET>)# Define here a function that returns the outcome of the check.def process(last_values, dataset, partition_id):# last_values is a dict of the last values of the metrics,# with the values as a dataiku.metrics.MetricDataPoint.# dataset is a dataiku.Dataset objectm = dataset.get_last_metric_values()if m.get_metric_by_id('python:modified_today:Python probe')['lastValues'][0]['value'] == 'false':return "ERROR"return 'OK', 'optional message' # or 'WARNING' or 'ERROR'

Setup Info
    Tags
      Help me…