本文整理汇总了C++中CDataset::AllContinuous方法的典型用法代码示例。如果您正苦于以下问题:C++ CDataset::AllContinuous方法的具体用法?C++ CDataset::AllContinuous怎么用?C++ CDataset::AllContinuous使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDataset
的用法示例。
在下文中一共展示了CDataset::AllContinuous方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareData
void CSVM::PrepareData(const CDataset &OrgSet,struct svm_problem &DataDesc)
{
//for SVM, we need to expand all multivalued discrete attributes of the training data into multi continuous attributes.
//expand discrete attribute
const CDataset *TrainSet=&OrgSet;
if(!OrgSet.AllContinuous())
TrainSet=OrgSet.ExpandDiscrete();
const MATRIX &TrainData=TrainSet->GetData();
const CASE_INFO &CaseInfo=TrainSet->GetInfo();
//number of attribute for data set
AttributeNum=CaseInfo.ValidWidth-1;
//instances is formated as libsvm's requirements
//number of instances
DataDesc.l=CaseInfo.Height;
//labels of instances
DataDesc.y=new double[DataDesc.l];
//content of instances (all attributes plus a tag for end of line, each node is initialized as end of a row)
struct svm_node Val={-1,0};
fill_d2(struct svm_node,DataDesc.x,CaseInfo.Height,CaseInfo.ValidWidth,Val);
for(int i=0;i<CaseInfo.Height;i++)
{
DataDesc.y[i]=(double)TrainData[i][CaseInfo.ValidWidth-1].Discr;
int ValidValue=0;
for(int j=0;j<CaseInfo.ValidWidth-1;j++)
{
if(CaseInfo.ValidAttrs[j].AttType==ATT_DISCRETE)
{
throw(CError("SVM: discrete attribute should have been expanded!\n",100,0));
}
else//range expanding
{
if(TrainData[i][j].Cont==0)
continue;
else if(CaseInfo.ValidAttrs[j].Max==CaseInfo.ValidAttrs[j].Min)
continue;
else
{
DataDesc.x[i][ValidValue].index=j+1;
DataDesc.x[i][ValidValue].value=(TrainData[i][j].Cont-CaseInfo.ValidAttrs[j].Min)/
(CaseInfo.ValidAttrs[j].Max-CaseInfo.ValidAttrs[j].Min);
ValidValue++;
}
}
}
//tag for end of line has been set
}
if(!OrgSet.AllContinuous())
delete TrainSet;
return;
}