vowpalwabbit.pyvw.pylibvw

The Python bindings employ native bindings and then inherit from this in Python to add extra functionality. The classes on this page should not be directly instantiated. The types in vowpalwabbit should be used instead.

class vowpalwabbit.pyvw.pylibvw.vw

Bases: pybind11_object

the basic VW object that holds weight vector, parser, etc.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pylibvw.vw, arg0: list) -> None

  2. __init__(self: pylibvw.vw, arg0: list, arg1: py_log_wrapper) -> None

  3. __init__(self: pylibvw.vw, arg0: pylibvw.vw) -> None

audit_example(self: pylibvw.vw, arg0: VW::example) None

print example audit information

finish(self: pylibvw.vw) None

stop VW by calling finish (and, eg, write weights to disk)

get_arguments(self: pylibvw.vw) str

return the arguments after resolving all dependencies

get_enabled_learners(self: pylibvw.vw) list

return the list of names of the enabled learners

get_enabled_reductions(self: pylibvw.vw) list

return the list of names of the enabled learners

get_holdout_sum_loss(self: pylibvw.vw) float

return the total cumulative holdout loss suffered so far

get_id(self: pylibvw.vw) str

return the model id

get_learner_metrics(self: pylibvw.vw) dict

get current learner stack metrics. returns empty dict if –extra_metrics was not supplied.

get_options(self: pylibvw.vw, arg0: object, arg1: bool) object

get available vw options

get_search_ptr(self: pylibvw.vw) Search::search

return a pointer to the search data structure

get_stride(self: pylibvw.vw) int

return the internal stride

get_sum_loss(self: pylibvw.vw) float

return the total cumulative loss suffered so far

get_weight(self: pylibvw.vw, arg0: SupportsInt, arg1: SupportsInt) float

get the weight for a particular index

get_weighted_examples(self: pylibvw.vw) float

return the total weight of examples so far

hash_feature(self: pylibvw.vw, arg0: str, arg1: SupportsInt) int

given a feature string (arg2) and a hashed namespace (arg3), hash that feature

hash_space(self: pylibvw.vw, arg0: str) int

given a namespace (as a string), compute the hash of that namespace

json_weights(self: pylibvw.vw) str

get json string of current weights

lBinary = 1
lConditionalContextualBandit = 6
lContextualBandit = 4
lContextualBanditEval = 9
lContinuous = 8
lCostSensitive = 3
lDefault = 0
lMax = 5
lMulticlass = 2
lMultilabel = 10
lSimple = 1
lSlates = 7
learn(self: pylibvw.vw, arg0: VW::example) None

given a pyvw example, learn (and predict) on that example

learn_multi(self: pylibvw.vw, arg0: list) None

given a list pyvw examples, learn (and predict) on those examples

num_weights(self: pylibvw.vw) int

how many weights are we learning?

pACTION_PDF_VALUE = 9
pACTION_PROBS = 3
pACTION_SCORES = 2
pACTIVE_MULTICLASS = 11
pDECISION_SCORES = 8
pMULTICLASS = 4
pMULTICLASSPROBS = 7
pMULTILABELS = 5
pNOPRED = 12
pPDF = 10
pPROB = 6
pSCALAR = 0
pSCALARS = 1
predict(self: pylibvw.vw, arg0: VW::example) None

given a pyvw example, predict on that example

predict_multi(self: pylibvw.vw, arg0: list) None

given a list of pyvw examples, predict on that example

run_parser(self: pylibvw.vw) None

parse external data file

save(self: pylibvw.vw, arg0: str) None

save model to filename

set_weight(self: pylibvw.vw, arg0: SupportsInt, arg1: SupportsInt, arg2: SupportsFloat) None

set the weight for a particular index

setup_example(self: pylibvw.vw, arg0: VW::example) None

given an example that you’ve created by hand, prepare it for learning (eg, compute quadratic feature)

tACTION = 1
tSHARED = 0
tSLOT = 2
tUNSET = 3
unsetup_example(self: pylibvw.vw, arg0: VW::example) None

reverse the process of setup, so that you can go back and modify this example

class vowpalwabbit.pyvw.pylibvw.example

Bases: pybind11_object

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: pylibvw.example, arg0: pylibvw.vw, arg1: typing.SupportsInt, arg2: str) -> None

Given a string as an argument parse that into a VW example

  1. __init__(self: pylibvw.example, arg0: pylibvw.vw, arg1: typing.SupportsInt) -> None

Construct an empty example; you must provide a label type

  1. __init__(self: pylibvw.example, arg0: pylibvw.vw, arg1: typing.SupportsInt, arg2: pylibvw.example) -> None

