本文整理汇总了C++中Constant::getDefaultLambda方法的典型用法代码示例。如果您正苦于以下问题:C++ Constant::getDefaultLambda方法的具体用法?C++ Constant::getDefaultLambda怎么用?C++ Constant::getDefaultLambda使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Constant
的用法示例。
在下文中一共展示了Constant::getDefaultLambda方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char **argv) {
if (argc < 5) {
cout
<< "Usage: \n\t-train trainfile\n\t-test predictfile\n\t-his historyfile\n\t-sep separator\n\t-method SVD,ASVD,SVDPP\n\t-dim featureLength\n\t-trps 0 represent not transpose the matrix; 1 otherwise\n\t-alpha alpha\n\t-lambda lambda\n\t-iter iternum\n\t-out outputfile"
<< endl;
return 1;
}
ConsoleHelper helper(argc, argv);
Constant constant;
string trainfile = helper.getArg("-train", "");
string testfile = helper.getArg("-test", "");
string method = helper.getArg("-method", "SVD");
string hisfile = helper.getArg("-his", "");
// string separator = helper.getArg("-sep", "\t");
string separator = helper.getArg("-sep", ","); /* ZZM */
string outputfile = helper.getArg("-out", "");
int trps = helper.getArg("-trps", 0);
int dim = helper.getArg("-dim", 8);
float alpha = helper.getArg("-alpha", constant.getDefaultAlpha(method));
float lambda = helper.getArg("-lambda", constant.getDefaultLambda(method));
int nIter = helper.getArg("-iter", 100);
if (trainfile.length() == 0) {
cout << "please input trainfile" << endl;
return 1;
} else if (testfile.length() == 0) {
cout << "please input testfile" << endl;
return 1;
}
if (!constant.isContainMethod(method)) {
cout << "There is no method named " << method << endl;
return 1;
}
Trainer *trainer = getTrainer(method, dim, trps);
trainer->loadFile(trainfile, testfile, separator, hisfile);
trainer->train(alpha, lambda, nIter);
trainer->predict(outputfile, separator);
return 1;
}