Main Content

mrm.execution.checkModel

Check Modelscape model validity

Since R2023a

    Description

    result = mrm.execution.checkModel(model,inputData) checks the validity of a Modelscape™ model by creating several test methods. The function determines whether the Modelscape model has the right shape for the input of the original model. The function returns the result of the tests in result. This function requires the Modelscape for MATLAB® support package.

    example

    result = mrm.execution.checkModel(model,inputData,parameterData) specifies additional parameters for the model.

    example

    Examples

    collapse all

    Create a Modelscape model as a subclass of the mrm.execution.Model class.

    The model takes the inputs X1, and X2, as well as an optional parameter intercept. The function computes the output Y as the value of exp(intercept + alpha1*X1 + alpha2*X2).

    The Modelscape model must also implement three methods for specifying the inputs and the outputs of the model: getInputs, getParameters, and getOutputs. For more details, see the Model Implementation for Modelscape Deploy

    classdef glmModel < mrm.execution.Model
        %   implement simple GLM with two inputs X1 and X2 that computes
        %   Y = exp(intercept + alpha1*X1 + alpha2*X2)
        properties
            alpha1 = 1
            alpha2 = 2
        end
    
    
        methods
            
             function parameters = getInputs(~)
                doubleDatatype = struct( ...
                    "name", "double");
                parameters = struct( ...
                    "name", {"X1","X2"}, ...
                    "dataType", {doubleDatatype, doubleDatatype});
            end
    
            function parameters = getParameters(~)
                doubleDatatype = struct( ...
                    "name", "double");
                parameters = struct( ...
                    "name", {"intercept"}, ...
                    "dataType", {doubleDatatype});
            end
    
            function parameters = getOutputs(~)
                doubleDatatype = struct( ...
                    "name", "double");
                parameters = struct( ...
                    "name", {"Y"}, ...
                    "dataType", {doubleDatatype});
            end
    
            function [outputs,diagnostics,batchDiagnostics] = evaluate(this,inputs,parameters)
                outputs = table( ...
                    exp(parameters.intercept +  this.alpha1*inputs.X1 + this.alpha2*inputs.X2), ...
                    'VariableNames', {'Y'}, ...
                    'RowNames', inputs.Properties.RowNames);
                rawDiagnostics = [inputs.Properties.RowNames repmat({struct()},numel(inputs.Properties.RowNames),1)]';
                diagnostics = struct(rawDiagnostics{:});
                batchDiagnostics = struct();
            end
    
        end
    end

    Validate the custom model.

    result = mrm.execution.checkModel(model, inputData, parameterData);

    Input Arguments

    collapse all

    Modelscape model, specified as a subclass of the mrm.execution.Model class. This model must also implement three methods for specifying the inputs and the outputs of the model: getInputs, getParameters, and getOutputs. For more details, see Model Implementation for Modelscape Deploy.

    Original model inputs, specified as a table.

    Data Types: table

    Original model parameters, specified as a structure.

    Data Types: struct

    Output Arguments

    collapse all

    Test results, returned as a matlab.unittest.TestResult class. The results include information describing whether the test pass, fail, or run to completion, as well as the duration of each test.

    Version History

    Introduced in R2023a