Search code examples
pythonvowpalwabbit

how to print a vowpal wabbit regression model in contextual bandits setting


I am using vowpal wabbit for contextual bandit problem, in python. Vowpal wabbit has a prediction model that uses the doubly robust method to build a regression model to predict the cost for different actions. This model is thenused by the exploration strategy to output predictions.

Is there a way to print (in python) what the predicted regression model is and what the variables, coefficients are. I cannot find a way to print the model like a typical regression model summary (containing the variable, coefficients, std errors, p values etc.)


Solution

  • Depending on how you initialize vw in python, you could use the --invert_hash <file_name> command and that will print a readable version of the model to the file provided (see here for details).

    If you are using vw 9.1.0 you can also use this new experimental feature that exports the model in a json format (see release notes here, check for "Export model weights and readable feature names as JSON")

    If you are building from source, the above experimental api has been recently exposed via the python interface (see here)