|
|
精明的豆腐 · 直播分成钱去哪儿了:平台吃肉主播喝汤_手机新浪网· 1 年前 · |
|
|
开朗的咖啡 · 这部青春片和导演,值得一赞!和导演聊《谁的青 ...· 1 年前 · |
|
|
想发财的荒野 · 番禺区全力打造广佛全域同城化高质量发展合作区 ...· 1 年前 · |
|
|
爱喝酒的葫芦 · 透过表象看本质 ...· 2 年前 · |
|
|
大方的柚子 · 华硕笔记本bios开启网卡 华硕 bios ...· 2 年前 · |
|
|
性感的椅子
3 年前 |
Receiver operating characteristic (ROC) curve or other performance curve for classifier output
[
___
] = perfcurve(
returns
the coordinates of a ROC curve and any other output argument from
the previous syntaxes, with additional options specified by one or
more
labels
,
scores
,
posclass
,
Name,Value
)
Name,Value
pair arguments.
For example, you can provide a list of negative classes, change
the
X
or
Y
criterion, compute
pointwise confidence
bounds
using cross validation or bootstrap, specify the misclassification
cost, or compute the confidence bounds in parallel.
Load the sample data.
load fisheriris
Use only the first two features as predictor variables. Define a binary classification problem by using only the measurements that correspond to the species versicolor and virginica.
pred = meas(51:end,1:2);
Define the binary response variable.
resp = (1:100)'>50; % Versicolor = 0, virginica = 1
Fit a logistic regression model.
mdl = fitglm(pred,resp,'Distribution','binomial','Link','logit');
Compute the ROC curve. Use the probability estimates from the logistic regression model as scores.
scores = mdl.Fitted.Probability;
[X,Y,T,AUC] = perfcurve(species(51:end,:),scores,'virginica');
perfcurve
stores the threshold values in the array
T
.
Display the area under the curve.
AUC
AUC = 0.7918
The area under the curve is 0.7918. The maximum AUC is 1, which corresponds to a perfect classifier. Larger AUC values indicate better classifier performance.
Plot the ROC curve.
plot(X,Y) xlabel('False positive rate') ylabel('True positive rate') title('ROC for Classification by Logistic Regression')
Alternatively, you can compute and plot the ROC curve by creating a
rocmetrics
object and using the object function
plot
.
rocObj = rocmetrics(species(51:end,:),scores,'virginica');
plot(rocObj)
The
plot
function displays a filled circle at the model operating point, and the legend displays the class name and AUC value for the curve.
Load the sample data.
load ionosphere
X
is a 351x34 real-valued matrix of predictors.
Y
is a character array of class labels:
'b'
for bad radar returns and
'g'
for good radar returns.
Reformat the response to fit a logistic regression. Use the predictor variables 3 through 34.
resp = strcmp(Y,'b'); % resp = 1, if Y = 'b', or 0 if Y = 'g' pred = X(:,3:34);
Fit a logistic regression model to estimate the posterior probabilities for a radar return to be a bad one.
mdl = fitglm(pred,resp,'Distribution','binomial','Link','logit'); score_log = mdl.Fitted.Probability; % Probability estimates
Compute the standard ROC curve using the probabilities for scores.
[Xlog,Ylog,Tlog,AUClog] = perfcurve(resp,score_log,'true');
Train an SVM classifier on the same sample data. Standardize the data.
mdlSVM = fitcsvm(pred,resp,'Standardize',true);
Compute the posterior probabilities (scores).
mdlSVM = fitPosterior(mdlSVM); [~,score_svm] = resubPredict(mdlSVM);
The second column of
score_svm
contains the posterior probabilities of bad radar returns.
Compute the standard ROC curve using the scores from the SVM model.
[Xsvm,Ysvm,Tsvm,AUCsvm] = perfcurve(resp,score_svm(:,mdlSVM.ClassNames),'true');
Fit a naive Bayes classifier on the same sample data.
mdlNB = fitcnb(pred,resp);
Compute the posterior probabilities (scores).
[~,score_nb] = resubPredict(mdlNB);
Compute the standard ROC curve using the scores from the naive Bayes classification.
[Xnb,Ynb,Tnb,AUCnb] = perfcurve(resp,score_nb(:,mdlNB.ClassNames),'true');
Plot the ROC curves on the same graph.
plot(Xlog,Ylog) hold on plot(Xsvm,Ysvm) plot(Xnb,Ynb) legend('Logistic Regression','Support Vector Machines','Naive Bayes','Location','Best') xlabel('False positive rate'); ylabel('True positive rate' ); title('ROC Curves for Logistic Regression, SVM, and Naive Bayes Classification') hold off
Although SVM produces better ROC values for higher thresholds, logistic regression is usually better at distinguishing the bad radar returns from the good ones. The ROC curve for naive Bayes is generally lower than the other two ROC curves, which indicates worse in-sample performance than the other two classifier methods.
Compare the area under the curve for all three classifiers.
AUClog
AUClog = 0.9659
AUCsvm
AUCsvm = 0.9489
AUCnb
AUCnb = 0.9393
Logistic regression has the highest AUC measure for classification and naive Bayes has the lowest. This result suggests that logistic regression has better in-sample average performance for this sample data.
This example shows how to determine the better parameter value for a custom kernel function in a classifier using the ROC curves.
Generate a random set of points within the unit circle.
rng(1); % For reproducibility n = 100; % Number of points per quadrant r1 = sqrt(rand(2*n,1)); % Random radii t1 = [pi/2*rand(n,1); (pi/2*rand(n,1)+pi)]; % Random angles for Q1 and Q3 X1 = [r1.*cos(t1) r1.*sin(t1)]; % Polar-to-Cartesian conversion r2 = sqrt(rand(2*n,1)); t2 = [pi/2*rand(n,1)+pi/2; (pi/2*rand(n,1)-pi/2)]; % Random angles for Q2 and Q4 X2 = [r2.*cos(t2) r2.*sin(t2)];
Define the predictor variables. Label points in the first and third quadrants as belonging to the positive class, and those in the second and fourth quadrants in the negative class.
pred = [X1; X2];
resp = ones(4*n,1);
resp(2*n + 1:end) = -1; % Labels
Create the function
mysigmoid.m
, which accepts two matrices in the feature space as inputs, and transforms them into a Gram matrix using the sigmoid kernel.
function G = mysigmoid(U,V) % Sigmoid kernel function with slope gamma and intercept c gamma = 1; c = -1; G = tanh(gamma*U*V' + c);
Train an SVM classifier using the sigmoid kernel function. It is good practice to standardize the data.
SVMModel1 = fitcsvm(pred,resp,'KernelFunction','mysigmoid',... 'Standardize',true); SVMModel1 = fitPosterior(SVMModel1); [~,scores1] = resubPredict(SVMModel1);
Set
gamma = 0.5
; within
mysigmoid.m
and save as
mysigmoid2.m
. And, train an SVM classifier using the adjusted sigmoid kernel.
function G = mysigmoid2(U,V) % Sigmoid kernel function with slope gamma and intercept c gamma = 0.5; c = -1; G = tanh(gamma*U*V' + c);
SVMModel2 = fitcsvm(pred,resp,'KernelFunction','mysigmoid2',... 'Standardize',true); SVMModel2 = fitPosterior(SVMModel2); [~,scores2] = resubPredict(SVMModel2);
Compute the ROC curves and the area under the curve (AUC) for both models.
[x1,y1,~,auc1] = perfcurve(resp,scores1(:,2),1); [x2,y2,~,auc2] = perfcurve(resp,scores2(:,2),1);
Plot the ROC curves.
plot(x1,y1) hold on plot(x2,y2) hold off legend('gamma = 1','gamma = 0.5','Location','SE'); xlabel('False positive rate'); ylabel('True positive rate'); title('ROC for classification by SVM');
The kernel function with the gamma parameter set to 0.5 gives better in-sample results.
Compare the AUC measures.
auc1
auc1 =
0.9518
auc2 =
0.9985
The area under the curve for gamma set to 0.5 is higher than that for gamma set to 1. This also confirms that gamma parameter value of 0.5 produces better results. For visual comparison of the classification performance with these two gamma parameter values, see Train SVM Classifier Using Custom Kernel .
Load the sample data.
load fisheriris
The column vector,
species
, consists of iris flowers of three different species: setosa, versicolor, virginica. The double matrix
meas
consists of four types of measurements on the flowers: sepal length, sepal width, petal length, and petal width. All measures are in centimeters.
Train a classification tree using the sepal length and width as the predictor variables. It is a good practice to specify the class names.
Model = fitctree(meas(:,1:2),species, ... 'ClassNames',{'setosa','versicolor','virginica'});
Predict the class labels and scores for the species based on the tree
Model
.
[~,score] = resubPredict(Model);
The scores are the posterior probabilities that an observation (a row in the data matrix) belongs to a class. The columns of
score
correspond to the classes specified by
'ClassNames'
. So, the first column corresponds to setosa, the second corresponds to versicolor, and the third column corresponds to virginica.
Compute the ROC curve for the predictions that an observation belongs to versicolor, given the true class labels
species
. Also compute the optimal operating point and
y
values for negative subclasses. Return the names of the negative classes.
Because this is a multiclass problem, you cannot merely supply
score(:,2)
as input to
perfcurve
. Doing so would not give
perfcurve
enough information about the scores for the two negative classes (setosa and virginica). This problem is unlike a binary classification problem, where knowing the scores of one class is enough to determine the scores of the other class. Therefore, you must supply
perfcurve
with a function that factors in the scores of the two negative classes. One such function is
, which corresponds to the one-versus-all coding design.
diffscore1 = score(:,2) - max(score(:,1),score(:,3));
The values in
diffscore
are classification scores for a binary problem that treats the second class as a positive class and the rest as negative classes.
[X,Y,T,~,OPTROCPT,suby,subnames] = perfcurve(species,diffscore1,'versicolor');
X
, by default, is the false positive rate (fallout or 1-specificity) and
Y
, by default, is the true positive rate (recall or sensitivity). The positive class label is
versicolor
. Because a negative class is not defined,
perfcurve
assumes that the observations that do not belong to the positive class are in one class. The function accepts it as the negative class.
OPTROCPT
OPTROCPT = 1×2
0.1000 0.8000
suby
suby = 12×2
0 0
0.1800 0.1800
0.4800 0.4800
0.5800 0.5800
0.6200 0.6200
0.8000 0.8000
0.8800 0.8800
0.9200 0.9200
0.9600 0.9600
0.9800 0.9800
subnames
subnames = 1x2 cell
{'setosa'} {'virginica'}
Plot the ROC curve and the optimal operating point on the ROC curve.
plot(X,Y) hold on plot(OPTROCPT(1),OPTROCPT(2),'ro') xlabel('False positive rate') ylabel('True positive rate') title('ROC Curve for Classification by Classification Trees') hold off
Find the threshold that corresponds to the optimal operating point.
T((X==OPTROCPT(1))&(Y==OPTROCPT(2)))
ans = 0.2857
Specify
virginica
as the negative class and compute and plot the ROC curve for
versicolor
.
Again, you must supply
perfcurve
with a function that factors in the scores of the negative class. An example of a function to use is
.
diffscore2 = score(:,2) - score(:,3); [X,Y,~,~,OPTROCPT] = perfcurve(species,diffscore2,'versicolor', ... 'negClass','virginica'); OPTROCPT
OPTROCPT = 1×2
0.1800 0.8200
figure, plot(X,Y) hold on plot(OPTROCPT(1),OPTROCPT(2),'ro') xlabel('False positive rate') ylabel('True positive rate') title('ROC Curve for Classification by Classification Trees') hold off
Alternatively, you can use a
rocmetrics
object to create the ROC curve.
rocmetrics
supports multiclass classification problems using the one-versus-all coding design, which reduces a multiclass problem into a set of binary problems. You can examine the performance of a multiclass problem on each class by plotting a one-versus-all ROC curve for each class.
Compute the performance metrics by creating a
rocmetrics
object. Specify the true labels, classification scores, and class names.
rocObj = rocmetrics(species,score,Model.ClassNames);
Plot the ROC curve for each class by using the
plot
function of
rocmetrics
.
figure plot(rocObj)
The
plot
function displays a filled circle at the model operating point for each class, and the legend shows the class name and AUC value for each curve. You can find the optimal operating points by using the properties stored in the
rocmetrics
object
rocObj
. For an example, see
Find Model Operating Point and Optimal Operating Point
.
Load the sample data.
load fisheriris
The column vector
species
consists of iris flowers of three different species: setosa, versicolor, virginica. The double matrix
meas
consists of four types of measurements on the flowers: sepal length, sepal width, petal length, and petal width. All measures are in centimeters.
Use only the first two features as predictor variables. Define a binary problem by using only the measurements that correspond to the versicolor and virginica species.
pred = meas(51:end,1:2);
Define the binary response variable.
resp = (1:100)'>50; % Versicolor = 0, virginica = 1
Fit a logistic regression model.
mdl = fitglm(pred,resp,'Distribution','binomial','Link','logit');
Compute the pointwise confidence intervals on the true positive rate (TPR) by vertical averaging (VA) and sampling using bootstrap.
[X,Y,T] = perfcurve(species(51:end,:),mdl.Fitted.Probability,... 'virginica','NBoot',1000,'XVals',[0:0.05:1]);
'NBoot',1000
sets the number of bootstrap replicas to 1000.
'XVals','All'
prompts
perfcurve
to return
X
,
Y
, and
T
values for all scores, and average the
Y
values (true positive rate) at all
X
values (false positive rate) using vertical averaging. If you do not specify
XVals
, then
perfcurve
computes the confidence bounds using threshold averaging by default.
Plot the pointwise confidence intervals.
errorbar(X,Y(:,1),Y(:,1)-Y(:,2),Y(:,3)-Y(:,1)); xlim([-0.02,1.02]); ylim([-0.02,1.02]); xlabel('False positive rate') ylabel('True positive rate') title('ROC Curve with Pointwise Confidence Bounds') legend('PCBwVA','Location','Best')
It might not always be possible to control the false positive rate (FPR, the
X
value in this example). So you might want to compute the pointwise confidence intervals on true positive rates (TPR) by threshold averaging.
[X1,Y1,T1] = perfcurve(species(51:end,:),mdl.Fitted.Probability,... 'virginica','NBoot',1000);
If you set
'TVals'
to
'All'
, or if you do not specify
'TVals'
or
'Xvals'
, then
perfcurve
returns
X
,
Y
, and
T
values for all scores and computes pointwise confidence bounds for
X
and
Y
using threshold averaging.
Plot the confidence bounds.
figure() errorbar(X1(:,1),Y1(:,1),Y1(:,1)-Y1(:,2),Y1(:,3)-Y1(:,1)); xlim([-0.02,1.02]); ylim([-0.02,1.02]); xlabel('False positive rate') ylabel('True positive rate') title('ROC Curve with Pointwise Confidence Bounds') legend('PCBwTA','Location','Best')
Specify the threshold values to fix and compute the ROC curve. Then plot the curve.
[X1,Y1,T1] = perfcurve(species(51:end,:),mdl.Fitted.Probability,... 'virginica','NBoot',1000,'TVals',0:0.05:1); figure() errorbar(X1(:,1),Y1(:,1),Y1(:,1)-Y1(:,2),Y1(:,3)-Y1(:,1)); xlim([-0.02,1.02]); ylim([-0.02,1.02]); xlabel('False positive rate') ylabel('True positive rate') title('ROC Curve with Pointwise Confidence Bounds') legend('PCBwTA','Location','Best')
labels
—
True class labels
True class labels, specified as a numeric vector, logical vector, character matrix, string array, cell array of character vectors, or categorical array. For more information, see Grouping Variables .
Example:
{'hi','mid','hi','low',...,'mid'}
Example:
['H','M','H','L',...,'M']
Data Types:
single
|
double
|
logical
|
char
|
string
|
cell
|
categorical
scores
—
Scores returned by a classifier
Scores returned by a classifier for some sample data, specified
as a vector of floating points.
scores
must have
the same number of elements as
labels
.
Data Types:
single
|
double
posclass
—
Positive class label
Positive class label, specified as a numeric scalar, logical scalar, character vector, string
scalar, cell containing a character vector, or categorical scalar. The positive class must be
a member of the input labels. The value of
posclass
that you can specify
depends on the value of
labels
.
labels
value
|
posclass
value
|
|---|---|
| Numeric vector | Numeric scalar |
| Logical vector | Logical scalar |
| Character matrix | Character vector |
| String array | String scalar |
| Cell array of character vectors | Character vector or cell containing character vector |
| Categorical vector | Categorical scalar |
For example, in a cancer diagnosis problem, if a malignant tumor
is the positive class, then specify
posclass
as
'malignant'
.
Data Types:
single
|
double
|
logical
|
char
|
string
|
cell
|
categorical
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where
Name
is
the argument name and
Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example:
'NegClass','versicolor','XCrit','fn','NBoot',1000,'BootType','per'
specifies
the species versicolor as the negative class, the criterion for the
X-coordinate as false negative, the number of bootstrap samples as
1000. It also specifies that the pointwise confidence bounds are computed
using the percentile method.
NegClass
—
List of negative classes
'all'
(default) |
numeric array
|
categorical array
|
string array
|
cell array of character vectors
List of negative classes, specified as the comma-separated pair consisting of
'NegClass'
, and a numeric array, a categorical array, a string array, or
a cell array of character vectors. By default,
perfcurve
sets
NegClass
to
'all'
and considers all nonpositive
classes found in the input array of labels to be negative.
If
NegClass
is a subset of the classes
found in the input array of labels, then
perfcurve
discards
the instances with labels that do not belong to either positive or
negative classes.
Example:
'NegClass',{'versicolor','setosa'}
Data Types:
single
|
double
|
categorical
|
char
|
string
|
cell
XCrit
—
Criterion to compute for
X
'fpr'
(default) |
'fnr'
|
'tnr'
|
'ppv'
|
'ecost'
| ...
Criterion to compute for
X
, specified as
the comma-separated pair consisting of
'XCrit'
and
one of the following.
| Criterion | Description |
|---|---|
tp
|
Number of true positive instances. |
fn
|
Number of false negative instances. |
fp
|
Number of false positive instances. |
tn
|
Number of true negative instances. |
tp+fp
|
Sum of true positive and false positive instances. |
rpp
|
Rate of positive predictions.
rpp =
(tp+fp)/(tp+fn+fp+tn)
|
rnp
|
Rate of negative predictions.
= (tn+fn)/(tp+fn+fp+tn) |
accu
|
Accuracy.
accu = (tp+tn)/(tp+fn+fp+tn)
|
tpr
, or
sens
, or
reca
|
True positive rate, or sensitivity, or recall.
sens = reca = tp/(tp+fn) |
fnr
, or
miss
|
False negative rate, or miss.
= miss = fn/(tp+fn) |
fpr
, or
fall
|
False positive rate, or fallout, or 1 – specificity.
fpr = fall = fp/(tn+fp)
|
tnr
, or
spec
|
True negative rate, or specificity.
= spec = tn/(tn+fp) |
ppv
, or
prec
|
Positive predictive value, or precision.
= prec = tp/(tp+fp) |
npv
|
Negative predictive value.
npv = tn/(tn+fn)
|
ecost
|
Expected cost.
ecost = (tp*Cost(P|P)+fn*Cost(N|P)+fp*
Cost(P|N)+tn*Cost(N|N))/(tp+fn+fp+tn)
|
| Custom criterion |
A custom-defined function with the input arguments
(C,scale,cost)
,
where
C
is a 2-by-2 confusion matrix,
scale
is
a 2-by-1 array of class scales, and
cost
is a 2-by-2
misclassification cost matrix.
|
Caution
Some of these criteria return
NaN
values
at one of the two special thresholds,
'reject all'
and
'accept
all'
.
Example:
'XCrit','ecost'
YCrit
—
Criterion to compute for
Y
'tpr'
(default) |
same criteria options for
X
XVals
—
Values for the
X
criterion
'all'
(default) |
numeric array
Values for the
X
criterion, specified as
the comma-separated pair consisting of
'XVals'
and
a numeric array.
If you specify
XVals
, then
perfcurve
computes
X
and
Y
and
the
pointwise
confidence bounds
for
Y
(when applicable)
only for the specified
XVals
.
If you do not specify
XVals
,
then
perfcurve
, computes
X
and
Y
and
the values for all scores by default.
Note
You cannot set
XVals
and
TVals
at
the same time.
Example:
'XVals',[0:0.05:1]
Data Types:
single
|
double
|
char
|
string
TVals
—
Thresholds for the positive class score
'all'
(default) |
numeric array
Thresholds for the positive class score, specified as the comma-separated
pair consisting of
'TVals'
and either
'all'
or
a numeric array.
If
TVals
is set to
'all'
or
not specified, and
XVals
is not specified, then
perfcurve
returns
X
,
Y
,
and
T
values for all scores and computes
pointwise confidence
bounds
for
X
and
Y
using
threshold averaging.
If
TVals
is set to a numeric
array, then
perfcurve
returns
X
,
Y
,
and
T
values for the specified thresholds and computes
pointwise confidence bounds for
X
and
Y
at
these thresholds using threshold averaging.
Note
You cannot set
XVals
and
TVals
at
the same time.
Example:
'TVals',[0:0.05:1]
Data Types:
single
|
double
|
char
|
string
UseNearest
—
Indicator to use the nearest values in the data
'on'
(default) |
'off'
Indicator to use the nearest values in the data instead of the specified numeric
XVals
or
TVals
, specified as the comma-separated pair
consisting of
'UseNearest'
and either
'on'
or
'off'
.
If you specify numeric
XVals
and set
UseNearest
to
'on'
, then
perfcurve
returns the nearest unique
X
values
found in the data, and it returns the corresponding values of
Y
and
T
.
If you specify numeric
XVals
and set
UseNearest
to
'off'
, then
perfcurve
returns the sorted
XVals
.
If you compute confidence bounds by cross validation or bootstrap, then this parameter
is always
'off'
.
Example:
'UseNearest','off'
ProcessNaN
—
perfcurve
method for processing
NaN
scores
'ignore'
(default) |
'addtofalse'
perfcurve
method for processing
NaN
scores,
specified as the comma-separated pair consisting of
'ProcessNaN'
and
'ignore'
or
'addtofalse'
.
If
ProcessNaN
is
'ignore'
,
then
perfcurve
removes observations with
NaN
scores
from the data.
If
ProcessNaN
is
'addtofalse'
,
then
perfcurve
adds instances with
NaN
scores
to false classification counts in the respective class. That is,
perfcurve
always
counts instances from the positive class as false negative (FN), and
it always counts instances from the negative class as false positive
(FP).
Example:
'ProcessNaN','addtofalse'
Prior
—
Prior probabilities for positive and negative classes
'empirical'
(default) |
'uniform'
|
array with two elements
Prior probabilities for positive and negative classes, specified
as the comma-separated pair consisting of
'Prior'
and
'empirical'
,
'uniform'
,
or an array with two elements.
If
Prior
is
'empirical'
,
then
perfcurve
derives prior probabilities from
class frequencies.
If
Prior
is
'uniform'
,
then
perfcurve
sets all prior probabilities to
be equal.
Example:
'Prior',[0.3,0.7]
Data Types:
single
|
double
|
char
|
string
Cost
—
Misclassification costs
[0 1;1 0]
(default) |
2-by-2 matrix
Misclassification costs, specified as the comma-separated pair
consisting of
'Cost'
and a 2-by-2 matrix, containing
[Cost(P|P),Cost(N|P);Cost(P|N),Cost(N|N)]
.
Cost(N|P)
is the cost of misclassifying a
positive class as a negative class.
Cost(P|N)
is
the cost of misclassifying a negative class as a positive class. Usually,
Cost(P|P)
=
0 and
Cost(N|N)
= 0, but
perfcurve
allows
you to specify nonzero costs for correct classification as well.
Example:
'Cost',[0 0.7;0.3 0]
Data Types:
single
|
double
Alpha
—
Significance level
Significance level for the confidence bounds, specified as the comma-separated pair
consisting of
'Alpha'
and a scalar value in the range 0 through 1.
perfcurve
computes 100*(1 –
α
) percent
pointwise confidence bounds
for
X
,
Y
,
T
, and
AUC
for a confidence level of 1 –
α
.
Example:
'Alpha',0.01
specifies 99% confidence bounds.
Data Types:
single
|
double
Weights
—
Observation weights
Observation weights, specified as the comma-separated pair consisting
of
'Weights'
and a vector of nonnegative scalar
values. This vector must have as many elements as
scores
or
labels
do.
If
scores
and
labels
are
in cell arrays and you need to supply
Weights
,
the weights must be in a cell array as well. In this case, every element
in
Weights
must be a numeric vector with as many
elements as the corresponding element in
scores
.
For example,
numel(weights{1}) == numel(scores{1})
.
When
perfcurve
computes the
X
,
Y
and
T
or
confidence bounds using cross-validation, it uses these observation
weights instead of observation counts.
When
perfcurve
computes confidence bounds
using bootstrap, it samples
N
out of
N
observations
with replacement, using these weights as multinomial sampling probabilities.
The default is a vector of 1s or a cell array in which each element is a vector of
Data Types:
single
|
double
|
cell
NBoot
—
Number of bootstrap replicas
Number of bootstrap replicas for computation of confidence bounds,
specified as the comma-separated pair consisting of
'NBoot'
and
a positive integer. The default value 0 means the confidence bounds
are not computed.
If
labels
and
scores
are
cell arrays, this parameter must be 0 because
perfcurve
can
use either cross-validation or bootstrap to compute confidence bounds.
Example:
'NBoot',500
Data Types:
single
|
double
BootType
—
Confidence interval type for
bootci
'bca'
(default) |
'norm
|
'per'
|
'cper'
|
'stud'
Confidence interval type for
bootci
to use to compute confidence intervals,
specified as the comma-separated pair consisting of
'BootType'
and one of
the following:
'bca'
— Bias corrected and
accelerated percentile method
'norm
or
'normal'
—
Normal approximated interval with bootstrapped bias and standard error
'per'
or
'percentile'
—
Percentile method
'cper'
or
'corrected percentile'
—
Bias corrected percentile method
'stud'
or
'student'
—
Studentized confidence interval
Example:
'BootType','cper'
BootArg
—
Optional input arguments for
bootci
{'Nbootstd',nbootstd}
Optional input arguments for
bootci
to compute confidence bounds, specified
as the comma-separated pair consisting of
'BootArg'
and
{'Nbootstd',nbootstd}
.
When you compute the studentized bootstrap confidence intervals (
'BootType'
is
'student'
), you can additionally specify the
'Nbootstd'
name-value pair argument of
bootci
by
using
'BootArg'
. For example,
'BootArg',{'Nbootstd',nbootstd}
estimates the standard error of the
bootstrap statistics using bootstrap with
nbootstd
data samples.
nbootstd
is a positive integer and its default is 100.
Example:
'BootArg',{'Nbootstd',nbootstd}
Data Types:
cell
Options
—
Options for controlling the computation of confidence intervals
[]
(default) |
structure array returned by
statset
Options for controlling the computation of confidence intervals, specified as the
comma-separated pair consisting of
'Options'
and a structure array
returned by
statset
. These options require Parallel Computing Toolbox™.
perfcurve
uses this argument for computing pointwise
confidence bounds only. To compute these bounds, you must pass cell arrays for
labels
and
scores
or set
NBoot
to a positive integer.
This table summarizes the available options.
| Option | Description |
|---|---|
'UseParallel'
|
|
'UseSubstreams'
|
|
'Streams'
|
A
In that case, use a cell array of the same size as the parallel pool. If a
parallel pool is not open, then
'UseParallel'
is
true
and
'UseSubstreams'
is
false
,
then the length of
'Streams'
must equal the number
of workers used by
perfcurve
. If a parallel pool
is already open, then the length of
'Streams'
is
the size of the parallel pool. If a parallel pool is not already open,
then MATLAB
®
might open a pool for you, depending on your installation
and preferences. To ensure more predictable results, use
parpool
(Parallel Computing Toolbox)
and explicitly create a parallel
pool before invoking
perfcurve
and setting
'Options',statset('UseParallel',true)
.
Example:
Data Types:
Output Arguments
|