virtual void doJob(size_t jobId) { // Randomly draw some data (with replacement) GReleaseDataHolder hDrawnFeatures(&m_drawnFeatures); GReleaseDataHolder hDrawnLabels(&m_drawnLabels); for(size_t j = 0; j < m_drawSize; j++) { size_t r = (size_t)m_rand.next(m_features.rows()); m_drawnFeatures.takeRow((GVec*)&m_features[r]); // This case is only okay because we only use drawFeatures as a const GMatrix m_drawnLabels.takeRow((GVec*)&m_labels[r]); // This case is only okay because we only use drawnLabels as a const GMatrix } // Train the learner with the drawn data m_pBag->models()[jobId]->m_pModel->train(m_drawnFeatures, m_drawnLabels); }
void aggregateRows(GArgReader& args) { size_t r = args.pop_uint(); vector<string> files; GFile::fileList(files); GMatrix* pResults = NULL; Holder<GMatrix> hResults; for(vector<string>::iterator it = files.begin(); it != files.end(); it++) { PathData pd; GFile::parsePath(it->c_str(), &pd); if(strcmp(it->c_str() + pd.extStart, ".arff") != 0) continue; GMatrix* pData = loadData(it->c_str()); Holder<GMatrix> hData(pData); if(!pResults) { pResults = new GMatrix(pData->relation()); hResults.reset(pResults); } pResults->takeRow(pData->releaseRow(r)); } pResults->print(cout); }