本文整理汇总了C++中DataReader::ReadDataFromCVS方法的典型用法代码示例。如果您正苦于以下问题:C++ DataReader::ReadDataFromCVS方法的具体用法?C++ DataReader::ReadDataFromCVS怎么用?C++ DataReader::ReadDataFromCVS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataReader
的用法示例。
在下文中一共展示了DataReader::ReadDataFromCVS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char ** argv)
{
std::string input_file = "";
std::string input_type = "l2r";
std::string config_file = "./gbrt.conf";
std::string act_type = "";
std::string model_file = "./gbrt.model";
int dimention = 1024;
//----parse command line
int opt_c;
while ( (opt_c = getopt( argc, argv, "d:f:i:c:m:tp")) != EOF )
{
switch (opt_c)
{
case 'i':
input_file = optarg;
break;
case 'f':
input_type = optarg;
break;
case 'c':
config_file = optarg;
break;
case 'm':
model_file = optarg;
break;
case 't':
act_type = "t";
break;
case 'p':
act_type = "p";
break;
case 'd':
dimention = atoi(optarg);
default:
break;
}
}
//check options
if ( act_type.length() == 0
|| input_file.length() == 0 )
{
std::cerr << "miss parameter!!" << endl;
Usage();
return 1;
}
else
{
cout << "parameters--------" << endl;
cout << " input file: " << input_file << endl;
cout << " input format (cvs, l2r): " << input_type<< endl;
cout << " config file: " << config_file << endl;
cout << " act type(t for train,p for predict): " << act_type << endl;
cout << " model file: " << model_file << endl;
cout << " max dimention(for L2R format): " << dimention << endl;
cout << endl;
}
Data data;
DataReader dr;
if ( input_type == "cvs")
{
if ( false == dr.ReadDataFromCVS(input_file, data))
{
std::cerr << "error: read CVS file failed! " << input_file << std::endl;
return 1;
}
}
else
{
if ( false == dr.ReadDataFromL2R(input_file, data, dimention))
{
std::cerr << "error: read L2R file failed! " << input_file << std::endl;
return 1;
}
}
GBDT gbdt;
if (!gbdt.LoadConfig(config_file))
return 1;
if (act_type == "t")
{
gbdt.Init();
gbdt.Train(data);
gbdt.SaveWeights(model_file);
}
else if( act_type == "p" )
{
T_VECTOR predictions;
gbdt.LoadWeights(model_file);
gbdt.PredictAllOutputs(data, predictions);
//----output prediction----
std::ifstream fs;
//.........这里部分代码省略.........