function [FinalRules, Rules]=Apriori(T,MST,MCT)
% Create Items Set
Items=[];
for i=1:numel(T)
Items=union(Items,T{i});
end
Items=Items(:)';
% 1st level Candidates
C{1}=cell(1,numel(Items));
count{1}=zeros(size(C{1}));
for r=1:numel(Items)
C{1}{r}=Items(r);
*for i=1:numel(T)*
if IsContainedIn(C{1}{r},T{i})
count{1}(r)=count{1}(r)+1;
end
end
end

4 Kommentare

KSSV
KSSV am 2 Jan. 2017
where are the inputs? How you have called the function? I think you have called the function without T, that's why error popped.
Bhupesh Rawat
Bhupesh Rawat am 10 Jan. 2017
Sir, but the same code is working with another data set.
Stephen23
Stephen23 am 10 Jan. 2017
@Bhupesh Rawat: please show us the complete error message, which means all of the red text. Also show us or tell us exactly how you are calling this function.
Bhupesh Rawat
Bhupesh Rawat am 10 Jan. 2017
The complete error message is given below:
??? Input argument "T" is undefined.
Error in ==> Apriori at 18 for i=1:numel(T)
I am calling function as below: clc;
clear;
close all;
%% Load Data
data=load('smalldata');
T=data.textdata;
%% Apriori
MST=0.22; % Minimum Support Threshold
MCT=0.6; % Minimum Confidence Threshold
[FinalRules, Rules]=Apriori(T,MST,MCT);
%% Results
disp('Final Rules:');
disp(' ');
DisplayRules(FinalRules);
disp(' ');

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

Guillaume
Guillaume am 10 Jan. 2017

0 Stimmen

As others have said, we need the full text of the error message and more details about how you call the function to help you with that error.
Saying that, the code shown can be greatly simplified, particularly if we assume that:
  1. The cell array T contains only row vectors
  2. There are no duplicates in individual row vectors.
If that is the case, then:
[Items, ~, dist] = unique([T{:}]);
Items = Items.';
C{1} = num2cell(Items);
count{1} = accumarray(dist, 1).';
If one or both assumption is broken then:
T = cellfun(@unique, T, 'UniformOutput', false);
[Items, ~, dist] = unique(vertcat(T{:}));
Items = Items.';
C{1} = num2cell(Items);
count{1} = accumarray(dist, 1).';

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by