示例#1
0
double FidoInterface::calcObjective(double alpha, double beta, double gamma) {
  std::vector<std::vector<std::string> > names;
  std::vector<double> probs, empq, estq; 
  double roc ,mse, objective;
  
  proteinGraph_->setAlphaBetaGamma(alpha, beta, gamma);
  proteinGraph_->getProteinProbs();
  proteinGraph_->getProteinProbsAndNames(names, probs);
  
  getEstimated_and_Empirical_FDR(names, probs, empq, estq);
  getROC_AUC(names, probs, roc);
  getFDR_MSE(estq, empq, mse);
  
  objective = (kObjectiveLambda * roc) - fabs((1-kObjectiveLambda) * mse);
  
  if (VERB > 2) {
    std::cerr.precision(10);
    std::cerr << "Grid searching Alpha= "  << alpha << 
                 " Beta= " << beta << 
                 " Gamma= "  << gamma << std::endl;
    std::cerr.unsetf(std::ios::floatfield);
    std::cerr << "The ROC AUC estimated values is : " << roc << std::endl;
    std::cerr << "The MSE FDR estimated values is : " << mse << std::endl;
    std::cerr << "Objective function with second roc and mse is : " << 
                 objective << std::endl;
  }
  return objective;
}
示例#2
0
void FidoInterface::gridSearchOptimize()
{
 
  if(VERB > 1)
  {
    std::cerr << "Running super grid search..." << std::endl;
  }
  
  double gamma_best, alpha_best, beta_best;
  gamma_best = alpha_best = beta_best = -1.0;
  double best_objective = -100000000;
  std::vector<std::vector<std::string> > names;
  std::vector<double> probs,empq,estq; 
  double roc,mse,current_objective;
  
  double alpha_step = 0.05;
  double beta_step = 0.05;
  double gamma_step = 0.05;
  
  double beta_init = 0.00001;
  double alpha_init = 0.001;
  double gamma_init = 0.1;
  
  double gamma_limit = 0.5;
  double beta_limit = 0.05;
  double alpha_limit = 0.5;
  
  if(alpha != -1)
  {
    alpha_init = alpha_limit = alpha;
  }
  
  if(beta != -1)
  {
    beta_init = beta_limit = beta;
  }
  
  if(gamma != -1)
  {
    gamma_init = gamma_limit = gamma;
  }
  
  //NOTE very annoying the residue error of the floats that get acummulated in every iteration
  
  for (double i = gamma_init; i <= gamma_limit; i+=gamma_step)
  { 
    double gamma_local = i;
    
    for (double j = log10(beta_init); j <= Round(log10(beta_limit),2); j+=beta_step)
    {
      double original = pow(10,j);
      double beta_local = original - beta_init;
      if(beta_local > 0.0) beta_local = original;
      
      for (double k = log10(alpha_init); k <= Round(log10(alpha_limit),2); k+=alpha_step)
      {
       
	double alpha_local = pow(10,k);
	
	proteinGraph->setAlphaBetaGamma(alpha_local, beta_local, gamma_local);
	proteinGraph->getProteinProbs();
	proteinGraph->getProteinProbsAndNames(names,probs);
	getEstimated_and_Empirical_FDR(names,probs,empq,estq);
	getROC_AUC(names,probs,roc);
	getFDR_MSE(estq,empq,mse);
	
	current_objective = (lambda * roc) - fabs(((1-lambda) * (mse)));
	
	if(VERB > 2)
	{
	  std::cerr.precision(10);
	  std::cerr << "Grid searching Alpha= "  << alpha_local << " Beta= " << beta_local << " Gamma= "  << gamma_local << std::endl;
	  std::cerr.unsetf(std::ios::floatfield);
	  std::cerr << "The ROC AUC estimated values is : " << roc <<  std::endl;
	  std::cerr << "The MSE FDR estimated values is : " <<  mse << std::endl;
	  std::cerr << "Objective function with second roc and mse is : " << current_objective << std::endl;
	  
	}    
	if (current_objective > best_objective)
	{
	  best_objective = current_objective;
	  gamma_best = gamma_local;
	  alpha_best = alpha_local;
	  beta_best = beta_local;
	}
      }
    }
  }
  
  alpha = alpha_best;
  beta = beta_best;
  gamma = gamma_best;

}
示例#3
0
void FidoInterface::gridSearch()
{
  double gamma_best, alpha_best, beta_best;
  gamma_best = alpha_best = beta_best = -1.0;
  double best_objective = -100000000;
  std::vector<std::vector<std::string> > names;
  std::vector<double> probs,empq,estq;
  std::vector<long double> gamma_search,beta_search,alpha_search;

  double roc, mse,current_objective;
  
  switch(depth)
  {
    case 0:    
      gamma_search = boost::assign::list_of(0.5);
      beta_search = boost::assign::list_of(0.001);
      alpha_search = boost::assign::list_of(0.008)(0.032)(0.128);
      break;
    
    case 1:
      gamma_search = boost::assign::list_of(0.1)(0.5)(0.9);
      beta_search = boost::assign::list_of(0.001);
      for (double k = 0.002; k <= 0.4; k*=4)
      {
       alpha_search.push_back(k);
      }
      break;
      
    case 2:
      gamma_search = boost::assign::list_of(0.1)(0.3)(0.5)(0.75)(0.9);
      beta_search = boost::assign::list_of(0.001);
      for (double k = 0.001; k <= 0.4; k*=2)
      {
       alpha_search.push_back(k);
      }
      break;
    
    default:
      gamma_search = boost::assign::list_of(0.5);
      beta_search = boost::assign::list_of(0.001);
      alpha_search = boost::assign::list_of(0.008)(0.032)(0.128);
  }

  if(alpha != -1)
    alpha_search = boost::assign::list_of(alpha);
  if(beta != -1)
    beta_search = boost::assign::list_of(beta);
  if(gamma != -1)
    gamma_search = boost::assign::list_of(gamma);
  
  for (unsigned int i = 0; i < gamma_search.size(); i++)
  {
    double gamma_local = gamma_search[i];
    
    for (unsigned int j = 0; j < alpha_search.size(); j++)
    {
      double alpha_local = alpha_search[j];
      
      for (unsigned int k = 0; k < beta_search.size(); k++)
      {

	double beta_local = beta_search[k];
	
	proteinGraph->setAlphaBetaGamma(alpha_local, beta_local, gamma_local);
	proteinGraph->getProteinProbs();
	proteinGraph->getProteinProbsAndNames(names,probs);
	getEstimated_and_Empirical_FDR(names,probs,empq,estq);
	getROC_AUC(names,probs,roc);
	getFDR_MSE(estq,empq,mse);
	
	current_objective = (lambda * roc) - fabs(((1-lambda) * (mse)));
	
	if(VERB > 2)
	{
	  std::cerr.precision(10);
	  std::cerr << "Grid searching Alpha= "  << alpha_local << " Beta= " << beta_local << " Gamma= "  << gamma_local << std::endl;
	  std::cerr.unsetf(std::ios::floatfield);
	  std::cerr << "The ROC AUC estimated values is : " << roc <<  std::endl;
	  std::cerr << "The MSE FDR estimated values is : " <<  mse << std::endl;
	  std::cerr << "Objective function with second roc and mse is : " << current_objective << std::endl;
	}  
	if (current_objective > best_objective)
	{
	  best_objective = current_objective;
	  gamma_best = gamma_local;
	  alpha_best = alpha_local;
	  beta_best = beta_local;
	}

      }
    }
  }
  
  alpha = alpha_best;
  beta = beta_best;
  gamma = gamma_best;
}