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
John D'Errico 2015년 12월 20일
STOP POSTING THE SAME IDENTICAL QUESTION.
Walter Roberson
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
PARVATHY P P 2015년 12월 21일
i am still getting same error
Walter Roberson
Walter Roberson 2015년 12월 21일
What is your current code?
PARVATHY P P
PARVATHY P P 2015년 12월 21일
편집: Walter Roberson 2015년 12월 21일
function [F,S,items] = findFreqItemsets(transactions,minSup,Itemsets)
F = cell2struct({},'',1); % Default to -999999.
S =struct(); % Default to -1.
items = struct('freqSets', []);
This is my file code now
PARVATHY P P
PARVATHY P P 2015년 12월 21일
편집: Walter Roberson 2015년 12월 21일
Now the answer is not exact
I am getting the following:
Minimum Support : 0.60
Frequent Itemsets Found: 0
Max Level Reached : 0-itemsets
Number of Support Data : 1
Instead of:
Minimum Support : 0.60
Frequent Itemsets Found: 8
Max Level Reached : 2-itemsets
Number of Support Data : 13
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
PARVATHY P P 2015년 12월 21일
By changing my code to this, i am getting the same output, which is not exact
Walter Roberson
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
PARVATHY P P 2015년 12월 21일
But i want the same output as in the blog
Walter Roberson
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
PARVATHY P P 2015년 12월 21일
편집: PARVATHY P P 2015년 12월 21일
I got it
Walter Roberson
Walter Roberson 2015년 12월 21일
Do you mean the question is resolved?

댓글을 달려면 로그인하십시오.

 채택된 답변

Geoff Hayes
Geoff Hayes 2015년 12월 19일

0 개 추천

The first line of your findFreqItemsets.m file includes text that is not commented out
findFreqItemsets() generates frequent itemsets using the Apriori method.
function [F,S,items] = findFreqItemsets(transactions,minSup,oneItemsets)
Try changing this to
% findFreqItemsets() generates frequent itemsets using the Apriori method.
function [F,S,items] = findFreqItemsets(transactions,minSup,oneItemsets)
and re-run your code.

댓글 수: 2

PARVATHY P P
PARVATHY P P 2015년 12월 20일
No after doing that , i am still getting the same error
PARVATHY P P
PARVATHY P P 2015년 12월 21일
Finally i got the result, Thanking you all for the support.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Walter Roberson
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에 대해 자세히 알아보기

태그

질문:

2015년 12월 19일

댓글:

2015년 12월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by