static void train_one(const problem *prob, const parameter *param, double *w, double Cp, double Cn, int nr_subset=0, int *perm=NULL, int *start=NULL, int *count=NULL) { double eps=param->eps; double begin, end; function *fun_obj=NULL; switch(param->solver_type) { case SELECTION_TREE: { begin = omp_get_wtime(); fun_obj=new selection_rank_fun(prob, param->C, param->thread_count, nr_subset, perm, start, count); end = omp_get_wtime(); printf("Constructing time: %f\n",end-begin); begin = omp_get_wtime(); TRON tron_obj(fun_obj, param->eps); tron_obj.set_print_string(liblinear_print_string); tron_obj.tron(w); end = omp_get_wtime(); printf("TRON running time: %f\n",end-begin); delete fun_obj; break; } default: fprintf(stderr, "ERROR: unknown solver_type\n"); break; } }
static void train_one(const problem *prob, const parameter *param, double *w, double Cp, double Cn, int nr_subset=0, int *perm=NULL, int *start=NULL, int *count=NULL) { double eps=param->eps; clock_t begin,end; function *fun_obj=NULL; begin = clock(); switch(param->solver_type) { case SELECTION_TREE: { fun_obj=new selection_rank_fun(prob, param->C, nr_subset, perm, start, count); TRON tron_obj(fun_obj, param->eps, param->max_cg_iter,param->num_sample,param->max_iter,param->C,param->solver_type); tron_obj.set_print_string(liblinear_print_string); tron_obj.tron(w); delete fun_obj; break; } default: fprintf(stderr, "ERROR: unknown solver_type\n"); break; } end = clock(); info("Training time = %g\n",double(end-begin)/double(CLOCKS_PER_SEC)); }
void train_one(const problem *prob, const parameter *param, double *w, double Cp, double Cn) { double eps=param->eps; int pos = 0; int neg = 0; for(int i=0;i<prob->l;i++) if(prob->y[i]==+1) pos++; neg = prob->l - pos; function *fun_obj=NULL; switch(param->solver_type) { case L2_LR: { fun_obj=new l2_lr_fun(prob, Cp, Cn); TRON tron_obj(fun_obj, eps*min(pos,neg)/prob->l); tron_obj.tron(w); delete fun_obj; break; } case L2LOSS_SVM: { fun_obj=new l2loss_svm_fun(prob, Cp, Cn); TRON tron_obj(fun_obj, eps*min(pos,neg)/prob->l); tron_obj.tron(w); delete fun_obj; break; } case L2LOSS_SVM_DUAL: solve_linear_c_svc(prob, w, eps, Cp, Cn, L2LOSS_SVM_DUAL); break; case L1LOSS_SVM_DUAL: solve_linear_c_svc(prob, w, eps, Cp, Cn, L1LOSS_SVM_DUAL); break; default: fprintf(stderr, "Error: unknown solver_type\n"); break; } }
static void train_one(const problem *prob, const parameter *param, double *w, double Cp, double Cn) { double eps=param->eps; int pos = 0; int neg = 0; for(int i=0;i<prob->l;i++) if(prob->y[i]==+1) pos++; neg = prob->l - pos; function *fun_obj=NULL; switch(param->solver_type) { case L2R_LR: { fun_obj=new l2r_lr_fun(prob, Cp, Cn); TRON tron_obj(fun_obj, eps*min(pos,neg)/prob->l); tron_obj.set_print_string(liblinear_print_string); tron_obj.tron(w); delete fun_obj; break; } case L2R_L2LOSS_SVC: { fun_obj=new l2r_l2_svc_fun(prob, Cp, Cn); TRON tron_obj(fun_obj, eps*min(pos,neg)/prob->l); tron_obj.set_print_string(liblinear_print_string); tron_obj.tron(w); delete fun_obj; break; } case L2R_L2LOSS_SVC_DUAL: solve_l2r_l1l2_svc(prob, w, eps, Cp, Cn, L2R_L2LOSS_SVC_DUAL); break; case L2R_L1LOSS_SVC_DUAL: solve_l2r_l1l2_svc(prob, w, eps, Cp, Cn, L2R_L1LOSS_SVC_DUAL); break; case L1R_L2LOSS_SVC: { problem prob_col; feature_node *x_space = NULL; transpose(prob, &x_space ,&prob_col); solve_l1r_l2_svc(&prob_col, w, eps*min(pos,neg)/prob->l, Cp, Cn); delete [] prob_col.y; delete [] prob_col.x; delete [] x_space; break; } case L1R_LR: { problem prob_col; feature_node *x_space = NULL; transpose(prob, &x_space ,&prob_col); solve_l1r_lr(&prob_col, w, eps*min(pos,neg)/prob->l, Cp, Cn); delete [] prob_col.y; delete [] prob_col.x; delete [] x_space; break; } case L2R_LR_DUAL: solve_l2r_lr_dual(prob, w, eps, Cp, Cn); break; default: fprintf(stderr, "Error: unknown solver_type\n"); break; } }