205 auto data = scoped_calloc_or_throw<oaa>();
206 bool probabilities =
false;
209 new_options.add(
make_option(
"oaa", data->k).keep().help(
"One-against-all multiclass with <k> labels"))
211 .help(
"subsample this number of negative examples when learning"))
212 .
add(
make_option(
"probabilities", probabilities).help(
"predict probabilites of all classes"))
213 .
add(
make_option(
"scores", scores).help(
"output raw scores per class"));
220 THROW(
"error: you have " << all.
sd->
ldict->
getK() <<
" named labels; use that as the argument to oaa")
223 data->pred = calloc_or_throw<polyprediction>(data->k);
224 data->subsample_order =
nullptr;
225 data->subsample_id = 0;
226 if (data->num_subsample > 0)
228 if (data->num_subsample >= data->k)
230 data->num_subsample = 0;
231 all.
trace_message <<
"oaa is turning off subsampling because your parameter >= K" << std::endl;
235 data->subsample_order = calloc_or_throw<uint32_t>(data->k);
236 for (
size_t i = 0; i < data->k; i++) data->subsample_order[i] = (uint32_t)i;
237 for (
size_t i = 0; i < data->k; i++)
239 size_t j = (size_t)(all.
get_random_state()->get_and_update_random() * (float)(data->k - i)) + i;
240 uint32_t tmp = data->subsample_order[i];
241 data->subsample_order[i] = data->subsample_order[j];
242 data->subsample_order[j] = tmp;
247 oaa* data_ptr = data.get();
250 if (probabilities || scores)
256 if (loss_function_type !=
"logistic")
257 all.
trace_message <<
"WARNING: --probabilities should be used only with --loss_function=logistic" << std::endl;
bool report_multiclass_log_loss
void(* delete_prediction)(void *)
void set_learn(void(*u)(T &, L &, E &))
base_learner * make_base(learner< T, E > &base)
virtual void add_and_parse(const option_group_definition &group)=0
std::shared_ptr< rand_state > get_random_state()
single_learner * as_singleline(learner< T, E > *l)
void set_finish_example(void(*f)(vw &all, T &, E &))
void delete_scalars(void *v)
virtual bool was_supplied(const std::string &key)=0
virtual std::string getType()=0
int add(svm_params ¶ms, svm_example *fec)
typed_option< T > make_option(std::string name, T &location)
learner< T, E > & init_multiclass_learner(free_ptr< T > &dat, L *base, void(*learn)(T &, L &, E &), void(*predict)(T &, L &, E &), parser *p, size_t ws, prediction_type::prediction_type_t pred_type=prediction_type::multiclass)
LEARNER::base_learner * setup_base(options_i &options, vw &all)
void learn_randomized(oaa &o, LEARNER::single_learner &base, example &ec)