What is this?
Python helper for running vowpalwabbit on multiple command line arguments and have programmatic access to results.
Getting started
Initialize the wrapper
from vw_executor.vw import Vw
vw = Vw(
'path to cache folder',
'path to vw binary' # Optional. If empty, pyvw is used
)
Run on single configuration
result = vw.train(INPUTS, CONFIGURATION)
where
INPUTS - list of paths to input files
CONFIGURATION
Every configuration can be defined using one of the following ways:
- string. I.e.
result = vw.train(['input1.txt'], '--cb_explore_adf --dsjson')
- dictionary. In this case, for every key/value pair:
- If value is None/NaN the whole pair is skipped
- If key starts with '#', key is skipped
- Otherwise f'{key} {value}' is added to command line
For example,
vw.train(['input1.txt'], {'#base': '--cb_explore_adf --dsjson', '--epsilon': 0.2, '--learning_rate': None})
is running vw binary with the following command line:
--cb_explore_adf --dsjson --epsilon 0.2
Run on multiple configurations
result = vw.train(INPUTS, CONFIGURATIONS)
CONFIGURATIONS is the list of CONFIGURATION here. It is recommended to use helper vw_opts.Grid class in order to create it. Grid can be constructed using one of the following ways:
- From Iterable of CONFIGURATION. For example,
from vw_executor.vw_opts import Grid
vw.train(['input1.txt'], Grid(['--cb_explore_adf --dsjson -l 0.1', '--cb_explore_adf --dsjson -l 0.2']))
- From dictionary with string keys and iterable values.
- Grid({'-k': ['v1', 'v2']}) is equivalent to Grid(['-k v1', '-k v2'])
- Grid({'-k1': [v1, v2], '-k2': [v3, v4]}) is equivalent to Grid(['-k1 v1 -k2 v3', '-k1 v1 -k2 v4', '-k1 v2 -k2 v3', '-k1 v2 -k2 v4'])
Grid supports multiplication("and") and summation("or") operators. For example,
Grid({
'-k1': ['v1, v2']
}) * (Grid({'-k2': ['v3']}) + Grid({'-k3': ['v4']}))
is equivalent to
Grid(['-k1 v1 -k2 v3', '-k1 v1 -k3 v4', '-k1 v2 -k2 v3', '-k1 v2 -k3 v4'])
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
vw-executor-0.3.3.tar.gz
(14.8 kB
view details)
File details
Details for the file vw-executor-0.3.3.tar.gz.
File metadata
- Download URL: vw-executor-0.3.3.tar.gz
- Upload date:
- Size: 14.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71b270008f4665b7569e0c24b05f3320eafb6e0ea23a1d5192f34a3177453476
|
|
| MD5 |
f97930670f6285feffadca5413701546
|
|
| BLAKE2b-256 |
032b2fbdbcd04971cd0f92591d2bffe878d4a65d9c9cf843e0f437d7701645f9
|