Contenuto principale

Costruzione e valutazione del modello

Generazione di dati sintetici, selezione delle feature, ingegneria delle feature, selezione dei modelli, ottimizzazione degli iperparametri, validazione incrociata, diagnostica dei residui e grafici

Quando si costruisce un modello di regressione di alta qualità, è importante selezionare le feature (o predittori) corretti, ottimizzare gli iperparametri (parametri del modello non adattati ai dati) e valutare le ipotesi del modello attraverso la diagnostica dei residui. È possibile ottimizzare gli iperparametri iterando tra la scelta dei loro valori ed eseguire la validazione incrociata di un modello utilizzando tali scelte. Questo processo produce diversi modelli e il migliore tra questi potrebbe essere quello che minimizza l'errore di generalizzazione stimato.

È possibile eseguire le seguenti operazioni per costruire e valutare i modelli di regressione:

  • Generare dati sintetici a partire da un insieme di dati esistente prima dell'addestramento di un modello di regressione utilizzando synthesizeTabularData, binningTabularSynthesizer o smoteTabularSynthesizer.

  • Progettare nuove feature prima dell'addestramento di un modello di regressione utilizzando genrfeatures.

  • Costruire e valutare i modelli di regressione in modo interattivo utilizzando l'app Regression Learner.

  • Selezionare automaticamente un modello con iperparametri ottimizzati utilizzando fitrauto. La funzione prova una selezione di tipi di modello di regressione con diversi valori di iperparametri e restituisce un modello finale che dovrebbe garantire buone prestazioni. Utilizzare fitrauto quando non si è sicuri di quale tipo di modello di regressione sia più adatto ai dati.

  • Ottimizzare gli iperparametri di un modello specifico selezionando i valori degli iperparametri ed eseguire la validazione incrociata del modello utilizzando tali valori. Ad esempio, per ottimizzare un modello SVM, scegliere un insieme di constraint box e scale del kernel, eseguire la validazione incrociata del modello per ciascuna coppia di valori, quindi confrontare le rispettive stime dell'errore quadratico medio ottenute tramite validazione incrociata a 10 partizioni. Alcune funzioni di regressione non parametrica in Statistics and Machine Learning Toolbox™ offrono l'ottimizzazione automatica degli iperparametri tramite ottimizzazione bayesiana, ricerca su griglia o ricerca casuale. bayesopt, la funzione principale per l'implementazione dell'ottimizzazione bayesiana, è sufficientemente flessibile da poter essere utilizzata anche in molte altre applicazioni. Per ulteriori dettagli, vedere Bayesian Optimization Workflow.

  • Interpretare un modello di regressione utilizzando lime, shapley e plotPartialDependence.

  • Valutare le prestazioni di un modello di regressione su sezioni distinte di dati utilizzando sliceMetrics.

App

Regression LearnerTrain regression models to predict data using supervised machine learning

Funzioni

espandi tutto

synthesizeTabularDataSynthesize tabular data (Da R2024b)
binningTabularSynthesizerBinning-based synthesizer for tabular data synthesis (Da R2024b)
smoteTabularSynthesizerSMOTE-based synthesizer for tabular data synthesis (Da R2026a)
synthesizeTabularDataSynthesize tabular data using binning-based or SMOTE-based synthesizer (Da R2024b)
mmdtestTwo-sample multivariate hypothesis test using maximum mean discrepancy (MMD) (Da R2024b)
knntestTwo-sample multivariate hypothesis test using k-nearest neighbors (KNN) (Da R2025a)
fsrftestUnivariate feature ranking for regression using F-tests
fsrmrmrRank features for regression using minimum redundancy maximum relevance (MRMR) algorithm (Da R2022a)
fsrncaFeature selection using neighborhood component analysis for regression
oobPermutedPredictorImportanceOut-of-bag predictor importance estimates for random forest of regression trees by permutation
partialDependenceCompute partial dependence
permutationImportancePredictor importance by permutation (Da R2024a)
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
predictorImportanceEstimates of predictor importance for regression tree
predictorImportanceEstimates of predictor importance for regression ensemble of decision trees
relieffRank importance of predictors using ReliefF or RReliefF algorithm
selectFeaturesSelect important features for NCA classification or regression (Da R2023b)
sequentialfsSequential feature selection using custom criterion
stepwiselmPerform stepwise regression
stepwiseglmCreate generalized linear regression model by stepwise regression
genrfeaturesPerform automated feature engineering for regression (Da R2021b)
describeDescribe generated features
transformTransform new data using generated features
fitrautoAutomatically select regression model with optimized hyperparameters
bayesoptSelect optimal machine learning hyperparameters using Bayesian optimization
hyperparametersVariable descriptions for optimizing a fit function
optimizableVariableVariable description for bayesopt or other optimizers
learnersizeCompact size of trained machine learning model object (Da R2024b)
plotPlot aggregated hyperparameter optimization results (Da R2024b)
resumeResume hyperparameter optimization problems (Da R2024b)
summarySummary table for AggregateBayesianOptimization object (Da R2024b)

Per dati indipendenti dal tempo

crossvalEstimate loss using cross-validation
cvpartitionPartition data for cross-validation
repartitionRepartition data for cross-validation
summarySummarize cross-validation partition with stratification or grouping variable (Da R2025a)
testTest indices for cross-validation
trainingTraining indices for cross-validation

