869 auto params = scoped_calloc_or_throw<svm_params>();
870 std::string kernel_type;
871 float bandwidth = 1.f;
877 new_options.add(
make_option(
"ksvm", ksvm).keep().help(
"kernel svm"))
878 .add(
make_option(
"reprocess", params->reprocess).default_value(1).help(
"number of reprocess steps for LASVM"))
879 .
add(
make_option(
"pool_greedy", params->active_pool_greedy).help(
"use greedy selection on mini pools"))
880 .
add(
make_option(
"para_active", params->para_active).help(
"do parallel active learning"))
881 .
add(
make_option(
"pool_size", params->pool_size).default_value(1).help(
"size of pools for active learning"))
884 .help(
"number of items to subsample from the pool"))
887 .default_value(
"linear")
888 .help(
"type of kernel (rbf or linear (default))"))
889 .
add(
make_option(
"bandwidth", bandwidth).keep().default_value(1.
f).help(
"bandwidth of rbf kernel"))
890 .
add(
make_option(
"degree", degree).keep().default_value(2).help(
"degree of poly kernel"));
899 float loss_parameter = 0.0;
903 params->model = &calloc_or_throw<svm_model>();
904 params->model->num_support = 0;
905 params->maxcache = 1024 * 1024 * 1024;
906 params->loss_sum = 0.;
914 params->active =
true;
916 params->active_c = 1.;
918 params->pool = calloc_or_throw<svm_example*>(params->pool_size);
919 params->pool_pos = 0;
921 if (!options.
was_supplied(
"subsample") && params->para_active)
922 params->subsample = (
size_t)ceil(params->pool_size / all.
all_reduce->
total);
925 if (params->lambda == 0.)
927 params->all->trace_message <<
"Lambda = " << params->lambda << endl;
928 params->all->trace_message <<
"Kernel = " << kernel_type << endl;
930 if (kernel_type.compare(
"rbf") == 0)
933 params->all->trace_message <<
"bandwidth = " << bandwidth << endl;
934 params->kernel_params = &calloc_or_throw<double>();
935 *((
float*)params->kernel_params) = bandwidth;
937 else if (kernel_type.compare(
"poly") == 0)
940 params->all->trace_message <<
"degree = " << degree << endl;
941 params->kernel_params = &calloc_or_throw<int>();
942 *((
int*)params->kernel_params) = degree;
947 params->all->weights.stride_shift(0);
base_learner * make_base(learner< T, E > &base)
virtual void add_and_parse(const option_group_definition &group)=0
void set_save_load(void(*sl)(T &, io_buf &, bool, bool))
void learn(svm_params ¶ms, single_learner &, example &ec)
std::shared_ptr< rand_state > get_random_state()
learner< T, E > & init_learner(free_ptr< T > &dat, L *base, void(*learn)(T &, L &, E &), void(*predict)(T &, L &, E &), size_t ws, prediction_type::prediction_type_t pred_type)
virtual bool was_supplied(const std::string &key)=0
void predict(svm_params ¶ms, svm_example **ec_arr, float *scores, size_t n)
void save_load(svm_params ¶ms, io_buf &model_file, bool read, bool text)
int add(svm_params ¶ms, svm_example *fec)
typed_option< T > make_option(std::string name, T &location)
loss_function * getLossFunction(vw &all, std::string funcName, float function_parameter)