【问题标题】:Self-Organizing Maps (SOM) problem in MATLABMATLAB 中的自组织映射 (SOM) 问题
【发布时间】:2011-06-02 11:37:00
【问题描述】:

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

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

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

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

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

错误代码:

???未定义的函数或方法 'plotsomplanes' 用于输入参数 输入“网络”。

【问题讨论】:

    标签: matlab machine-learning som self-organizing-maps


    【解决方案1】:

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

    >> 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'
    

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

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

    【讨论】:

      猜你喜欢
      • 2012-02-03
      • 1970-01-01
      • 1970-01-01
      • 2010-12-10
      • 2012-10-16
      • 2016-11-08
      • 2022-12-11
      • 2018-08-13
      • 2010-12-07
      相关资源
      最近更新 更多