Per dati delle serie temporali

tspartitionPartition time series data for cross-validation (Da R2022b)
testTest indices for time series cross-validation (Da R2022b)
trainingTraining indices for time series cross-validation (Da R2022b)

Spiegazioni locali interpretabili e indipendenti dal modello (LIME)

limeLocal interpretable model-agnostic explanations (LIME)
fitFit simple model of local interpretable model-agnostic explanations (LIME)
plotPlot results of local interpretable model-agnostic explanations (LIME)

Valori di Shapley

shapleyShapley values
fitCompute Shapley values for query points
plotPlot Shapley values using bar graphs
boxchartVisualize Shapley values using box charts (box plots) (Da R2024a)
plotDependencePlot dependence of Shapley values on predictor values (Da R2024b)
swarmchartVisualize Shapley values using swarm scatter charts (Da R2024a)

Dipendenza parziale

partialDependenceCompute partial dependence
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
sliceMetricsMetrics on data slices for machine learning model (Da R2026a)
plotPlot bar graph of slice metric (Da R2026a)
reportGenerate slice metrics report (Da R2026a)
coefCIConfidence intervals of coefficient estimates of linear regression model
coefTestLinear hypothesis test on linear regression model coefficients
dwtestDurbin-Watson test with linear regression model object
plotScatter plot or added variable plot of linear regression model
plotAddedAdded variable plot of linear regression model
plotAdjustedResponseAdjusted response plot of linear regression model
plotDiagnosticsPlot observation diagnostics of linear regression model
plotEffectsPlot main effects of predictors in linear regression model
plotInteractionPlot interaction effects of two predictors in linear regression model
plotResidualsPlot residuals of linear regression model
plotSlicePlot of slices through fitted linear regression surface
coefCIConfidence intervals of coefficient estimates of generalized linear regression model
coefTestLinear hypothesis test on generalized linear regression model coefficients
devianceTestAnalysis of deviance for generalized linear regression model
plotDiagnosticsPlot observation diagnostics of generalized linear regression model
plotResidualsPlot residuals of generalized linear regression model
plotSlicePlot of slices through fitted generalized linear regression surface
coefCIConfidence intervals of coefficient estimates of nonlinear regression model
coefTestLinear hypothesis test on nonlinear regression model coefficients
plotDiagnosticsPlot diagnostics of nonlinear regression model
plotSlicePlot of slices through fitted nonlinear regression surface
linhyptestLinear hypothesis test

Oggetti

espandi tutto

FeatureSelectionNCARegressionFeature selection for regression using neighborhood component analysis (NCA)
FeatureTransformerGenerated feature transformations
BayesianOptimizationBayesian optimization results
HyperparameterOptimizationOptionsHyperparameter optimization options (Da R2024b)
AggregateBayesianOptimizationAggregate Bayesian optimization results (Da R2024b)
SupervisedLearningBayesianOptimizationResults of Bayesian optimization for supervised learning model (Da R2026a)

Argomenti

Workflow dell'app Regression Learner

Selezione delle feature

Ingegneria delle feature

  • Automated Feature Engineering for Regression
    Use genrfeatures to engineer new features before training a regression model. Before making predictions on new data, apply the same feature transformations to the new data set.

Selezione automatica dei modelli

Ottimizzazione degli iperparametri

Validazione incrociata

Interpretazione del modello

Stima dell'incertezza

Diagnostica del modello lineare

  • Interpret Linear Regression Results
    Display and interpret linear regression output statistics.
  • Linear Regression
    Fit a linear regression model and examine the result.
  • Linear Regression with Interaction Effects
    Construct and analyze a linear regression model with interaction effects and interpret the results.
  • Summary of Output and Diagnostic Statistics
    Evaluate a fitted model by using model properties and object functions.
  • F-statistic and t-statistic
    In linear regression, the F-statistic is the test statistic for the analysis of variance (ANOVA) approach to test the significance of the model or the components in the model. The t-statistic is useful for making inferences about the regression coefficients.
  • Coefficient of Determination (R-Squared)
    Coefficient of determination (R-squared) indicates the proportionate amount of variation in the response variable y explained by the independent variables X in the linear regression model.
  • Coefficient Standard Errors and Confidence Intervals
    Estimated coefficient variances and covariances capture the precision of regression coefficient estimates.
  • Residuals
    Residuals are useful for detecting outlying y values and checking the linear regression assumptions with respect to the error term in the regression model.
  • Durbin-Watson Test
    The Durbin-Watson test assesses whether or not there is autocorrelation among the residuals of time series data.
  • Cook’s Distance
    Cook's distance is useful for identifying outliers in the X values (observations for predictor variables).
  • Hat Matrix and Leverage
    The hat matrix provides a measure of leverage.
  • Delete-1 Statistics
    Delete-1 change in covariance (CovRatio) identifies the observations that are influential in the regression fit.

Diagnostica del modello lineare generalizzato

  • Generalized Linear Models
    Generalized linear models use linear methods to describe a potentially nonlinear relationship between predictor terms and a response variable.

Diagnostica del modello non lineare

  • Nonlinear Regression
    Parametric nonlinear models represent the relationship between a continuous response variable and one or more continuous predictor variables.