Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm MATLAB中遗传算法在权重优化中的应用_Algorithm_Matlab_Genetic Algorithm - Fatal编程技术网

Algorithm MATLAB中遗传算法在权重优化中的应用

Algorithm MATLAB中遗传算法在权重优化中的应用,algorithm,matlab,genetic-algorithm,Algorithm,Matlab,Genetic Algorithm,我是遗传算法新手,希望你们能帮我 我有一个数据集: dataset = [[3 4 4 4] ;[2 3 2 3] ;[1 1 3 2] ;[3 2 4 3] ;[0 3 1 0]]; 其中最后一列[4,3,2,3,0]表示实际标签;前三列表示特征向量[x1 x2 x3] 我想用遗传算法优化权重[w1 w2 w3] 我怎样才能做到这一点 您的权重是您的优化变量。对于最基本的优化: w = [w1 w2 w3]; x

我是遗传算法新手,希望你们能帮我

我有一个数据集:

dataset = [[3 4 4 4]
          ;[2 3 2 3]
          ;[1 1 3 2]
          ;[3 2 4 3]
          ;[0 3 1 0]];
其中最后一列
[4,3,2,3,0]
表示实际标签;前三列表示特征向量
[x1 x2 x3]

我想用遗传算法优化权重
[w1 w2 w3]


我怎样才能做到这一点

您的权重是您的优化变量。对于最基本的优化:

w = [w1 w2 w3];
x = [x1 x2 x3];
wOpt = ga(@fitnessfunc(w, x), length(w))

function y = fitnessfunc(w,x)
    y = w(1) * x(1) + w(2) * x(2) + w(3) * x(3);
有关
ga
函数调用的更多选项以及如何构造程序,请参阅

记住,你的权重是你正在优化的变量。
数据集
x
值只是额外的参数