Create a new example object pointing to an existing object

ensure_namespace_exists(self: pylibvw.example, arg0: SupportsInt) None

Add a new namespace if it doesn’t already exist

erase_namespace(self: pylibvw.example, arg0: SupportsInt) None

Remove all the features from a given namespace

feature(self: pylibvw.example, arg0: SupportsInt, arg1: SupportsInt) int

Get the feature id for the ith feature in a given namespace id

feature_weight(self: pylibvw.example, arg0: SupportsInt, arg1: SupportsInt) float

The the feature value (weight) per .feature(…)

get_action_pdf_value(self: pylibvw.example) tuple

Get action and pdf value from example prediction

get_action_scores(self: pylibvw.example) list

Get action scores from example prediction

get_active_multiclass(self: pylibvw.example) tuple

Get active multiclass from example prediction

get_cb_continuous_class(self: pylibvw.example, arg0: SupportsInt) int

Assuming a cb_continuous label type, return the ith class

get_cb_continuous_cost(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cb_continuous label type, return the cost for the ith action

get_cb_continuous_num_costs(self: pylibvw.example) int

Assuming a cb_continuous label type, return the number of costs

get_cb_continuous_pdf_value(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cb_continuous label type, return the ith pdf_value

get_cb_eval_action(self: pylibvw.example) int

Assuming a cb_eval label type, get action

get_cb_eval_class(self: pylibvw.example, arg0: SupportsInt) int

Assuming a cb_eval label type, return the ith class

get_cb_eval_cost(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cb_eval label type, return the cost for the ith action

get_cb_eval_num_costs(self: pylibvw.example) int

Assuming a cb_eval label type, return the number of costs

get_cb_eval_partial_prediction(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cb_eval label type, return the ith partial prediction

get_cb_eval_probability(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cb_eval label type, return the ith probability

get_cb_eval_weight(self: pylibvw.example) int

Assuming a cb_eval label type, get weight

get_cbandits_class(self: pylibvw.example, arg0: SupportsInt) int

Assuming a contextual_bandits label type, return the ith class

get_cbandits_cost(self: pylibvw.example, arg0: SupportsInt) float

Assuming a contextual_bandits label type, return the cost for the ith action

get_cbandits_num_costs(self: pylibvw.example) int

Assuming a contextual_bandits label type, return the number of costs

get_cbandits_partial_prediction(self: pylibvw.example, arg0: SupportsInt) float

Assuming a contextual_bandits label type, return the ith partial prediction

get_cbandits_prediction(self: pylibvw.example) int

Assuming a contextual_bandits label type, return the prediction

get_cbandits_probability(self: pylibvw.example, arg0: SupportsInt) float

Assuming a contextual_bandits label type, return the ith probability

get_cbandits_weight(self: pylibvw.example) int

Assuming a contextual_bandits label type, get the weight

get_ccb_action(self: pylibvw.example, arg0: SupportsInt) int

Assuming a CCB label type, return the ith action

get_ccb_cost(self: pylibvw.example) float

Assuming a CCB label type, get the cost

get_ccb_explicitly_included_actions(self: pylibvw.example) list

Assuming a CCB label type, return the list of explicitly included actions

get_ccb_has_outcome(self: pylibvw.example) bool

Assuming a CCB label type, check if has outcome

get_ccb_num_explicitly_included_actions(self: pylibvw.example) int

Assuming a CCB label type, return the number of explicitly included actions

get_ccb_num_probabilities(self: pylibvw.example) int

Assuming a CCB label type, return the number of probabilities

get_ccb_probability(self: pylibvw.example, arg0: SupportsInt) float

Assuming a CCB label type, return the ith probability

get_ccb_type(self: pylibvw.example) int

Assuming a CCB label type, return the example type

get_ccb_weight(self: pylibvw.example) float

Assuming a CCB label type, get the weight

get_costsensitive_class(self: pylibvw.example, arg0: SupportsInt) int

Assuming a cost_sensitive label type, return the ith class

get_costsensitive_cost(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cost_sensitive label type, return the cost for the ith class

get_costsensitive_num_costs(self: pylibvw.example) int

Assuming a cost_sensitive label type, return the number of costs

get_costsensitive_partial_prediction(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cost_sensitive label type, return the ith partial prediction

get_costsensitive_prediction(self: pylibvw.example) int

Assuming a cost_sensitive label type, return the prediction

get_costsensitive_wap_value(self: pylibvw.example, arg0: SupportsInt) float

Assuming a cost_sensitive label type, return the ith wap value

get_decision_scores(self: pylibvw.example) list

Get decision scores from example prediction

get_example_counter(self: pylibvw.example) int

Returns the counter of total number of examples seen up to and including this one

get_feature_number(self: pylibvw.example) int

Returns the total number of features for this example

get_ft_offset(self: pylibvw.example) int

Returns the feature offset for this example (used, eg, by multiclass classification to bulk offset all features)

get_loss(self: pylibvw.example) float

Returns the loss associated with this example

get_multiclass_label(self: pylibvw.example) int

Assuming a multiclass label type, return the corresponding label

get_multiclass_prediction(self: pylibvw.example) int

Assuming a multiclass label type, return the prediction

get_multiclass_weight(self: pylibvw.example) float

Assuming a multiclass label type, return the importance weight

get_multilabel_labels(self: pylibvw.example) list

Get multilabel labels from example label

get_multilabel_predictions(self: pylibvw.example) list

Get multilabel predictions from example prediction

get_partial_prediction(self: pylibvw.example) float

Returns the partial prediction associated with this example

get_pdf(self: pylibvw.example) list

Get pdf from example prediction

get_prob(self: pylibvw.example) float

Get probability from example prediction

get_scalars(self: pylibvw.example) list

Get scalar values from example prediction

get_simplelabel_initial(self: pylibvw.example) float

Assuming a simple_label label type, return the initial value

get_simplelabel_label(self: pylibvw.example) float

Assuming a simple_label label type, return the corresponding label

get_simplelabel_prediction(self: pylibvw.example) float

Assuming a simple_label label type, return the prediction

get_simplelabel_weight(self: pylibvw.example) float

Assuming a simple_label label type, return the importance weight

get_slates_action(self: pylibvw.example, arg0: SupportsInt) int

Assuming a slates label type, return the ith action

get_slates_cost(self: pylibvw.example) float

Assuming a slates label type, get the cost

get_slates_labeled(self: pylibvw.example) bool

Assuming a slates label type, check if labeled

get_slates_num_probabilities(self: pylibvw.example) int

Assuming a slates label type, return the number of probabilities

get_slates_probability(self: pylibvw.example, arg0: SupportsInt) float

Assuming a slates label type, return the ith probability

get_slates_slot_id(self: pylibvw.example) int

Assuming a slates label type, get the slot id

get_slates_type(self: pylibvw.example) int

Assuming a slates label type, return the example type

get_slates_weight(self: pylibvw.example) float

Assuming a slates label type, get the weight

get_tag(self: pylibvw.example) str

Returns the tag associated with this example

get_topic_prediction(self: pylibvw.vw, arg0: pylibvw.example, arg1: SupportsInt) float

For LDA models, returns the topic prediction for the topic id given

get_total_sum_feat_sq(self: pylibvw.example) float

The total sum of feature-value squared for this example

get_updated_prediction(self: pylibvw.example) float

Returns the partial prediction as if we had updated it after learning

namespace(self: pylibvw.example, arg0: SupportsInt) int

Get the namespace id for namespace i (for i = 0.. num_namespaces)

num_features_in(self: pylibvw.example, arg0: SupportsInt) int

Get the number of features in a given namespace id

num_namespaces(self: pylibvw.example) int

The total number of namespaces associated with this example

pop_feature(self: pylibvw.example, arg0: SupportsInt) bool

Remove the top feature from a given namespace; returns True iff the list was non-empty

pop_namespace(self: pylibvw.example) bool

Remove the top namespace off; returns True iff the list was non-empty

push_feature_dict(self: pylibvw.example, arg0: pylibvw.vw, arg1: dict) None

Add a (Python) dictionary of namespace/feature-list pairs

push_feature_list(self: pylibvw.example, arg0: pylibvw.vw, arg1: SupportsInt, arg2: SupportsInt, arg3: list) None

Add a (Python) list of features to a given namespace

push_hashed_feature(self: pylibvw.example, arg0: SupportsInt, arg1: SupportsInt, arg2: SupportsFloat) None

Add a hashed feature to a given namespace

push_namespace(self: pylibvw.example, arg0: SupportsInt) None

Add a new namespace

set_label_string(self: pylibvw.example, arg0: pylibvw.vw, arg1: str, arg2: SupportsInt) None

(Re)assign the label of this example to this string

set_test_only(self: pylibvw.example, arg0: bool) None

Change the test-only bit on an example

sum_feat_sq(self: pylibvw.example, arg0: SupportsInt) float

Get the sum of feature-values squared for a given namespace id (id=character-ord)