Main Content

Desarrollo y evaluación de modelos

Selección de características, ingeniería de características, selección de modelos, optimización de hiperparámetros, validación cruzada, diagnósticos de valores residuales y gráficas

Al desarrollar un modelo de regresión de alta calidad, es importante seleccionar las características (o predictores) correctos, ajustar los hiperparámetros (parámetros del modelo no ajustados a los datos) y evaluar los supuestos del modelo a través de diagnósticos de valores residuales.

Puede ajustar los hiperparámetros mediante iteraciones entre la selección de los valores para los mismos y la realización de una validación cruzada de un modelo usando sus propias opciones. Este proceso arroja varios modelos y el mejor de ellos puede ser el que minimice el error de generalización estimado. Por ejemplo, para ajustar un modelo SVM, elija un conjunto de restricciones de cajas y escalas de kernel, realice una validación cruzada de un modelo para cada par de valores y, después, compare las estimaciones de los cuadrados de error medios con validación cruzada de 10 particiones.

Para extraer nuevas características antes de entrenar un modelo de regresión, utilice genrfeatures.

Para desarrollar y evaluar modelos de regresión de forma interactiva, utilice la app Regression Learner.

Para seleccionar automáticamente un modelo con hiperparámetros ajustados, utilice fitrauto. La función prueba una selección de tipos de modelos de regresión con diferentes valores en los hiperparámetros y devuelve un modelo final que se prevé que funcione bien. Utilice fitrauto cuando no sepa con seguridad los tipos de modelos de regresión que mejor se adaptan a sus datos.

Determinadas funciones de regresión no paramétricas de Statistics and Machine Learning Toolbox™ ofrecen un ajuste automático de los hiperparámetros mediante optimización bayesiana, búsqueda por cuadrículas o búsqueda aleatoria. bayesopt, la función principal para implementar la optimización bayesiana, es también lo suficientemente flexible para muchas otras aplicaciones. Para obtener más información, consulte Bayesian Optimization Workflow.

Para interpretar un modelo de regresión, puede utilizar lime, shapley y plotPartialDependence.

Apps

Regression LearnerEntrenar modelos de regresión para predecir datos usando machine learning supervisado

Funciones

expandir todo

fsrftestUnivariate feature ranking for regression using F-tests (desde R2020a)
fsrmrmrRank features for regression using minimum redundancy maximum relevance (MRMR) algorithm (desde R2022a)
fsrncaFeature selection using neighborhood component analysis for regression
oobPermutedPredictorImportancePredictor importance estimates by permutation of out-of-bag predictor observations for random forest of regression trees
partialDependenceCompute partial dependence (desde R2020b)
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 (desde R2023b)
sequentialfsSequential feature selection using custom criterion
stepwiselmPerform stepwise regression
stepwiseglmCreate generalized linear regression model by stepwise regression
genrfeaturesPerform automated feature engineering for regression (desde R2021b)
describeDescribe generated features (desde R2021a)
transformTransform new data using generated features (desde R2021a)
fitrautoAutomatically select regression model with optimized hyperparameters (desde R2020b)
bayesoptSelect optimal machine learning hyperparameters using Bayesian optimization
hyperparametersVariable descriptions for optimizing a fit function
optimizableVariableVariable description for bayesopt or other optimizers

Para datos no dependientes del tiempo

crossvalEstimate loss using cross-validation
cvpartitionPartición de datos para validación cruzada
repartitionRepartition data for cross-validation
testÍndices de prueba para la validación cruzada
trainingÍndices de entrenamiento para la validación cruzada

Para datos de series temporales

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

Explicaciones independientes del modelo local interpretable (LIME, por sus siglas en inglés)

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

Valores de Shapley

shapleyShapley values (desde R2021a)
fitCompute Shapley values for query point (desde R2021a)
plotPlot Shapley values (desde R2021a)

Dependencia parcial

partialDependenceCompute partial dependence (desde R2020b)
plotPartialDependenceCreate partial dependence plot (PDP) and individual conditional expectation (ICE) plots
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

Objetos

expandir todo

FeatureSelectionNCARegressionFeature selection for regression using neighborhood component analysis (NCA)
FeatureTransformerGenerated feature transformations (desde R2021a)
BayesianOptimizationBayesian optimization results

Temas

Flujo de trabajo de la app Regression Learner

Selección de características

Ingeniería de características

  • 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.

Selección de modelos automatizados

Optimización de hiperparámetros

Interpretación de modelos

Validación cruzada

Diagnósticos de modelos lineales

  • 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.
  • Coeficiente de determinación (R cuadrado)
    El coeficiente de determinación (R cuadrado) indica la cantidad proporcional de variación en la variable de respuesta y explicada por las variables independientes X en el modelo de regresión lineal.
  • 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.

Diagnósticos de modelos lineales generalizados

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

Diagnósticos de modelos no lineales

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