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 Commenti

Jan
Jan il 20 Dic 2015
I've formatted your code. Mark the code blocks before you press the "{} Code" button.
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.

Accedi per commentare.

Risposte (2)

Jan
Jan il 20 Dic 2015
Modificato: Jan il 20 Dic 2015
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 Commento

PARVATHY P P
PARVATHY P P il 20 Dic 2015
Modificato: Walter Roberson il 20 Dic 2015
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', []);

Accedi per commentare.

Walter Roberson
Walter Roberson il 20 Dic 2015

0 voti

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

Categorie

Scopri di più su App Building in Centro assistenza e File Exchange

Tag

Richiesto:

il 20 Dic 2015

Commentato:

il 20 Dic 2015

Community Treasure Hunt

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

Start Hunting!

Translated by