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 Kommentare

John D'Errico
John D'Errico am 20 Dez. 2015
STOP POSTING THE SAME IDENTICAL QUESTION.
Walter Roberson
Walter Roberson am 20 Dez. 2015
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 am 21 Dez. 2015
i am still getting same error
Walter Roberson
Walter Roberson am 21 Dez. 2015
What is your current code?
PARVATHY P P
PARVATHY P P am 21 Dez. 2015
Bearbeitet: Walter Roberson am 21 Dez. 2015
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 am 21 Dez. 2015
Bearbeitet: Walter Roberson am 21 Dez. 2015
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 am 21 Dez. 2015
By changing my code to this, i am getting the same output, which is not exact
Walter Roberson
Walter Roberson am 21 Dez. 2015
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 am 21 Dez. 2015
But i want the same output as in the blog
Walter Roberson
Walter Roberson am 21 Dez. 2015
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 am 21 Dez. 2015
Bearbeitet: PARVATHY P P am 21 Dez. 2015
I got it
Walter Roberson
Walter Roberson am 21 Dez. 2015
Do you mean the question is resolved?

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Geoff Hayes
Geoff Hayes am 19 Dez. 2015

0 Stimmen

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 Kommentare

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 20 Dez. 2015

0 Stimmen

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).

Kategorien

Mehr zu Get Started with MATLAB finden Sie in Hilfe-Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by