39 if (f->first !=
"" && ((f->first) !=
" "))
41 ns_pre.append(f->first);
46 ns_pre.append(f->second);
47 dat.
ns_pre->push_back(ns_pre);
54 if (weights[ft_idx] != 0)
60 for (std::vector<std::string>::const_iterator s = dat.
ns_pre->begin(); s != dat.
ns_pre->end(); ++s) ns_pre += *s;
62 std::ostringstream tempstream;
63 tempstream <<
':' << ((ft_idx & weights.
mask()) >> weights.
stride_shift()) <<
':' << weights[ft_idx];
65 std::string temp = ns_pre + tempstream.str() +
'\n';
78 std::ostringstream tempstream;
83 for (
size_t j = 0; j < fs.
size(); ++j)
87 for (
size_t k = 0; k < all.
lda; k++)
90 tempstream <<
':' << w;
93 tempstream << std::endl;
120 for (
size_t j = 0; j < fs.
size(); ++j)
127 for (
size_t j = 0; j < fs.
size(); ++j)
138 rd.all->interactions, rd.all->permutations, ec, rd, rd.all->weights.dense_weights);
157 inline void print_ex(
vw& all,
size_t ex_processed,
size_t vals_found,
size_t progress)
160 << std::setw(9) << vals_found <<
" " << std::right << std::setw(12) << progress <<
'%' << std::endl;
165 bool printed =
false;
188 dat.
all->
trace_message <<
"Note: for some reason audit couldn't find all regressor values in dataset (" 195 for (
typename T::iterator iter = w.begin(); iter != w.end(); ++iter)
206 THROW(
"audit_regressor is incompatible with a cache file. Use it in single pass mode only.");
232 THROW(
"regressor has no non-zero weights. Nothing to audit.");
248 std::string out_file;
253 .help(
"stores feature names and their regressor values. Same dataset must be used for both " 254 "regressor training and this mode."));
260 if (out_file.empty())
261 THROW(
"audit_regressor argument (output filename) is missing.");
264 THROW(
"audit_regressor can't be used with --passes > 1.");
268 auto dat = scoped_calloc_or_throw<audit_regressor_data>();
270 dat->ns_pre =
new std::vector<std::string>();
271 dat->out_file =
new io_buf();
281 return LEARNER::make_base<audit_regressor_data>(ret);
v_array< namespace_index > indices
void print_ex(vw &all, size_t ex_processed, size_t vals_found, size_t progress)
void set_init_driver(void(*f)(T &))
LEARNER::base_learner * audit_regressor_setup(options_i &options, vw &all)
VW::config::options_i * options
double weighted_unlabeled_examples
static constexpr int WRITE
virtual bool close_file()
static constexpr int col_current_label
v_array< feature_index > indicies
the core definition of a set of features.
v_array< feature_value > values
virtual void add_and_parse(const option_group_definition &group)=0
void finish(vw &all, bool delete_all)
void audit_regressor_lda(audit_regressor_data &rd, LEARNER::single_learner &, example &ec)
std::vector< std::string > * ns_pre
void regressor_values(audit_regressor_data &dat, T &w)
static constexpr int col_example_weight
std::array< features, NUM_NAMESPACES > feature_space
single_learner * as_singleline(learner< T, E > *l)
void set_finish_example(void(*f)(vw &all, T &, E &))
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)
typed_option< T > & get_typed_option(const std::string &key)
size_t loaded_regressor_values
virtual bool was_supplied(const std::string &key)=0
static constexpr int col_example_counter
void generate_interactions(vw &all, example_predict &ec, R &dat)
dense_parameters dense_weights
void finish_example(vw &, example &)
void init_driver(audit_regressor_data &dat)
void audit_regressor_feature(audit_regressor_data &dat, const float, const uint64_t ft_idx)
option_group_definition & add(T &&op)
v_array< audit_strings_ptr > space_names
typed_option< T > make_option(std::string name, T &location)
size_t bin_write_fixed(const char *data, size_t len)
void audit_regressor_interaction(audit_regressor_data &dat, const audit_strings *f)
void set_finish(void(*f)(T &))
sparse_parameters sparse_weights
void audit_regressor(audit_regressor_data &rd, LEARNER::single_learner &base, example &ec)
std::vector< std::string > interactions
LEARNER::base_learner * l
void end_examples(audit_regressor_data &d)
LEARNER::base_learner * setup_base(options_i &options, vw &all)
const char * to_string(prediction_type_t prediction_type)
void set_end_examples(void(*f)(T &))
void update_dump_interval(bool progress_add, float progress_arg)
std::pair< std::string, std::string > audit_strings