CompactClassificationGAM
Description
CompactClassificationGAM
is a compact version of a ClassificationGAM
model object (GAM for binary classification). The compact model does not include the data used
for training the classifier. Therefore, you cannot perform some tasks, such as
cross-validation, using the compact model. Use a compact model for tasks such as predicting
the labels of new data.
Creation
Create a CompactClassificationGAM
object from a full ClassificationGAM
model object by using compact
.
Properties
GAM Properties
This property is read-only.
Interaction term indices, specified as a t
-by-2 matrix of positive
integers, where t
is the number of interaction terms in the model.
Each row of the matrix represents one interaction term and contains the column indexes
of the predictor data X
for the interaction term. If the model does
not include an interaction term, then this property is empty
([]
).
The software adds interaction terms to the model in the order of importance based on the p-values. Use this property to check the order of the interaction terms added to the model.
Data Types: double
This property is read-only.
Intercept (constant) term of the model, which is the sum of the intercept terms in the predictor trees and interaction trees, specified as a numeric scalar.
Data Types: single
| double
Other Classification Properties
This property is read-only.
Categorical predictor
indices, specified as a vector of positive integers. CategoricalPredictors
contains index values indicating that the corresponding predictors are categorical. The index
values are between 1 and p
, where p
is the number of
predictors used to train the model. If none of the predictors are categorical, then this
property is empty ([]
).
Data Types: double
This property is read-only.
Unique class labels used in training, specified as a categorical or character array,
logical or numeric vector, or cell array of character vectors.
ClassNames
has the same data type as the class labels
Y
. (The software treats string arrays as cell arrays of character
vectors.)
ClassNames
also determines the class order.
Data Types: single
| double
| logical
| char
| cell
| categorical
Misclassification costs, specified as a 2-by-2 numeric matrix.
Cost(
is the cost of classifying a point into class i
,j
)j
if its true class is i
. The order of the rows and columns of Cost
corresponds to the order of the classes in ClassNames
.
The software uses the Cost
value for prediction, but not training. You can change the value by using dot notation.
Example: Mdl.Cost = C;
Data Types: double
This property is read-only.
Expanded predictor names, specified as a cell array of character vectors.
ExpandedPredictorNames
is the same as PredictorNames
for a generalized additive model.
Data Types: cell
This property is read-only.
Predictor variable names, specified as a cell array of character vectors. The order of the
elements in PredictorNames
corresponds to the order in which the
predictor names appear in the training data.
Data Types: cell
This property is read-only.
Prior class probabilities, specified as a numeric vector with two elements. The order of the
elements corresponds to the order of the elements in
ClassNames
.
Data Types: double
This property is read-only.
Response variable name, specified as a character vector.
Data Types: char
Score transformation, specified as a character vector or function handle. ScoreTransform
represents a built-in transformation function or a function handle for transforming predicted classification scores.
To change the score transformation function to function
, for example, use dot notation.
For a built-in function, enter a character vector.
Mdl.ScoreTransform = 'function';
This table describes the available built-in functions.
Value Description 'doublelogit'
1/(1 + e–2x) 'invlogit'
log(x / (1 – x)) 'ismax'
Sets the score for the class with the largest score to 1, and sets the scores for all other classes to 0 'logit'
1/(1 + e–x) 'none'
or'identity'
x (no transformation) 'sign'
–1 for x < 0
0 for x = 0
1 for x > 0'symmetric'
2x – 1 'symmetricismax'
Sets the score for the class with the largest score to 1, and sets the scores for all other classes to –1 'symmetriclogit'
2/(1 + e–x) – 1 For a MATLAB® function or a function that you define, enter its function handle.
Mdl.ScoreTransform = @function;
function
must accept a matrix (the original scores) and return a matrix of the same size (the transformed scores).
This property determines the output score computation for object functions such as
predict
,
margin
, and
edge
. Use
'logit'
to compute posterior probabilities, and use
'none'
to compute the logit of posterior probabilities.
Data Types: char
| function_handle
Object Functions
lime | Local interpretable model-agnostic explanations (LIME) |
partialDependence | Compute partial dependence |
plotLocalEffects | Plot local effects of terms in generalized additive model (GAM) |
plotPartialDependence | Create partial dependence plot (PDP) and individual conditional expectation (ICE) plots |
shapley | Shapley values |
compareHoldout | Compare accuracies of two classification models using new data |
Examples
Reduce the size of a full generalized additive model (GAM) by removing the training data. Full models hold the training data. You can use a compact model to improve memory efficiency.
Load the ionosphere
data set. This data set has 34 predictors and 351 binary responses for radar returns, either bad ('b'
) or good ('g'
).
load ionosphere
Train a GAM using the predictors X
and class labels Y
. A recommended practice is to specify the class names.
Mdl = fitcgam(X,Y,'ClassNames',{'b','g'})
Mdl = ClassificationGAM ResponseName: 'Y' CategoricalPredictors: [] ClassNames: {'b' 'g'} ScoreTransform: 'logit' Intercept: 2.2715 NumObservations: 351 Properties, Methods
Mdl
is a ClassificationGAM
model object.
Reduce the size of the classifier.
CMdl = compact(Mdl)
CMdl = CompactClassificationGAM ResponseName: 'Y' CategoricalPredictors: [] ClassNames: {'b' 'g'} ScoreTransform: 'logit' Intercept: 2.2715 Properties, Methods
CMdl
is a CompactClassificationGAM
model object.
Display the amount of memory used by each classifier.
whos('Mdl','CMdl')
Name Size Bytes Class Attributes CMdl 1x1 1064155 classreg.learning.classif.CompactClassificationGAM Mdl 1x1 1265674 ClassificationGAM
The full classifier (Mdl
) is larger than the compact classifier (CMdl
).
To efficiently label new observations, you can remove Mdl
from the MATLAB® Workspace, and then pass CMdl
and new predictor values to predict
.
Version History
Introduced in R2021a
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)