1

我很难将制表符分隔的输入文件加载到 MATLAB nprtool 中,我认为这是因为 nprtool GUI 不支持加载混合数据类型。我正在加载的 .tab 文件大约有 1100 个数据样本(行),每个样本看起来像:

864 1342470776.212023000    172.25.177.41   155.34.234.20   HTTP    440 58689   http-alt    GET http://i.cdn.turner.com/cnn/.e/img/3.0/global/header/hdr-main.gif   image/png,image/*;q=0.8,*/*;q=0.5   gzip,deflate            0.000094000     http://www.cnn.com/

以上只是输入向量中的一个样本。我尝试使用 nprtool GUI 加载文件,但它无法正确识别数据。它将所有内容都视为“文本数据”,“数据”部分中有一些垃圾。然后,我尝试通过脚本在没有 GUI 的情况下执行此操作。此方法会引发错误(如下)。有什么办法吗?下面是我用来加载文件和错误的脚本片段。任何帮助表示赞赏。谢谢!

text1 = fopen('/Users/cgarry/Desktop/CRANEUM/output.tab');
pacTargets = importdata('/Users/cgarry/Desktop/CRANEUM/data.tab','\t');
pacInputs = textscan(text1,'%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s');
fclose(text1);

inputs = pacInputs;
targets = pacTargets;

% Create a Pattern Recognition Network
hiddenLayerSize = 10;
net = patternnet(hiddenLayerSize);


% Setup Division of Data for Training, Validation, Testing
net.divideParam.trainRatio = 70/100;
net.divideParam.valRatio = 15/100;
net.divideParam.testRatio = 15/100;


% Train the Network
[net,tr] = train(net,inputs,targets);

% Test the Network
outputs = net(inputs);
errors = gsubtract(targets,outputs);
performance = perform(net,targets,outputs);

% View the Network
view(net)

% Plots
% Uncomment these lines to enable various plots.
%figure, plotperform(tr)
%figure, plottrainstate(tr)
%figure, plotconfusion(targets,outputs)
%figure, ploterrhist(errors)


>> nnet
Error using trainscg (line 97)
Inputs X{1,1} is not numeric or logical.

Error in network/train (line 106)
[net,tr] = feval(net.trainFcn,net,X,T,Xi,Ai,EW,net.trainParam);

Error in nnet (line 21)
[net,tr] = train(net,inputs,targets);
4

1 回答 1

1

Thats right, Matlab Neural network doesn't support mixed data type. But don't worry there are multiple ways to handle this. The easiest way is to categorize your data. For example all data including HTTP are represented with 1 while other can be represent by 2, 3,.... There are some other softwares available. I think R neural net package can handle this (not sure).

于 2012-08-11T04:14:59.833 回答