Info
此问题已关闭。 请重新打开它进行编辑或回答。
error in for loop
2 次查看(过去 30 天)
显示 更早的评论
1 Input: Dataset with i continuous attribute, M examples and S target classes;
2 Begin
3 For each continuous attribute Ai
4 Find the maximum dn and the minimum d0 values of Ai;
5 Form a set of all distinct values of A in ascending order;
6 Initialize all possible interval boundaries B with the minimum and maximum
7 Calculate the midpoints of all the adjacent pairs in the set;
8 Set the initial discretization scheme as D: {[d0,dn]}and Globalcacc = 0;
9 Initialize k = 1;
10 For each inner boundary B which is not already in scheme D,
11 Add it into D;
12 Calculate the corresponding cacc value;
13 Pick up the scheme D’ with the highest cacc value;
14 If cacc > Globalcacc or k < S then
15 Replace D with D’;
16 Globalcacc = cacc;
17 k = k + 1;
18 Goto Line 10;
18 Else
19 D’ = D;
20 End If
21 Output the Discretization scheme D’ with k intervals for continuous attribute Ai;
22 End
i have completed till step 8
i am struck in for loop can u tell how to process please
B is a matrix
for calculating cacc i have posted in my previous post
please help
8 个评论
回答(1 个)
Daniel Shub
2012-1-9
Doing things like:
F=OriginalData
F1=F(:,1);
F2=F(:,2);
F3=F(:,3);
F4=F(:,4);
F5=F(:,5);
F6=F(:,6);
is really ugly and rarely useful in MATLAB. I would suggest reading the getting start section of the manual ( http://www.mathworks.co.uk/help/techdoc/learn_matlab/bqr_2pl.html ) and the FAQ ( http://matlab.wikia.com/wiki/FAQ ). This will be more beneficial to you in the long run.
You should also search this site for the reasons not to use
clear all
at the beginning of your code.
Finally, please look at: http://www.mathworks.co.uk/matlabcentral/answers/6200-tutorial-how-to-ask-a-question-on-answers-and-get-a-fast-answer
and href=""<http://www.mathworks.co.uk/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup</a>>
3 个评论
Daniel Shub
2012-1-9
I am not IA. I would say the original F is an elegant way to present F instead of F1, F2, ... F6. My guess is I could code for you line 9 and help with cacc, but I am not going to. Spend a little time reading and working through the documentation and FAQs, and I bet this will all become much easier.
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!