14 template <
bool is_learn,
bool is_conf
idence_after_training>
17 float threshold = 0.f;
21 if (existing_label == FLT_MAX)
24 float opposite_label = 1.f;
26 opposite_label = -1.f;
30 if (!is_confidence_after_training)
39 if (is_confidence_after_training)
50 ss << std::fixed << res <<
" " << confidence;
54 ssize_t len = ss.str().size();
57 std::cerr <<
"write error: " << strerror(errno) << std::endl;
88 bool confidence_arg =
false;
89 bool confidence_after_training =
false;
91 new_options.
add(
make_option(
"confidence", confidence_arg).keep().help(
"Get confidence for binary predictions"))
92 .
add(
make_option(
"confidence_after_training", confidence_after_training).help(
"Confidence after training"));
101 <<
"Confidence does not work in test mode because learning algorithm state is needed. Use --save_resume when " 102 "saving the model and avoid --test_only" 107 auto data = scoped_calloc_or_throw<confidence>();
111 void (*predict_with_confidence_ptr)(
confidence&, single_learner&,
example&) =
nullptr;
113 if (confidence_after_training)
115 learn_with_confidence_ptr = predict_or_learn_with_confidence<true, true>;
116 predict_with_confidence_ptr = predict_or_learn_with_confidence<false, true>;
120 learn_with_confidence_ptr = predict_or_learn_with_confidence<true, false>;
121 predict_with_confidence_ptr = predict_or_learn_with_confidence<false, false>;
void predict(E &ec, size_t i=0)
double weighted_unlabeled_examples
static ssize_t write_file_or_socket(int f, const void *buf, size_t nbytes)
v_array< int > final_prediction_sink
base_learner * make_base(learner< T, E > &base)
int print_tag(std::stringstream &ss, v_array< char > tag)
virtual void add_and_parse(const option_group_definition &group)=0
single_learner * as_singleline(learner< T, E > *l)
void print_update(vw &all, bool is_test, example &ec, multi_ex *ec_seq, bool action_scores)
void set_finish_example(void(*f)(vw &all, T &, E &))
void confidence_print_result(int f, float res, float confidence, v_array< char > tag)
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)
void predict_or_learn_with_confidence(confidence &, single_learner &base, example &ec)
float sensitivity(baseline &data, base_learner &base, example &ec)
void finish_example(vw &, example &)
void update(bool test_example, bool labeled_example, float loss, float weight, size_t num_features)
float sensitivity(example &ec, size_t i=0)
option_group_definition & add(T &&op)
typed_option< T > make_option(std::string name, T &location)
void return_confidence_example(vw &all, confidence &, example &ec)
void output_and_account_confidence_example(vw &all, example &ec)
base_learner * confidence_setup(options_i &options, vw &all)
LEARNER::base_learner * setup_base(options_i &options, vw &all)
void learn(E &ec, size_t i=0)
void(* print)(int, float, float, v_array< char >)