How can i correct this error?
古いコメントを表示
In this above mentioned blog, it has the code of what i have done. In that code, the below mentioned code of lines when executed showed the error :
Attempt to reference field of non-structure array.
Error in @(x)length(x.freqSets)
Below is the mentioned code:
minSup = 0.6; % minimum support threshold 0.6
[F,S] = findFreqItemsets(transactions,minSup);
fprintf('Minimum Support : %.2f\n', minSup)
fprintf('Frequent Itemsets Found: %d\n', sum(arrayfun(@(x) length(x.freqSets), F)))
fprintf('Max Level Reached : %d-itemsets\n', length(F))
fprintf('Number of Support Data : %d\n', length(S))
I have created a file named findFreqItemsets in the same path, which includes the following code.
function [F,S,items] = findFreqItemsets(transactions,minSup,oneItemsets)
F = -999999; % Default to -999999.
S = -1; % Default to -1.
items = struct('freqSets', []);
How can i correct this error? I want to perform the association rule using this, so how can i edit this code to correct tis error?
2 件のコメント
Jan
2015 年 12 月 20 日
I've formatted your code. Mark the code blocks before you press the "{} Code" button.
Walter Roberson
2015 年 12 月 20 日
Other volunteers: I posted a number of answers to this (and the identical question) last night, but they were all rejected by the user so I deleted them. The user needs to go back to using the code from the blog and simply send it different input, but is apparently unwilling to do so.
Every one of the outputs the user creates in their attempted code is the wrong data type: the first output needs to be a structure with a field FreqSets, the second needs to be a container.Map, and the third needs to be a cell array. Just like is computed by the code they completely replaced.
回答 (2 件)
Perhaps you mean:
[F,S, items] = findFreqItemsets(transactions,minSup);
fprintf('Minimum Support : %.2f\n', minSup)
fprintf('Frequent Itemsets Found: %d\n', ...
sum(arrayfun(@(x) length(x.freqSets), items)))
The first output F is -999999, so it is not a struct, but the 3rd output is one.
1 件のコメント
PARVATHY P P
2015 年 12 月 20 日
編集済み: Walter Roberson
2015 年 12 月 20 日
No i am still getting with this code, after making modifications in the file findFreqItemsets:
[F,S] = findFreqItemsets(transactions,minSup);
fprintf('Minimum Support : %.2f\n', minSup)
fprintf('Frequent Itemsets Found: %d\n', ...
sum(arrayfun(@(x) length(x.freqSets), items)))
Attempt to reference field of non-structure array.
Error in @(x)length(x.freqSets)
Modifications i have done in the file:
function [F,S,items] = findFreqItemsets(transactions,minSup,oneItemsets)
F = -999999; % Default to -999999.
S = -1; % Default to -1.
items = struct('freqSets', []);
Walter Roberson
2015 年 12 月 20 日
0 投票
Sorry, you will need to find a different programming language to use; MATLAB is not able to handle your requirements.
You want MATLAB to treat values as simultaneously being structures and non-structures. MATLAB is not able to do that. You will need to find a different programming language that implements RPM (Read Programmers Mind), or DWIWNWIS (Do What I Want Not What I Say).
カテゴリ
ヘルプ センター および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!