現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
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?
Star Strider
2017 年 5 月 12 日
Use the testing sample and the classifications from it for both vectors.
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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 (한국어)