gather
Gather properties of Statistics and Machine Learning Toolbox object from GPU
Syntax
Description
gathers all properties of the input object gatheredObj = gather(obj)obj and returns the gathered
object gatheredObj. All properties of the output object are stored in
the local workspace.
Use gather to create a Statistics and Machine Learning Toolbox™ object with properties stored in the local workspace from an object fitted
using data stored as a GPU array. For more details on GPU arrays, see gpuArray (Parallel Computing Toolbox). Using a GPU requires Parallel Computing Toolbox™ and a supported GPU device. For information on supported devices, see GPU Computing Requirements (Parallel Computing Toolbox).
Examples
Gather the properties of a linear regression model fitted with GPU array data.
Load the carsmall data set. Create X as a numeric matrix that contains three car performance metrics. Create Y as a numeric vector that contains the corresponding miles per gallon.
load carsmall
X = [Weight,Horsepower,Acceleration];
Y = MPG;Convert the predictor X and response Y to gpuArray (Parallel Computing Toolbox) objects.
X = gpuArray(X); Y = gpuArray(Y);
Fit a linear regression model mdl by using fitlm.
mdl = fitlm(X,Y);
Display the coefficients of mdl and determine whether the estimated coefficient values are GPU arrays.
mdl.Coefficients
ans=4×4 table
Estimate SE tStat pValue
__________ _________ _________ __________
(Intercept) 47.977 3.8785 12.37 4.8957e-21
x1 -0.0065416 0.0011274 -5.8023 9.8742e-08
x2 -0.042943 0.024313 -1.7663 0.08078
x3 -0.011583 0.19333 -0.059913 0.95236
isgpuarray(mdl.Coefficients.Estimate)
ans = logical
1
Gather the properties of the linear regression model.
gatheredMdl = gather(mdl);
Display the coefficients of gatheredMdl and determine whether the estimated coefficient values are GPU arrays.
gatheredMdl.Coefficients
ans=4×4 table
Estimate SE tStat pValue
__________ _________ _________ __________
(Intercept) 47.977 3.8785 12.37 4.8957e-21
x1 -0.0065416 0.0011274 -5.8023 9.8742e-08
x2 -0.042943 0.024313 -1.7663 0.08078
x3 -0.011583 0.19333 -0.059913 0.95236
isgpuarray(gatheredMdl.Coefficients.Estimate)
ans = logical
0
Gather the properties of a linear regression model and a k-nearest neighbor classifier. Both models are fitted using GPU array data.
Load the carsmall data set. Create X as a numeric matrix that contains three car performance metrics, and convert the predictor X to a gpuArray object.
load carsmall
X = [Weight,Horsepower,Acceleration];
X = gpuArray(X);Fit a linear regression model of MPG (miles per gallon) as a function of the predictor X.
mdlLinear = fitlm(X,MPG);
Train a 3-nearest neighbor classifier using the predictor X and the classes Cylinders. Standardize the noncategorical predictor data.
mdlKNN = fitcknn(X,Cylinders,'NumNeighbors',3,'Standardize',1);
Gather the properties of the mdLinear and mdlKNN models.
[gMdlLinear,gMdlKNN] = gather(mdlLinear,mdlKNN);
Determine whether the p-value of the Durbin-Watson test for the regression model mdlLinear is a GPU array.
isgpuarray(dwtest(mdlLinear))
ans = logical
1
Determine whether the p-value of the Durbin-Watson test for the gathered regression model gMdlLinear is a GPU array.
isgpuarray(dwtest(gMdlLinear))
ans = logical
0
Determine whether the resubstitution loss of the classifier mdlKNN is a GPU array.
isgpuarray(resubLoss(mdlKNN))
ans = logical
1
Determine whether the resubstitution loss of the gathered classifier gMdlKNN is a GPU array.
isgpuarray(resubLoss(gMdlKNN))
ans = logical
1
Input Arguments
Object fitted with GPU arrays or a gpuArray object, specified as a
regression model object, classification model object, cluster analysis and anomaly
detection model object, probability distribution object, cvpartition object, or gpuArray (Parallel Computing Toolbox) object. A gpuArray object represents an array
stored on the GPU.
For more information on the Statistics and Machine Learning Toolbox objects supported by gather, see Supported Regression Models, Supported Classification Models, Supported Cluster Analysis and Anomaly Detection Models, and Supported Probability Distribution Objects.
More About
The gather function can gather the properties
of the following regression model objects.
| Model Type | Full or Compact Model Object | Model Creation Function |
|---|---|---|
| Full generalized linear regression model | GeneralizedLinearModel or CompactGeneralizedLinearModel | fitglm or
GeneralizedLinearModel object function compact |
| Full linear regression model | LinearModel or CompactLinearModel | fitlm or LinearModel
object function compact |
| Ensemble of learners for regression | RegressionEnsemble, CompactRegressionEnsemble, or RegressionBaggedEnsemble | fitrensemble or regression ensemble
object function compact |
| Gaussian process regression (GPR) model | RegressionGP or CompactRegressionGP | fitrgp or RegressionGP
object function compact |
| Gaussian kernel regression model | RegressionKernel | fitrkernel |
| Regression linear model | RegressionLinear | fitrlinear |
| Regression neural network model | RegressionNeuralNetwork or CompactRegressionNeuralNetwork | fitrnet
or RegressionNeuralNetwork object function compact |
| Support vector machine (SVM) regression model | RegressionSVM or CompactRegressionSVM | fitrsvm or RegressionSVM
object function compact |
| Regression tree model | RegressionTree or CompactRegressionTree | fitrtree or
RegressionTree object function compact |
| Cross-validated regression ensemble | RegressionPartitionedEnsemble | fitrensemble or regression ensemble
object function crossval |
| Cross-validated GPR model | RegressionPartitionedGP | fitrgp or RegressionGP
object function crossval |
| Cross-validated Gaussian kernel regression model | RegressionPartitionedKernel | fitrkernel |
| Cross-validated regression linear model | RegressionPartitionedLinear | fitrlinear |
| Cross-validated neural network regression model | RegressionPartitionedNeuralNetwork | fitrnet
or RegressionNeuralNetwork object function crossval |
| Cross-validated SVM regression model | RegressionPartitionedSVM | fitrsvm or RegressionSVM
object function crossval |
| Cross-validated regression model | RegressionPartitionedModel | fitrtree or
RegressionTree object function crossval |
| XGBoost regression model | CompactRegressionXGBoost | importModelFromXGBoost
|
If you want to create a compact model fitted with GPU arrays, the input argument
mdl of compact must be a full model object fitted
with GPU array input arguments.
The gather function can gather the properties
of the following classification model objects.
| Model Type | Full or Compact Model Object | Model Creation Function |
|---|---|---|
| Multiclass model for support vector machines or other classifiers | ClassificationECOC or CompactClassificationECOC | fitcecoc or
ClassificationECOC object function compact |
| Ensemble of learners for classification | ClassificationEnsemble, CompactClassificationEnsemble, or ClassificationBaggedEnsemble | fitcensemble or classification ensemble
object function compact |
| Gaussian kernel classification model | ClassificationKernel | fitckernel |
| k-nearest neighbor classifier | ClassificationKNN | fitcknn |
| Classification linear model | ClassificationLinear | fitclinear |
| Classification neural network model | ClassificationNeuralNetwork or CompactClassificationNeuralNetwork | fitcnet
or ClassificationNeuralNetwork object function compact |
| Support vector machine (SVM) classifier | ClassificationSVM or CompactClassificationSVM | fitcsvm or
ClassificationSVM object function compact |
| Binary decision tree for multiclass classification | ClassificationTree or CompactClassificationTree | fitctree or
ClassificationTree object function compact |
| Cross-validated ECOC model | ClassificationPartitionedECOC, ClassificationPartitionedKernelECOC, or ClassificationPartitionedLinearECOC | fitcecoc or
ClassificationECOC object function crossval |
| Cross-validated classification ensemble | ClassificationPartitionedEnsemble | fitcensemble or classification ensemble
object function crossval |
| Cross-validated Gaussian kernel classification model | ClassificationPartitionedKernel | fitckernel |
| Cross-validated classification linear model | ClassificationPartitionedLinear | fitclinear |
| Cross-validated neural network classification model | ClassificationPartitionedNeuralNetwork | fitcnet
or ClassificationNeuralNetwork object function crossval |
| Cross-validated classification model | ClassificationPartitionedModel | fitcknn, fitcsvm, fitctree, or classification model object
function crossval |
| XGBoost classification model | CompactClassificationXGBoost | importModelFromXGBoost
|
If you want to create a compact model fitted with GPU arrays, the Input argument
mdl of compact must be a full model object fitted
with GPU array input arguments.
The gather function can gather the properties
of the following cluster analysis and anomaly detection model objects.
| Model Type | Model Object | Model Creation Function |
|---|---|---|
One-class support vector machine (SVM) for anomaly detection | OneClassSVM | ocsvm |
The gather function can gather the properties
of the following probability distribution objects.
| Probability Distribution | Probability Distribution Object | Object Creation Function |
|---|---|---|
| Beta distribution | BetaDistribution | fitdist with
distname specified as 'Beta' |
| Binomial distribution | BinomialDistribution | fitdist with
distname specified as 'Binomial' |
| Birnbaum-Saunders distribution | BirnbaumSaundersDistribution | fitdist with
distname specified as
'BirnbaumSaunders' |
| Burr distribution | BurrDistribution | fitdist with
distname specified as 'Burr' |
| Empirical Distribution | EmpiricalDistribution | fitdist |
| Exponential distribution | ExponentialDistribution | fitdist with
distname specified as
'Exponential' |
| Extreme Value distribution | ExtremeValueDistribution | fitdist with
distname specified as
'ExtremeValue' |
| Gamma distribution | GammaDistribution | fitdist with
distname specified as 'Gamma' |
| Generalized Extreme Value distribution | GeneralizedExtremeValueDistribution | fitdist with
distname specified as
'GeneralizedExtremeValue' |
| Generalized Pareto distribution | GeneralizedParetoDistribution | fitdist with
distname specified as
'GeneralizedPareto' |
| Half-normal distribution | HalfNormalDistribution | fitdist with
distname specified as 'HalfNormal' |
| Inverse Gaussian distribution | InverseGaussianDistribution | fitdist with
distname specified as
'InverseGaussian' |
| Kernel distribution | KernelDistribution | fitdist with
distname specified as 'Kernel' |
| Logistic distribution | LogisticDistribution | fitdist with
distname specified as 'Logistic' |
| Loglogistic distribution | LoglogisticDistribution | fitdist with
distname specified as
'Loglogistic' |
| Lognormal distribution | LognormalDistribution | fitdist with
distname specified as 'Lognormal' |
| Nakagami distribution | NakagamiDistribution | fitdist with
distname specified as 'Nakagami' |
| Negative Binomial distribution | NegativeBinomialDistribution | fitdist with
distname specified as
'NegativeBinomial' |
| Normal distribution | NormalDistribution | fitdist with
distname specified as 'Normal' |
| Poisson distribution | PoissonDistribution | fitdist with
distname specified as 'Poisson' |
| Rayleigh distribution | RayleighDistribution | fitdist with
distname specified as 'Rayleigh' |
| t Location-Scale distribution | tLocationScaleDistribution | fitdist with
distname specified as
'tLocationScale' |
| Weibull distribution | WeibullDistribution | fitdist with
distname specified as 'Weibull' |
Tips
Gathering GPU arrays can be costly and is generally not necessary unless you need to use the results with functions that do not support GPU arrays. For the complete list of Statistics and Machine Learning Toolbox functions that accept GPU arrays, see Function List (GPU Arrays).
You can also call
gatheron other data types, such as distributed, codistributed, or tall arrays. If the data type does not support gathering, thengatherhas no effect.
Extended Capabilities
The
gather function supports tall arrays with the following usage
notes and limitations:
This function supports only
cvpartitionobjects and unevaluated tall arrays.
For more information, see Tall Arrays.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
Version History
Introduced in R2020bYou can use the gather function to create gathered RegressionGP, CompactRegressionGP, and RegressionPartitionedGP model objects from equivalent objects fitted with GPU
array data.
You can use the gather function to create gathered CompactClassificationECOC and ClassificationPartitionedKernelECOC model objects from equivalent objects fitted
with GPU array data.
You can now use the gather function to create gathered RegressionKernel,
RegressionPartitionedKernel, ClassificationKernel, and ClassificationPartitionedKernel model objects from equivalent objects fitted
with GPU array data.
You can now use the gather function to create a gathered
RegressionNeuralNetwork, CompactRegressionNeuralNetwork, or RegressionPartitionedNeuralNetwork model object from an equivalent object fitted
with GPU array data.
You can now use the gather function to create a gathered
ClassificationNeuralNetwork or CompactClassificationNeuralNetwork model object from an equivalent object fitted
with GPU array data. You can also create a gathered ClassificationPartitionedModel model object from an equivalent object that was
fitted with GPU array data using the fitcnet and
crossval
functions.
You can now use the gather function to create a gathered
RegressionLinear or RegressionPartitionedLinear model object from an
equivalent object fitted with GPU array data.
You can use the gather function to create a ClassificationLinear or ClassificationPartitionedLinear model object from an
equivalent object fitted with GPU array data.
Starting in R2023a, you can use the gather function to create
a RegressionSVM, CompactRegressionSVM, or RegressionPartitionedSVM model object from an equivalent object fitted with GPU
array data.
See Also
gather (Parallel Computing Toolbox) | gpuArray (Parallel Computing Toolbox) | LinearModel | GeneralizedLinearModel | RegressionLinear | RegressionGP | RegressionSVM | RegressionTree | ClassificationLinear | ClassificationKNN | ClassificationTree | ClassificationEnsemble | ClassificationECOC | fitdist
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)