模型的构建和评估
特征选择、特征工程、模型选择、超参数优化、交叉验证、残差诊断和绘图
在构建高质量回归模型时,选择正确的特征(或预测变量)、调整超参数(未与数据拟合的模型参数)以及通过残差诊断评估模型假设非常重要。
您可以先为超参数选择值,然后使用您选择的值对模型进行交叉验证,通过这样的迭代对超参数进行调整。这个过程会生成多个模型,其中估计的泛化误差最小的可能是最佳模型。例如,要调整 SVM 模型,可以选择一组框约束和核尺度,使用每对值对模型进行交叉验证,然后比较它们的 10 折交叉验证均方误差估计值。
要在训练回归模型之前对新函数进行工程处理,请使用 genrfeatures
。
要以交互方式构建和评估回归模型,请使用回归学习器。
要自动选择具有调整后的超参数的模型,请使用 fitrauto
。该函数尝试选择具有不同超参数值的回归模型类型,并返回预期表现良好的最终模型。当您不确定哪些回归模型类型最适合您的数据时,请使用 fitrauto
。
Statistics and Machine Learning Toolbox™ 中的某些非参数化回归函数通过贝叶斯优化、网格搜索或随机搜索提供自动超参数调整。实现贝叶斯优化的主函数 bayesopt
对于许多其他应用来说也足够灵活。有关详细信息,请参阅Bayesian Optimization Workflow。
要解释回归模型,可以使用 lime
、shapley
和 plotPartialDependence
。
App
回归学习器 | 使用有监督机器学习训练回归模型来预测数据 |
函数
对象
主题
回归学习器工作流
- Train Regression Models in Regression Learner App
Workflow for training, comparing and improving regression models, including automated, manual, and parallel training. - Choose Regression Model Options
In Regression Learner, automatically train a selection of models, or compare and tune options of linear regression models, regression trees, support vector machines, Gaussian process regression models, kernel approximation models, ensembles of regression trees, and regression neural networks. - Feature Selection and Feature Transformation Using Regression Learner App
Identify useful predictors using plots or feature ranking algorithms, select features to include, and transform features using PCA in Regression Learner. - Visualize and Assess Model Performance in Regression Learner
Compare model metrics and visualize results.
特征选择
- Introduction to Feature Selection
Learn about feature selection algorithms and explore the functions available for feature selection. - Sequential Feature Selection
This topic introduces sequential feature selection and provides an example that selects features sequentially using a custom criterion and thesequentialfs
function. - Neighborhood Component Analysis (NCA) Feature Selection
Neighborhood component analysis (NCA) is a non-parametric method for selecting features with the goal of maximizing prediction accuracy of regression and classification algorithms. - Robust Feature Selection Using NCA for Regression
Perform feature selection that is robust to outliers using a custom robust loss function in NCA. - Select Predictors for Random Forests
Select split-predictors for random forests using interaction test algorithm.
特征工程
- Automated Feature Engineering for Regression
Usegenrfeatures
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.
自动模型选择
- Automated Regression Model Selection with Bayesian and ASHA Optimization
Usefitrauto
to automatically try a selection of regression model types with different hyperparameter values, given training predictor and response data.
超参数优化
- Bayesian Optimization Workflow
Perform Bayesian optimization using a fit function or by callingbayesopt
directly. - Variables for a Bayesian Optimization
Create variables for Bayesian optimization. - Bayesian Optimization Objective Functions
Create the objective function for Bayesian optimization. - Constraints in Bayesian Optimization
Set different types of constraints for Bayesian optimization. - Optimize a Boosted Regression Ensemble
Minimize cross-validation loss of a regression ensemble. - Bayesian Optimization Plot Functions
Visually monitor a Bayesian optimization. - Bayesian Optimization Output Functions
Monitor a Bayesian optimization. - Bayesian Optimization Algorithm
Understand the underlying algorithms for Bayesian optimization. - Parallel Bayesian Optimization
How Bayesian optimization works in parallel.
模型解释
- Interpret Machine Learning Models
Explain model predictions using thelime
andshapley
objects and theplotPartialDependence
function. - Shapley Values for Machine Learning Model
Compute Shapley values for a machine learning model using interventional algorithm or conditional algorithm.
交叉验证
- Implement Cross-Validation Using Parallel Computing
Speed up cross-validation using parallel computing. - Manually Perform Time Series Forecasting Using Ensembles of Boosted Regression Trees
Manually perform single-step and multiple-step time series forecasting with ensembles of boosted regression trees.
线性模型诊断
- 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. - 决定系数(R 方)
决定系数(R 方)表示线性回归模型中由自变量 X 解释的响应变量 y 的变化比例。 - 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.
广义线性模型诊断
- Generalized Linear Models
Generalized linear models use linear methods to describe a potentially nonlinear relationship between predictor terms and a response variable.
非线性模型诊断
- Nonlinear Regression
Parametric nonlinear models represent the relationship between a continuous response variable and one or more continuous predictor variables.