이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
what is the value of predicted and actual?
조회 수: 4 (최근 30일)
이전 댓글 표시
MANIMEGALAI SELVARAJ
2017년 2월 19일
function EVAL = Evaluate(ACTUAL,PREDICTED)
% This fucntion evaluates the performance of a classification model by
% calculating the common performance measures: Accuracy, Sensitivity,
% Specificity, Precision, Recall, F-Measure, G-mean.
% Input: ACTUAL = Column matrix with actual class labels of the training
% examples
% PREDICTED = Column matrix with predicted class labels by the
% classification model
% Output: EVAL = Row matrix with all the performance measures
idx = (ACTUAL()==1);
p = length(ACTUAL(idx));
n = length(ACTUAL(~idx));
N = p+n;
tp = sum(ACTUAL(idx)==PREDICTED(idx));
tn = sum(ACTUAL(~idx)==PREDICTED(~idx));
fp = n-tn;
fn = p-tp;
tp_rate = tp/p;
tn_rate = tn/n;
accuracy = (tp+tn)/N;
sensitivity = tp_rate;
specificity = tn_rate;
precision = tp/(tp+fp);
recall = sensitivity;
f_measure = 2*((precision*recall)/(precision + recall));
gmean = sqrt(tp_rate*tn_rate);
EVAL = [accuracy sensitivity specificity precision recall f_measure gmean];
댓글 수: 1
채택된 답변
Star Strider
2017년 2월 19일
From the documenbtation:
% Input: ACTUAL = Column matrix with actual class labels of the training
% examples
% PREDICTED = Column matrix with predicted class labels by the
% classification model
I would assume that ‘matrix’ is ‘vector’ here. The ‘ACTUAL’ values are whatever the original classifications are, and the ‘PREDICTED’ the results of your classifier. The values likely depend on the original ‘correct’ classifications and your classifier output.
댓글 수: 31
oza san
2017년 5월 12일
편집: oza san
2017년 5월 12일
dear Star i have been trying to use the above code but i stack with an error "index exceeds matrix dimensions. Error in Evaluate1 (line 21) tp = sum(ACTUAL(idx)==d(idx));" what can i do?
if true
newX=load('C:\Users\sam\Desktop\dataset\pred.mat');%to load the classifier output!
d = struct2cell(newX); % to change its format from struct to cell array
ACTUAL = zeros(2000,1); the orginal value
ACTUAL(1:1000) = 0;% setfirst 1000 row as negative sapmle
ACTUAL(1001:end) = 1; % set the rest as postive sample
the rest of the code is as it is!!
end
Star Strider
2017년 5월 12일
You must be certain your ‘ACTUAL’ and ‘d’ vectors are the same sizes (same number of rows and columns in each).
oza san
2017년 5월 12일
Dear Star thank you for your fast replay.ok.i will try that way but since ACTUAL is the value of the training sample how it could be equal with testing sample which is 20% of the training sample?
oza san
2017년 5월 12일
ya i test it manually and works fine.before i give the the test sample for the classifier i set the values for it[0 and 1]. then i get the classifier output with the same column number finally i use both of them for evaluation.
oza san
2017년 5월 14일
Dear sir,here i am again i need to extract a word from a sentence in an image using vertical projection profile mind you if you have some ample codes?
Star Strider
2017년 5월 14일
Post this as a new Question.
Image processing is not an area of my expertise.
I cannot help you with it.
oza san
2017년 5월 15일
편집: oza san
2017년 5월 15일
Dear Sir, i tried to load my actual and predicted values to calculate performance measures but i can't load the data.i get an error"Undefined operator '==' for input arguments of type 'cell'."!! actually when i give the actual manually it woks fine!!!the problem is it can not load the data found in .mat file. what can i do?
if true
% code
ACTUAL=load('C:\Users\sam\Desktop\dataset\ACTUAL.mat');%load actual
pred=load('C:\Users\sam\Desktop\dataset\pred.mat');%load predicted
c = struct2cell(ACTUAL);%change the struct to cell
d = struct2cell(pred);%change the struct to cell
idx = (c()==1);
p = length(c(idx));
n = length(c(~idx));
N = p+n;
tp = sum(c(idx)==d(idx));
tn = sum(c(~idx)==d(~idx));
fp = n-tn;
end
Star Strider
2017년 5월 15일
The only place I see that is in your ‘idx’ assignment.
This should work:
c = {1 2 6 1 3 7 9 1}; % Create Test Data
idx = cellfun(@eq, c, mat2cell(ones(size(c)), 1, ones(size(c))), 'Uni',0);
idx = [idx{:}];
oza san
2017년 5월 15일
편집: oza san
2017년 5월 15일
i cam up with an error"Input arguments, D1 through D2, must sum to each dimension of the input matrix size, [200 1].'"
if true
% code
c= zeros(200,1); creating test data
c(1:end) = 1;
idx = cellfun(@eq, c, mat2cell(ones(size(c)), 1, ones(size(c))), 'Uni',0);
idx = [idx{:}]
end
Star Strider
2017년 5월 15일
You didn’t tell me what size ‘c’ is.
Try this:
idx = cellfun(@eq, c, mat2cell(ones(size(c)), ones(size(c)), 1), 'Uni',0);
Star Strider
2017년 5월 15일
This works correctly for me:
c = {1 2 6 1 3 7 9 1}'; % Create Test Data
idx = cellfun(@eq, c, mat2cell(ones(size(c)), ones(size(c)), 1), 'Uni',0)
idx = [idx{:}]
I cannot determine what the problem may be with respect to your code.
I am using R2017a. There could be version differences in the way the functions work.
Star Strider
2017년 5월 15일
I thought ‘c’ was already a cell array. That was the original problem.
What is the result when you run this from your Command Window (or script):
whos c
oza san
2017년 5월 15일
here is what i get Name Size Bytes Class Attributes
c 200x1 1600 double
Name Size Bytes Class Attributes
d 200x1 22800 cell
Star Strider
2017년 5월 15일
I don’t understand that in the context of these earlier assignments:
c = struct2cell(ACTUAL);%change the struct to cell
d = struct2cell(pred);%change the struct to cell
oza san
2017년 5월 15일
i thought that both actual and predicted value are structure so i tried to convert to cell array.but now i ignore.
Star Strider
2017년 5월 15일
I’m lost.
If ‘c’ is a double array, your original:
idx = c == 1;
should work.
oza san
2017년 5월 15일
" Undefined operator '==' for input arguments of type 'cell'."
tp = sum(c(idx) == d(idx));what is wrong with this one?
oza san
2017년 5월 15일
Dear sir i make you too busy let me see it by myself and if i can't i will be back.
Nowshin Jenny
2018년 12월 19일
Dear sir, after using this command in my code for EEG signal classification, I got following error-
"Function definitions are not permitted in this context."
How can i solve it?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 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)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)