Python 8.11 to 9 migration#
You can do nothing and everything should still work when migrating to VW 9. But if you want to move to the new way to avoid deprecation warnings and future breaks here’s a rundown.
Imports#
Modules are now direcly accessible from the root module. In the past from vowpalwabbit import ...
was needed, but now import vowpalwabbit
and accessing with .
will work.
pyvw
#
The old pyvw
types are now available under the root module.
Instead of:
from vowpalwabbit import pyvw
Use:
import vowpalwabbit
And use the corresponding types exposed by vowpalwabbit
instead of vowpalwabbit.pyvw
.
Exception
vowpalwabbit.pyvw.SearchTask
is only available under vowpalwabbit.pyvw
due to its advanced nature and less usage.
DFtoVW
#
Replace any reference to the old module name DFtoVW
with vowpalwabbit.dftovw
.
sklearn_vw
#
Replace any reference to the old module name sklearn_vw
with vowpalwabbit.sklearn
.
Class names#
Replace
vowpalwabbit.pyvw.vw
withvowpalwabbit.Workspace
Replace
vowpalwabbit.pyvw.example
withvowpalwabbit.Example
Replace
vowpalwabbit.pyvw.example_namespace
withvowpalwabbit.ExampleNamespace
Replace
vowpalwabbit.pyvw.namespace_id
withvowpalwabbit.NamespaceId
Replace
vowpalwabbit.pyvw.abstract_label
withvowpalwabbit.AbstractLabel
Replace
vowpalwabbit.pyvw.simple_label
withvowpalwabbit.SimpleLabel
Replace
vowpalwabbit.pyvw.multiclass_label
withvowpalwabbit.MulticlassLabel
Replace
vowpalwabbit.pyvw.multiclass_probabilities_label
withvowpalwabbit.MulticlassProbabilitiesLabel
Replace
vowpalwabbit.pyvw.cost_sensitive_label
withvowpalwabbit.CostSensitiveLabel
Replace
vowpalwabbit.pyvw.cbandits_label
withvowpalwabbit.CBLabel
get_prediction
#
Instead of calling the free function vowpalwabbit.pyvw.get_prediction()
call vowpalwabbit.Example.get_prediction()
on an vowpalwabbit.Example
instance.
Label types and prediction types#
Instead of using the prediction type integer constants such as
vowpalwabbit.pyvw.pylibvw.vw.pSCALAR
use the corresponding value invowpalwabbit.PredictionType
Instead of using the label type integer constants such as
vowpalwabbit.pyvw.pylibvw.vw.lSimple
use the corresponding value invowpalwabbit.LabelType
Instead of
vowpalwabbit.pyvw.pylibvw.vw.lBinary
usevowpalwabbit.LabelType.SCALAR
Instead of
vowpalwabbit.pyvw.pylibvw.vw.lDefault
use a value ofNone
vowpalwabbit.pyvw.pylibvw.vw.lMax
did not have a corresponding type
Getting a label from an Example#
If using
vowpalwabbit.Example.get_label()
, you should change the parameter from a class type to avowpalwabbit.LabelType
.If calling
vowpalwabbit.AbstractLabel.from_example()
. This has changed from a method on an existing instance to a static factory function which accepts anvowpalwabbit.Example
and returns an instance of the correspodning label type. Usingvowpalwabbit.Example.get_label()
is preferred.
ExampleNamespace.push_features#
The first argument of vowpalwabbit.ExampleNamespace.push_features()
was removed as it was not needed and unused. Using two arguments is deprecated, to fix the callsites remove the first argument.