Пример #1
0
void InstanceParser::read()
{
    m_sizes.clear();
    m_mkpItems.clear();
    m_binItems.clear();

    QFile file(m_path);
    if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "Cannot open file";
        return;
    }

    setDevice(&file);

    while(!atEnd()) {
        readNext();

        if(isStartElement()) {
            if(name() == "problem")
                readProblem();
            else
                raiseError("This file is not valid");
        }
    }
}
Пример #2
0
void
ProblemsReader::updateOutputs() {

	// clear existing problems
	_problems->clear();

	unsigned int numProblems;
	*_stream >> numProblems;

	LOG_DEBUG(streamproblemreaderlog) << "reading " << numProblems << " problems" << std::endl;

	for (unsigned int i = 0; i < numProblems; i++)
		readProblem(i);
}
Пример #3
0
int SVMTrainModel::train(double &RecRate, std::vector<int> &ConfusionTable)
{ 

  if((!have_input_file_name) || (!have_model_file_name))
  {
    fprintf(stderr,"ERROR: Set Input and Model files first!\n");
    exit(1);
  }

  const char *error_msg;
  
  readProblem(input_file_name);
  error_msg = svm_check_parameter(&prob,&param);
  
  if(error_msg)
  {
    fprintf(stderr,"ERROR: %s\n",error_msg);
    exit(1);
  }
  
  if(cross_validation)
  {
    do_cross_validation(RecRate,ConfusionTable);
  }
  else
  {
    model = svm_train(&prob,&param);
    if(svm_save_model(model_file_name,model))
    {
      fprintf(stderr, "can't save model to file %s\n", model_file_name);
      exit(1);
    }
    svm_free_and_destroy_model(&model);
  }
  svm_destroy_param(&param);
  free(prob.y);
  free(prob.x);
  free(x_space);
  free(line);
  
  return 0;
}