2011-10-10 7 views
1

こんにちは私は妥当な答えを与えた以前の質問をしました。私はトラックに戻ってきたと思いました。Fuzzy c-means tcp dump clustering in matlab問題は以下のtcp/udpデータの前処理段階です私の質問:FCM数値データとcsv/excelファイル

1)どのように私は、またはどのように数値データにセル内のテキストデータを変換する最良の方法は?数値はどうなるべきですか?

編集: Excelの私のデータは次のようになります。

enter image description here

0,tcp,http,SF,239,486,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,8,8,0.00,0.00,0.00,0.00,1.00,0.00,0.00,19,19,1.00,0.00,0.05,0.00,0.00,0.00,0.00,0.00,normal. 
+0

「1」から「1」への変換、または「tcp」から数値への変換を意味しますか? – Nzbuu

+0

tcpから番号 –

答えて

2

ここでは、私はMATLABにデータを読んでいまし方法の例です。データ自体はカンマで区切った形式で、その形式(数字、名義)とともにlist of featuresの2つが必要です。

%# 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); 

Statistics ToolboxからDATASETクラスを調べることもできます。

+0

ねえ、これは素晴らしいよ!私はまだデータから.datファイルを構築する方法を知っていないので、新しい質問が作成されます。データセットのリンクは、自己のトラブルシューティングのためのものです。 –

関連する問題