本文整理汇总了C++中Corpus::read_data方法的典型用法代码示例。如果您正苦于以下问题:C++ Corpus::read_data方法的具体用法?C++ Corpus::read_data怎么用?C++ Corpus::read_data使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Corpus
的用法示例。
在下文中一共展示了Corpus::read_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char* argv[])
{
seedMT( time(NULL) );
if ( argc > 1 )
{
Corpus* c = new Corpus();
Params param;
param.read_settings( argv[5] ); //"settings.txt");
param.NTOPICS = atoi(argv[1]);
param.INITIAL_C = atof(argv[2]);
param.LAMBDA = atof(argv[3]);
param.RHO = atof(argv[4]);
param.NFOLDS = 1;
if ( argc > 6 ) param.NFOLDS = atoi(argv[6]);
if ( argc > 7 ) param.DELTA_ELL = atof(argv[7]);
c->read_data(param.train_filename, param.NLABELS);
char dir[512];
sprintf(dir, "s%d_c%d_f%d_s%d", param.NTOPICS, (int)param.INITIAL_C,
param.NFOLDS, param.SUPERVISED);
mkdir(dir,0755);
MedSTC model;
model.train("random", dir, c, ¶m);
// testing.
Corpus *tstC = new Corpus();
tstC->read_data(param.test_filename, param.NLABELS);
MedSTC evlModel;
double dAcc = evlModel.sparse_coding(dir, tstC, ¶m);
printf("Accuracy: %.3f\n", dAcc);
delete tstC;
delete c;
} else {
printf("usage : MedSTC est [initial alpha] [k] [labels] [random/seeded/*] [directory]\n");
printf(" MedSTC cv [foldnum] [foldix] [initial alpha] [k] [labels] [settings] [data] [random/seeded/*] [directory]\n");
printf(" MedSTC inf [settings] [model] [data] [name]\n");
}
return 0;
}
示例2: main
/*
* main
*/
int main(int argc, char* argv[])
{
seedMT( time(NULL) );
// seedMT(4357U);
if (argc > 1)
{
Corpus* c = new Corpus();
Params param;
param.INNER_CV = true;
if ( strcmp(argv[1], "estinf") == 0 ) {
param.read_settings("settings.txt");
param.NTOPICS = atoi(argv[2]);
param.NLABELS = atoi(argv[3]);
param.NFOLDS = atoi(argv[4]);
param.INITIAL_C = atof(argv[5]);
param.DELTA_ELL = atof(argv[6]);
printf("K: %d, C: %.3f, Alpha: %d, svm: %d\n", param.NTOPICS,
param.INITIAL_C, param.ESTIMATE_ALPHA, param.SVM_ALGTYPE);
c->read_data(param.train_filename, param.NLABELS);
char dir[512];
sprintf(dir, "20ng%d_c%d_f%d", param.NTOPICS, (int)param.INITIAL_C, param.NFOLDS);
make_directory(dir);
if ( param.INNER_CV ) {
c->shuffle();
char modelDir[512];
sprintf(modelDir, "%s/innercv", dir);
make_directory(modelDir);
param.INITIAL_C = innerCV(modelDir, c, ¶m);
printf("\n\nBest C: %f\n", param.INITIAL_C);
}
MedLDA model;
model.run_em(argv[7], dir, c, ¶m);
// testing.
Corpus *tstC = new Corpus();
tstC->read_data(param.test_filename, param.NLABELS);
MedLDA evlModel;
double dAcc = evlModel.infer(dir, tstC, ¶m);
printf("Accuracy: %.3f\n", dAcc);
delete tstC;
}
if ( strcmp(argv[1], "est") == 0 ) {
param.read_settings("settings.txt");
param.NTOPICS = atoi(argv[2]);
param.NLABELS = atoi(argv[3]);
param.NFOLDS = atoi(argv[4]);
param.INITIAL_C = atof(argv[5]);
param.DELTA_ELL = atof(argv[6]);
c->read_data(param.train_filename, param.NLABELS);
char dir[512];
sprintf(dir, "%s%d_c%d_f%d", argv[7], param.NTOPICS, param.INITIAL_C, param.NFOLDS);
make_directory(dir);
if ( param.INNER_CV ) {
c->shuffle();
char modelDir[512];
sprintf(modelDir, "%s/innercv", dir);
make_directory(modelDir);
param.INITIAL_C = innerCV(modelDir, c, ¶m);
printf("\n\nBest C: %f\n", param.INITIAL_C);
}
MedLDA model;
model.run_em(argv[8], dir, c, ¶m);
}
if (strcmp(argv[1], "inf")==0)
{
param.read_settings("settings.txt");
param.NLABELS = atoi(argv[2]);
c->read_data(param.test_filename, param.NLABELS);
MedLDA model;
double dAcc = model.infer(argv[3], c, ¶m);
printf("Accuracy: %.3f\n", dAcc);
}
delete c;
} else {
printf("usage : MEDsLDAc estinf [k] [labels] [fold] [initial C] [l] [random/seeded/*]\n");
printf(" MEDsLDAc est [k] [labels] [fold] [initial C] [l] [dir root] [random/seeded/*]\n");
printf(" MEDsLDAc inf [labels] [model]\n");
}
return(0);
}