MATLAB中的自组织映射(SOM)问题 [英] Self-Organizing Maps (SOM) problem in MATLAB

查看:378
本文介绍了MATLAB中的自组织映射(SOM)问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含数据的文本文件. 我的文本文件:

I have a text file that include data. My text file:

young, myopic, no, reduced, no
young, myopic, no, normal, soft
young, myopic, yes, reduced, no
young, myopic, yes, normal, hard
young, hyperopia, no, reduced, no
young, hyperopia, no, normal, soft
young, hyperopia, yes, reduced, no
young, hyperopia, yes, normal, hard

我阅读了我的文本文件加载方法

I read my text file load method

%young=1
%myopic=2
%no=3 etc.

load iris.txt
net = newsom(1,[1 5]);
[net,tr] = train(net,1);
plotsomplanes(net);

错误代码:

???未定义的函数或方法 'plotsomplanes'作为输入参数 输入网络".

??? Undefined function or method 'plotsomplanes' for input arguments of type 'network'.

推荐答案

鉴于您正在显示的文本文件,LOAD功能将无法使用.您应该使用 TEXTSCAN 来解析文本文件.然后,我使用 GRP2IDX 将标称数据转换为数值属性(它将为每个属性值分配1,2,3,..).在这种情况下,数据变为:

Given the text file you're showing, the LOAD function will not work. You should use TEXTSCAN to parse the text file. I then use GRP2IDX to convert the nominal data into numeric attributes (it will assign 1,2,3,.. for each attribute values). In this case the data becomes:

>> data =
     1     1     1     1     1
     1     1     1     2     2
     1     1     2     1     1
     1     1     2     2     3
     1     2     1     1     1
     1     2     1     2     2
     1     2     2     1     1
     1     2     2     2     3

>> labels{:}
ans = 
    'young'
ans = 
    'myopic'
    'hyperopia'
ans = 
    'no'
    'yes'
ans = 
    'reduced'
    'normal'
ans = 
    'no'
    'soft'
    'hard'

我应该提到,您可能需要一个更大的数据集(更多实例)才能获得有意义的结果...

I should mention that you will probably need a much larger dataset (more instances) to get any meaningful results...

%# read text file
fid = fopen('iris.txt');
D = textscan(fid, '%s %s %s %s %s', 'Delimiter',',');
fclose(fid);

%# convert nominal to numeric
%#data = cell2mat( cellfun(@grp2idx, D, 'UniformOutput',false) );
data = zeros(numel(D{1}),numel(D));
labels = cell(size(D));
for i=1:numel(D)
    [data(:,i) labels{i}] = grp2idx(D{i});
end

%# build SOM
net = newsom(data', [4 4]);
[net,tr] = train(net, data');
figure, plotsomhits(net, data')
figure, plotsomplanes(net)

这篇关于MATLAB中的自组织映射(SOM)问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