2011-10-11 27 views
0

从以前的问题FCM Clustering numeric data and csv/excel file林正试图找出如何采取outputed信息,并创建了与MATLAB集群使用一个可行的.dat文件领先的。Matlab的集群和数据格式

%# read the list of features 
fid = fopen('kddcup.names','rt'); 
C = textscan(fid, '%s %s', 'Delimiter',':', 'HeaderLines',1); 
fclose(fid); 

%# determine type of features 
C{2} = regexprep(C{2}, '.$','');    %# remove "." at the end 
attribNom = [ismember(C{2},'symbolic');true]; %# nominal features 

%# build format string used to read/parse the actual data 
frmt = cell(1,numel(C{1})); 
frmt(ismember(C{2},'continuous')) = {'%f'}; %# numeric features: read as number 
frmt(ismember(C{2},'symbolic')) = {'%s'}; %# nominal features: read as string 
frmt = [frmt{:}]; 
frmt = [frmt '%s'];       %# add the class attribute 

%# read dataset 
fid = fopen('kddcup.data','rt'); 
C = textscan(fid, frmt, 'Delimiter',','); 
fclose(fid); 

%# convert nominal attributes to numeric 
ind = find(attribNom); 
G = cell(numel(ind),1); 
for i=1:numel(ind) 
    [C{ind(i)},G{i}] = grp2idx(C{ind(i)}); 
end 

%# all numeric dataset 
M = cell2mat(C); 

我有几种类型的数据,看起来像这样:

enter image description here

我想下面的方法来创建.dat文件,但与错误想出了:

>> a = load('matlab.mat'); 
>> save 'matlab.dat' a -ascii 
Warning: Attempt to write an unsupported data type 
to an ASCII file. 
    Variable 'a' not written to file. 
>> a = load('data.mat'); 
>> save 'matlab.dat' a -ascii 
Warning: Attempt to write an unsupported data type 
to an ASCII file. 
    Variable 'a' not written to file. 
>> save 'matlab.dat' a 
>> findcluster('matlab.dat') 
??? Error using ==> load 
Number of columns on line 1 of ASCII file 
C:\Users\Garrith\Documents\MATLAB\matlab.dat 
must be the same as previous lines. 

Error in ==> findcluster>localloadfile at 471 
     load(filename); 

Error in ==> findcluster at 160 
     localloadfile(filename, param); 

Matlabs聚类工具适用于多维数据集,但只显示两个 尺寸。然后,您使用x和y轴进行比较,但是我不太确定是否可以从当前数据创建聚类2d分析?

我需要做的是从我以前的帖子FCM Clustering numeric data and csv/excel file

正常化M档数据标准化的:

  1. 发现的最小和最大的数据集

  2. 标准化规模最小和在数据最大

  3. 号码设置

  4. 标准值

所以,第一个问题是我怎么找到我的数据集的最小和最大数(M)

第1步: 查找数据集中的最大值和最小值并代表他们与变量资本和资本B:

Lets say minimum number A = 92000 
and max number say B = 64525000 

第二步正常化 确定的最小和最大数,并设置杂物统计局小写a和b 不确定(你如何规范化数据下手不知道)如何在MATLAB做到这一点

set the minimum = a = 1 
set the maximum = b = 10 

第3步 计算任意数x的标准化值利用方程

A = 92000 
B = 64525000 
a = 1 
b = 10 
x = 2214000 

a + (x - A)(b - a)/(B - A) 
1+(2214000 - 92000)(10-1)/(6425000 - 92000) 
= 4.01 
+0

这是两个独立的问题。 – Nzbuu

回答

1

看着你的问题中间的错误。 a = load(matfile)返回一个结构,它不受基于ASCII的MAT文件格式的支持。尝试阅读文档。