0

从上一个问题开始FCM Clustering numeric data and csv/excel file我现在试图弄清楚如何获取输出的信息并创建一个可行的 .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);

我有几种类型的数据,如下所示:

在此处输入图像描述

我尝试了以下方法来创建一个 .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 和 csv/excel 文件中的 m 文件

规范化数据:

  1. 找到最小和最大数据集

  2. 标准化比例最小值和最大值

  3. 数据集中的数字

  4. 标准化值

所以第一个问题是我如何找到我的数据集中的最小和最大数字(m)

步骤 1:找到数据集中的最大值和最小值,并用变量大写 A 和大写 B 表示它们:

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

第 2 步规范化确定最小和最大数字并将变量设置为小写 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
4

1 回答 1

1

Looking at the errors in the middle of your question. a = load(matfile) returns a structure, which is not supported by the ASCII-based MAT-file format. Try reading the documentation.

于 2011-10-11T19:19:05.437 回答