本文整理汇总了C++中RawData::X方法的典型用法代码示例。如果您正苦于以下问题:C++ RawData::X方法的具体用法?C++ RawData::X怎么用?C++ RawData::X使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RawData
的用法示例。
在下文中一共展示了RawData::X方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process
void OrganizedData::process(RawData* raw, int nBlock, double pTest, int nSupport)
{
int nData = raw->nData, nDim = raw->nDim - 1;
this->nSupport = nSupport;
this->nBlock = nBlock;
this->nDim = nDim;
train = field<mat>(nBlock,2);
test = field<mat>(nBlock,2);
support = field<mat>(1,2);
mat xm(nSupport,nDim),
ym(nSupport,1);
vec mark(nData); mark.fill(0);
printf("Randomly selecting %d supporting point ...\n", nSupport);
for (int i = 0; i < nSupport; i++)
{
int pos = IRAND(0, nData - 1);
while (mark[pos] > 0)
pos = IRAND(0, nData - 1);
mark[pos] = 1;
for (int j = 0; j < nDim; j++)
xm(i, j) = raw->X(pos,j);
ym(i,0) = raw->X(pos,nDim);
}
support(0,0) = xm; xm.clear();
support(0,1) = ym; ym.clear();
cout << "Partitioning the remaining data into " << nBlock << " cluster using K-Mean ..." << endl;
vvd _remain;
for (int i = 0; i < nData; i++) if (!mark(i))
{
rowvec R = raw->X.row(i);
_remain.push_back(r2v(R));
}
mat remaining = v2m(_remain);
mark.clear();
RawData* remain = new RawData(remaining);
KMean* partitioner = new KMean(remain);
Partition* clusters = partitioner->cluster(nBlock);
cout << "Packaging training/testing data points into their respective cluster" << endl;
for (int i = 0; i < nBlock; i++)
{
cout << "Processing block " << i + 1 << endl;
int bSize = (int) clusters->member[i].size(),
tSize = (int) floor(bSize * pTest),
pos = 0,
counter = 0;
mark = vec(bSize); mark.fill(0);
if (bSize > tSize) // if we can afford to draw tSize test points from this block without depleting it ...
{
mat xt(tSize,nDim),
yt(tSize,1);
for (int j = 0; j < tSize; j++)
{
pos = IRAND(0, bSize - 1);
while (mark[pos] > 0)
pos = IRAND(0, bSize - 1);
mark[pos] = 1; pos = clusters->member[i][pos];
for (int t = 0; t < nDim; t++)
xt(j, t) = remain->X(pos,t);
yt(j,0) = remain->X(pos,nDim);
}
bSize -= tSize;
nTest += tSize;
test(i,0) = xt; xt.clear();
test(i,1) = yt; yt.clear();
}
nTrain += bSize;
mat xb(bSize,nDim),
yb(bSize,1);
//cout << remain->X.n_rows << endl;
for (int j = 0; j < (int)mark.n_elem; j++) if (mark[j] < 1)
{
for (int t = 0; t < nDim; t++) {
//.........这里部分代码省略.........