how do 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.
findFreqItemsets() generates frequent itemsets using the Apriori method.
function [F,S,items] = findFreqItemsets(transactions,minSup,oneItemsets)
F = -999999; % Default to -999999.
S = -1; % Default to -1.
items = struct('freqSets', []);
%FINDFREQITEMSETS generates frequent itemsets using Apriori method
% |transactions| is a nested cell array of transaction data or a table
% with |Value| column that contains such cell array. Each row contains a
% nested cell array of items in a single transaction. If supplied as a
% table, it also needs |Key| column with a cell array of transaction ids.
%etc
What was wrong with the lines of the above written file code? How do i correct my error?
댓글 수: 13
John D'Errico
2015년 12월 20일
STOP POSTING THE SAME IDENTICAL QUESTION.
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.
PARVATHY P P
2015년 12월 21일
Walter Roberson
2015년 12월 21일
What is your current code?
PARVATHY P P
2015년 12월 21일
편집: Walter Roberson
2015년 12월 21일
PARVATHY P P
2015년 12월 21일
편집: Walter Roberson
2015년 12월 21일
Walter Roberson
2015년 12월 21일
function [F,S,items] = findFreqItemsets(transactions,minSup,Itemsets)
F = struct('freqSets', {});
S = containers.Map();
items = {};
However, since you are not creating any data, you should not expect to get any non-zero items for the output (except for Minimum Support.)
PARVATHY P P
2015년 12월 21일
Walter Roberson
2015년 12월 21일
That is because that is the output for the findFreqItemsets code and input data that is in the blog, not for the findFreqItemsets that you are replacing it with. I still say you should be using the code that is in the blog.
PARVATHY P P
2015년 12월 21일
Walter Roberson
2015년 12월 21일
To get the same output as the blog you should use the same code as the blog and the same input as the blog.
Did you not look in the blog to the section near the end "Appendix: Code used for this post" ??
PARVATHY P P
2015년 12월 21일
편집: PARVATHY P P
2015년 12월 21일
Walter Roberson
2015년 12월 21일
Do you mean the question is resolved?
채택된 답변
추가 답변 (1개)
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에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!