不等号1314 2014-02-28 08:55
浏览 2058

你好 elm分类输出真实数据然后对于接下来进行类别输出部分我不懂它是如何类别分类的

下面是进行类别输出
MatrixXd tempY=mScores;
//int size=tempY.size();
double *Y=new double[nsmp];
double *Max=new double[nsmp];
double max=0.0;
double *min=new double[nsmp];
for(int i=0;i {
min[i]=tempY(0,i);
}
for(int i=0;i {
max=min[i];
for(int j=0;j {
if(tempY(j,i)>max)
{
max=tempY(j,i);
}
}
Max[i]=max;
}
for(int i=0;i<tempY.cols();i++)
{
for(int j=0;j<tempY.rows();j++)
{
if(tempY(j,i)==Max[i])
{
tempY(j,i)=1;
}
else
{
tempY(j,i)=0;
}
}
}
cout<<"the sample is belong to ";
for(int i=0;i<tempY.cols();i++)
{
for(int j=0;j<tempY.rows();j++)
{
if(tempY(j,i)==1)
{
Y[i]=j+1;
cout<<Y[i]<<" ";
}
}
}
cout<<endl;
outY=Y;
return 0;
}

int compare( const void *a, const void *b )
{
const double *da = (const double *) a;
const double *db = (const double *) b;
return (*da > *db) - (*da < *db);
}

// builds 1-of-K target matrix from labels array
//template
MatrixXd buildTargetMatrix( double *Y, int nLabels ) {

// make a temporary copy of the labels array
double *tmpY = new double[ nLabels ];
for ( int i = 0 ; i < nLabels ; i++ ) {
    tmpY[i] = Y[i];
}

// sort the array of labels
qsort( tmpY, nLabels, sizeof(double), compare );

// count unique labels
int nunique = 1;
for ( int i = 0 ; i < nLabels - 1 ; i++ ) {
    if ( tmpY[i] != tmpY[i+1] )
        nunique++;
}

delete [] tmpY;

MatrixXd targets( nunique, nLabels );
targets.fill( 0 );


// fill in the ones
for ( int i = 0 ; i < nLabels ; i++ ) 
{
    int idx = Y[i]-1;
    targets( idx, i ) = 1;
}

// normalize the targets matrix values (-1/1)
//targets *= 2;
//targets.array() -= 1;

return targets;

}

#endif

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 用visual studi code完成html页面
    • ¥15 聚类分析或者python进行数据分析
    • ¥15 逻辑谓词和消解原理的运用
    • ¥15 三菱伺服电机按启动按钮有使能但不动作
    • ¥15 js,页面2返回页面1时定位进入的设备
    • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?