Supported Data Types
Statistics and Machine Learning Toolbox™ supports the following data types for input arguments:
Numeric scalars, vectors, matrices, or arrays having single- or double-precision entries. These data forms have data type
single
ordouble
. Examples include response variables, predictor variables, and numeric values.Cell arrays of character vectors; character, string, logical, or categorical arrays; or numeric vectors for categorical variables representing grouping data. These data forms have data types
cell
(specificallycellstr
),char
,string
,logical
,categorical
, andsingle
ordouble
, respectively. An example is an array of class labels in machine learning.You can also use nominal or ordinal arrays for categorical data. However, the
nominal
andordinal
data types are not recommended. To work with nominal or ordinal categorical data, use thecategorical
data type instead.You can use signed or unsigned integers, e.g.,
int8
oruint8
. However:Estimation functions might not support signed or unsigned integer data types for nongrouping data.
If you recast a
single
ordouble
numeric vector containingNaN
values to a signed or unsigned integer, then the software converts theNaN
elements to0
.
Some functions support tabular arrays for heterogeneous data (for details, see Tables). The
table
data type contains variables of any of the data types previously listed. An example is mixed categorical and numerical predictor data for regression analysis.For some functions, you can also use dataset arrays for heterogeneous data. However, the
dataset
data type is not recommended. To work with heterogeneous data, use thetable
data type if the estimation function supports it.Functions that do not support the
table
data type support sample data of typesingle
ordouble
, e.g., matrices.
Some functions accept
gpuArray
(Parallel Computing Toolbox) input arguments so that they execute on the GPU. For the full list of Statistics and Machine Learning Toolbox functions that accept GPU arrays, see Function List (GPU Arrays).Some functions accept
tall
array input arguments to work with large data sets. For the full list of Statistics and Machine Learning Toolbox functions that accept tall arrays, see Function List (Tall Arrays).Some functions accept sparse matrices, i.e., matrix
A
such thatissparse(A)
returns1
. For functions that do not accept sparse matrices, recast the data to a full matrix by usingfull
.
Statistics and Machine Learning Toolbox does not support the following data types:
Complex numbers.
Custom numeric data types, e.g., a variable that is double precision and an object.
Signed or unsigned numeric integers for nongrouping data, e.g.,
uint8
andint16
.
Note
If you specify data of an unsupported type, then the software might return an error or unexpected results.