Remove residuals from Cox model
creates a Cox proportional hazards model with an empty
compactCoxMdl = discardResiduals(
property. For models trained on many data points, removing the residuals yields a
significantly more compact object.
Save Memory by Discarding Residuals
Create a Cox proportional hazards model from the
lightbulb data set. For details of this data set, see Survivor Functions for Two Groups.
load('lightbulb.mat'); bulbmodel = fitcox(lightbulb(:,2),lightbulb(:,1),... 'Censoring',lightbulb(:,3));
Examine the memory used by
S1 = whos('bulbmodel'); disp(S1.bytes)
Remove the residuals from
bulbmodel and examine the memory savings.
bulbmodel = discardResiduals(bulbmodel); S2 = whos('bulbmodel'); disp(S2.bytes/S1.bytes)
Removing the residuals lowers the memory usage by about half.
compactCoxMdl — Cox proportional hazards model without residuals
Cox proportional hazards model without residuals, returned as a
CoxModel object. Typically,
compactCoxMdl to the same name as
obtain the original object without the residuals:
coxMdl = discardResiduals(coxMdl);
Introduced in R2022b