주요 콘텐츠

fit

R2026b

Fit existing model to new or existing data, and provide summary statistics

    Description

    [outmodel,statistics] = fit(inmodel,X,Y) fits the model to the specified data.

    example

    [outmodel,statistics] = fit(inmodel) refits the model if data for fit has already been supplied.

    example

    Examples

    collapse all

    Fit a model to new input and response data using the fit method.

    Create an RBF model with two inputs, generate sample data, and fit the model.

    mdl = mbcCreateModel('RBF', 2);
    
    X = [rand(50,1)*5000 + 1000, rand(50,1)*90 + 10];
    Y = 0.002*X(:,1) + 0.5*X(:,2) + randn(50,1)*2;
    
    [fittedModel, statistics] = fit(mdl, X, Y)

    Refit a model that already has data assigned, for example after modifying the fit algorithm.

    Create a polynomial model with named inputs, fit it to data, change the fit algorithm, then refit.

    Inputs = mbcinputs('Symbol', {'N','L'}', ...
        'Name', {'Speed','Load'}', ...
        'Range', {[800 5000],[0.1 1]}');
    mdl = mbcCreateModel('Polynomial', Inputs);
    
    X = [rand(80,1)*4200 + 800, rand(80,1)*0.9 + 0.1];
    Y = 0.002*X(:,1) + 3*X(:,2) + randn(80,1)*0.5;
    [mdl, stats] = fit(mdl, X, Y);
    
    % Change the fit algorithm and refit with the same data
    mdl.FitAlgorithm = 'Minimize PRESS';
    [mdl, stats] = fit(mdl)

    Fit a model to data and then inspect the goodness-of-fit using summary statistics.

    Create a Gaussian Process model, fit it to multivariate data, and view the summary statistics.

    mdl = mbcCreateModel('Gaussian Process Model', 3);
    
    X = rand(100, 3) .* [5000 100 50];
    Y = 0.001*X(:,1).^2 + 0.3*X(:,2) - 0.5*X(:,3) + randn(100,1)*5;
    
    [fittedModel, statistics] = fit(mdl, X, Y);
    
    s = SummaryStatistics(fittedModel)

    Input Arguments

    collapse all

    Model being fitted, specified as an mbcmodel.model object.

    Data being used to fit the model, specified as a matrix.

    Output Arguments

    collapse all

    Fitted model, returned as an mbcmodel.model object.

    Statistics of the fitted model, returned as a structure.

    More About

    collapse all

    Version History

    Introduced in R2007a