0

前の質問からのリードFCM数値データとcsv/excelファイルのクラスタリング出力された情報を取得し、matlabでのクラスタリングで使用するための実行可能な.datファイルを作成する方法を理解しようとしています。

    %# 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クラスタリングツールは多次元データセットで機能しますが、2次元でのみ表示されます。次に、x軸とy軸を使用して比較しますが、現在のデータからクラスタリング2D分析を作成できるかどうかはよくわかりません。

私がする必要があるのは、以前の投稿からのmファイルを正規化することですFCMクラスタリング数値データとcsv/excelファイル

データを正規化するには:

  1. 最小および最大のデータセットを見つける

  2. 正規化されたスケールの最小値と最大値

  3. データセット内の番号

  4. 正規化された値

したがって、最初の質問は、データセット内の最小数と最大数をどのように見つけるかです(m)

ステップ1:データセット内の最大値と最小値を見つけて、変数capitalAとcapitalBで表します。

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

質問の途中でエラーを確認します。a = load(matfile)ASCIIベースのMATファイル形式でサポートされていない構造を返します。ドキュメントを読んでみてください。

于 2011-10-11T19:19:05.437 に答える