repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
MillionIntegrals/vel
vel/util/network.py
convolutional_layer_series
def convolutional_layer_series(initial_size, layer_sequence): """ Execute a series of convolutional layer transformations to the size number """ size = initial_size for filter_size, padding, stride in layer_sequence: size = convolution_size_equation(size, filter_size, padding, stride) return s...
python
def convolutional_layer_series(initial_size, layer_sequence): """ Execute a series of convolutional layer transformations to the size number """ size = initial_size for filter_size, padding, stride in layer_sequence: size = convolution_size_equation(size, filter_size, padding, stride) return s...
[ "def", "convolutional_layer_series", "(", "initial_size", ",", "layer_sequence", ")", ":", "size", "=", "initial_size", "for", "filter_size", ",", "padding", ",", "stride", "in", "layer_sequence", ":", "size", "=", "convolution_size_equation", "(", "size", ",", "f...
Execute a series of convolutional layer transformations to the size number
[ "Execute", "a", "series", "of", "convolutional", "layer", "transformations", "to", "the", "size", "number" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/network.py#L34-L41
train
MillionIntegrals/vel
vel/api/model.py
Model.train
def train(self, mode=True): r""" Sets the module in training mode. This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, ...
python
def train(self, mode=True): r""" Sets the module in training mode. This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, ...
[ "def", "train", "(", "self", ",", "mode", "=", "True", ")", ":", "r", "super", "(", ")", ".", "train", "(", "mode", ")", "if", "mode", ":", "mu", ".", "apply_leaf", "(", "self", ",", "mu", ".", "set_train_mode", ")", "return", "self" ]
r""" Sets the module in training mode. This has any effect only on certain modules. See documentations of particular modules for details of their behaviors in training/evaluation mode, if they are affected, e.g. :class:`Dropout`, :class:`BatchNorm`, etc. Returns: ...
[ "r", "Sets", "the", "module", "in", "training", "mode", "." ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/model.py#L18-L35
train
MillionIntegrals/vel
vel/api/model.py
Model.summary
def summary(self, input_size=None, hashsummary=False): """ Print a model summary """ if input_size is None: print(self) print("-" * 120) number = sum(p.numel() for p in self.model.parameters()) print("Number of model parameters: {:,}".format(number)) ...
python
def summary(self, input_size=None, hashsummary=False): """ Print a model summary """ if input_size is None: print(self) print("-" * 120) number = sum(p.numel() for p in self.model.parameters()) print("Number of model parameters: {:,}".format(number)) ...
[ "def", "summary", "(", "self", ",", "input_size", "=", "None", ",", "hashsummary", "=", "False", ")", ":", "if", "input_size", "is", "None", ":", "print", "(", "self", ")", "print", "(", "\"-\"", "*", "120", ")", "number", "=", "sum", "(", "p", "."...
Print a model summary
[ "Print", "a", "model", "summary" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/model.py#L37-L51
train
MillionIntegrals/vel
vel/api/model.py
Model.hashsummary
def hashsummary(self): """ Print a model summary - checksums of each layer parameters """ children = list(self.children()) result = [] for child in children: result.extend(hashlib.sha256(x.detach().cpu().numpy().tobytes()).hexdigest() for x in child.parameters()) r...
python
def hashsummary(self): """ Print a model summary - checksums of each layer parameters """ children = list(self.children()) result = [] for child in children: result.extend(hashlib.sha256(x.detach().cpu().numpy().tobytes()).hexdigest() for x in child.parameters()) r...
[ "def", "hashsummary", "(", "self", ")", ":", "children", "=", "list", "(", "self", ".", "children", "(", ")", ")", "result", "=", "[", "]", "for", "child", "in", "children", ":", "result", ".", "extend", "(", "hashlib", ".", "sha256", "(", "x", "."...
Print a model summary - checksums of each layer parameters
[ "Print", "a", "model", "summary", "-", "checksums", "of", "each", "layer", "parameters" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/model.py#L53-L62
train
MillionIntegrals/vel
vel/api/model.py
RnnLinearBackboneModel.zero_state
def zero_state(self, batch_size): """ Initial state of the network """ return torch.zeros(batch_size, self.state_dim, dtype=torch.float32)
python
def zero_state(self, batch_size): """ Initial state of the network """ return torch.zeros(batch_size, self.state_dim, dtype=torch.float32)
[ "def", "zero_state", "(", "self", ",", "batch_size", ")", ":", "return", "torch", ".", "zeros", "(", "batch_size", ",", "self", ".", "state_dim", ",", "dtype", "=", "torch", ".", "float32", ")" ]
Initial state of the network
[ "Initial", "state", "of", "the", "network" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/model.py#L121-L123
train
MillionIntegrals/vel
vel/api/model.py
SupervisedModel.loss
def loss(self, x_data, y_true): """ Forward propagate network and return a value of loss function """ y_pred = self(x_data) return y_pred, self.loss_value(x_data, y_true, y_pred)
python
def loss(self, x_data, y_true): """ Forward propagate network and return a value of loss function """ y_pred = self(x_data) return y_pred, self.loss_value(x_data, y_true, y_pred)
[ "def", "loss", "(", "self", ",", "x_data", ",", "y_true", ")", ":", "y_pred", "=", "self", "(", "x_data", ")", "return", "y_pred", ",", "self", ".", "loss_value", "(", "x_data", ",", "y_true", ",", "y_pred", ")" ]
Forward propagate network and return a value of loss function
[ "Forward", "propagate", "network", "and", "return", "a", "value", "of", "loss", "function" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/api/model.py#L139-L142
train
MillionIntegrals/vel
vel/models/vision/cifar_resnet_v2.py
ResNetV2.metrics
def metrics(self): """ Set of metrics for this model """ from vel.metrics.loss_metric import Loss from vel.metrics.accuracy import Accuracy return [Loss(), Accuracy()]
python
def metrics(self): """ Set of metrics for this model """ from vel.metrics.loss_metric import Loss from vel.metrics.accuracy import Accuracy return [Loss(), Accuracy()]
[ "def", "metrics", "(", "self", ")", ":", "from", "vel", ".", "metrics", ".", "loss_metric", "import", "Loss", "from", "vel", ".", "metrics", ".", "accuracy", "import", "Accuracy", "return", "[", "Loss", "(", ")", ",", "Accuracy", "(", ")", "]" ]
Set of metrics for this model
[ "Set", "of", "metrics", "for", "this", "model" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/models/vision/cifar_resnet_v2.py#L77-L81
train
MillionIntegrals/vel
vel/util/tensor_util.py
one_hot_encoding
def one_hot_encoding(input_tensor, num_labels): """ One-hot encode labels from input """ xview = input_tensor.view(-1, 1).to(torch.long) onehot = torch.zeros(xview.size(0), num_labels, device=input_tensor.device, dtype=torch.float) onehot.scatter_(1, xview, 1) return onehot.view(list(input_tensor.s...
python
def one_hot_encoding(input_tensor, num_labels): """ One-hot encode labels from input """ xview = input_tensor.view(-1, 1).to(torch.long) onehot = torch.zeros(xview.size(0), num_labels, device=input_tensor.device, dtype=torch.float) onehot.scatter_(1, xview, 1) return onehot.view(list(input_tensor.s...
[ "def", "one_hot_encoding", "(", "input_tensor", ",", "num_labels", ")", ":", "xview", "=", "input_tensor", ".", "view", "(", "-", "1", ",", "1", ")", ".", "to", "(", "torch", ".", "long", ")", "onehot", "=", "torch", ".", "zeros", "(", "xview", ".", ...
One-hot encode labels from input
[ "One", "-", "hot", "encode", "labels", "from", "input" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/tensor_util.py#L4-L10
train
MillionIntegrals/vel
vel/util/tensor_util.py
merge_first_two_dims
def merge_first_two_dims(tensor): """ Reshape tensor to merge first two dimensions """ shape = tensor.shape batch_size = shape[0] * shape[1] new_shape = tuple([batch_size] + list(shape[2:])) return tensor.view(new_shape)
python
def merge_first_two_dims(tensor): """ Reshape tensor to merge first two dimensions """ shape = tensor.shape batch_size = shape[0] * shape[1] new_shape = tuple([batch_size] + list(shape[2:])) return tensor.view(new_shape)
[ "def", "merge_first_two_dims", "(", "tensor", ")", ":", "shape", "=", "tensor", ".", "shape", "batch_size", "=", "shape", "[", "0", "]", "*", "shape", "[", "1", "]", "new_shape", "=", "tuple", "(", "[", "batch_size", "]", "+", "list", "(", "shape", "...
Reshape tensor to merge first two dimensions
[ "Reshape", "tensor", "to", "merge", "first", "two", "dimensions" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/tensor_util.py#L13-L18
train
MillionIntegrals/vel
vel/rl/vecenv/dummy.py
DummyVecEnvWrapper.instantiate
def instantiate(self, parallel_envs, seed=0, preset='default') -> VecEnv: """ Create vectorized environments """ envs = DummyVecEnv([self._creation_function(i, seed, preset) for i in range(parallel_envs)]) if self.frame_history is not None: envs = VecFrameStack(envs, self.frame_hist...
python
def instantiate(self, parallel_envs, seed=0, preset='default') -> VecEnv: """ Create vectorized environments """ envs = DummyVecEnv([self._creation_function(i, seed, preset) for i in range(parallel_envs)]) if self.frame_history is not None: envs = VecFrameStack(envs, self.frame_hist...
[ "def", "instantiate", "(", "self", ",", "parallel_envs", ",", "seed", "=", "0", ",", "preset", "=", "'default'", ")", "->", "VecEnv", ":", "envs", "=", "DummyVecEnv", "(", "[", "self", ".", "_creation_function", "(", "i", ",", "seed", ",", "preset", ")...
Create vectorized environments
[ "Create", "vectorized", "environments" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/vecenv/dummy.py#L16-L23
train
MillionIntegrals/vel
vel/rl/vecenv/dummy.py
DummyVecEnvWrapper.instantiate_single
def instantiate_single(self, seed=0, preset='default'): """ Create a new Env instance - single """ env = self.env.instantiate(seed=seed, serial_id=0, preset=preset) if self.frame_history is not None: env = FrameStack(env, self.frame_history) return env
python
def instantiate_single(self, seed=0, preset='default'): """ Create a new Env instance - single """ env = self.env.instantiate(seed=seed, serial_id=0, preset=preset) if self.frame_history is not None: env = FrameStack(env, self.frame_history) return env
[ "def", "instantiate_single", "(", "self", ",", "seed", "=", "0", ",", "preset", "=", "'default'", ")", ":", "env", "=", "self", ".", "env", ".", "instantiate", "(", "seed", "=", "seed", ",", "serial_id", "=", "0", ",", "preset", "=", "preset", ")", ...
Create a new Env instance - single
[ "Create", "a", "new", "Env", "instance", "-", "single" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/vecenv/dummy.py#L25-L32
train
MillionIntegrals/vel
vel/rl/vecenv/dummy.py
DummyVecEnvWrapper._creation_function
def _creation_function(self, idx, seed, preset): """ Helper function to create a proper closure around supplied values """ return lambda: self.env.instantiate(seed=seed, serial_id=idx, preset=preset)
python
def _creation_function(self, idx, seed, preset): """ Helper function to create a proper closure around supplied values """ return lambda: self.env.instantiate(seed=seed, serial_id=idx, preset=preset)
[ "def", "_creation_function", "(", "self", ",", "idx", ",", "seed", ",", "preset", ")", ":", "return", "lambda", ":", "self", ".", "env", ".", "instantiate", "(", "seed", "=", "seed", ",", "serial_id", "=", "idx", ",", "preset", "=", "preset", ")" ]
Helper function to create a proper closure around supplied values
[ "Helper", "function", "to", "create", "a", "proper", "closure", "around", "supplied", "values" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/vecenv/dummy.py#L34-L36
train
MillionIntegrals/vel
vel/rl/models/stochastic_policy_model_separate.py
StochasticPolicyModelSeparate.policy
def policy(self, observations): """ Calculate only action head for given state """ input_data = self.input_block(observations) policy_base_output = self.policy_backbone(input_data) policy_params = self.action_head(policy_base_output) return policy_params
python
def policy(self, observations): """ Calculate only action head for given state """ input_data = self.input_block(observations) policy_base_output = self.policy_backbone(input_data) policy_params = self.action_head(policy_base_output) return policy_params
[ "def", "policy", "(", "self", ",", "observations", ")", ":", "input_data", "=", "self", ".", "input_block", "(", "observations", ")", "policy_base_output", "=", "self", ".", "policy_backbone", "(", "input_data", ")", "policy_params", "=", "self", ".", "action_...
Calculate only action head for given state
[ "Calculate", "only", "action", "head", "for", "given", "state" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/models/stochastic_policy_model_separate.py#L85-L90
train
MillionIntegrals/vel
vel/phase/cycle.py
CycleCallback._init_cycle_dict
def _init_cycle_dict(self): """ Populate a cycle dict """ dict_arr = np.zeros(self.epochs, dtype=int) length_arr = np.zeros(self.epochs, dtype=int) start_arr = np.zeros(self.epochs, dtype=int) c_len = self.cycle_len idx = 0 for i in range(self.cycles): ...
python
def _init_cycle_dict(self): """ Populate a cycle dict """ dict_arr = np.zeros(self.epochs, dtype=int) length_arr = np.zeros(self.epochs, dtype=int) start_arr = np.zeros(self.epochs, dtype=int) c_len = self.cycle_len idx = 0 for i in range(self.cycles): ...
[ "def", "_init_cycle_dict", "(", "self", ")", ":", "dict_arr", "=", "np", ".", "zeros", "(", "self", ".", "epochs", ",", "dtype", "=", "int", ")", "length_arr", "=", "np", ".", "zeros", "(", "self", ".", "epochs", ",", "dtype", "=", "int", ")", "sta...
Populate a cycle dict
[ "Populate", "a", "cycle", "dict" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/phase/cycle.py#L34-L53
train
MillionIntegrals/vel
vel/phase/cycle.py
CycleCallback.on_batch_begin
def on_batch_begin(self, batch_info: BatchInfo): """ Set proper learning rate """ cycle_length = self.cycle_lengths[batch_info.local_epoch_number - 1] cycle_start = self.cycle_starts[batch_info.local_epoch_number - 1] numerator = (batch_info.local_epoch_number - cycle_start - 1) * batch...
python
def on_batch_begin(self, batch_info: BatchInfo): """ Set proper learning rate """ cycle_length = self.cycle_lengths[batch_info.local_epoch_number - 1] cycle_start = self.cycle_starts[batch_info.local_epoch_number - 1] numerator = (batch_info.local_epoch_number - cycle_start - 1) * batch...
[ "def", "on_batch_begin", "(", "self", ",", "batch_info", ":", "BatchInfo", ")", ":", "cycle_length", "=", "self", ".", "cycle_lengths", "[", "batch_info", ".", "local_epoch_number", "-", "1", "]", "cycle_start", "=", "self", ".", "cycle_starts", "[", "batch_in...
Set proper learning rate
[ "Set", "proper", "learning", "rate" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/phase/cycle.py#L55-L73
train
MillionIntegrals/vel
vel/phase/cycle.py
CycleCallback.set_lr
def set_lr(self, lr): """ Set a learning rate for the optimizer """ if isinstance(lr, list): for group_lr, param_group in zip(lr, self.optimizer.param_groups): param_group['lr'] = group_lr else: for param_group in self.optimizer.param_groups: ...
python
def set_lr(self, lr): """ Set a learning rate for the optimizer """ if isinstance(lr, list): for group_lr, param_group in zip(lr, self.optimizer.param_groups): param_group['lr'] = group_lr else: for param_group in self.optimizer.param_groups: ...
[ "def", "set_lr", "(", "self", ",", "lr", ")", ":", "if", "isinstance", "(", "lr", ",", "list", ")", ":", "for", "group_lr", ",", "param_group", "in", "zip", "(", "lr", ",", "self", ".", "optimizer", ".", "param_groups", ")", ":", "param_group", "[", ...
Set a learning rate for the optimizer
[ "Set", "a", "learning", "rate", "for", "the", "optimizer" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/phase/cycle.py#L75-L82
train
MillionIntegrals/vel
vel/internals/parser.py
Variable.parameter_constructor
def parameter_constructor(cls, loader, node): """ Construct variable instance from yaml node """ value = loader.construct_scalar(node) if isinstance(value, str): if '=' in value: (varname, varvalue) = Parser.parse_equality(value) return cls(varname, v...
python
def parameter_constructor(cls, loader, node): """ Construct variable instance from yaml node """ value = loader.construct_scalar(node) if isinstance(value, str): if '=' in value: (varname, varvalue) = Parser.parse_equality(value) return cls(varname, v...
[ "def", "parameter_constructor", "(", "cls", ",", "loader", ",", "node", ")", ":", "value", "=", "loader", ".", "construct_scalar", "(", "node", ")", "if", "isinstance", "(", "value", ",", "str", ")", ":", "if", "'='", "in", "value", ":", "(", "varname"...
Construct variable instance from yaml node
[ "Construct", "variable", "instance", "from", "yaml", "node" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/parser.py#L18-L29
train
MillionIntegrals/vel
vel/internals/parser.py
Parser.register
def register(cls): """ Register variable handling in YAML """ if not cls.IS_LOADED: cls.IS_LOADED = True yaml.add_constructor('!param', Parameter.parameter_constructor, Loader=yaml.SafeLoader) yaml.add_constructor('!env', EnvironmentVariable.parameter_constructor, Lo...
python
def register(cls): """ Register variable handling in YAML """ if not cls.IS_LOADED: cls.IS_LOADED = True yaml.add_constructor('!param', Parameter.parameter_constructor, Loader=yaml.SafeLoader) yaml.add_constructor('!env', EnvironmentVariable.parameter_constructor, Lo...
[ "def", "register", "(", "cls", ")", ":", "if", "not", "cls", ".", "IS_LOADED", ":", "cls", ".", "IS_LOADED", "=", "True", "yaml", ".", "add_constructor", "(", "'!param'", ",", "Parameter", ".", "parameter_constructor", ",", "Loader", "=", "yaml", ".", "S...
Register variable handling in YAML
[ "Register", "variable", "handling", "in", "YAML" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/parser.py#L74-L80
train
MillionIntegrals/vel
vel/internals/parser.py
Parser.parse_equality
def parse_equality(cls, equality_string): """ Parse some simple equality statements """ cls.register() assert '=' in equality_string, "There must be an '=' sign in the equality" [left_side, right_side] = equality_string.split('=', 1) left_side_value = yaml.safe_load(left_side.st...
python
def parse_equality(cls, equality_string): """ Parse some simple equality statements """ cls.register() assert '=' in equality_string, "There must be an '=' sign in the equality" [left_side, right_side] = equality_string.split('=', 1) left_side_value = yaml.safe_load(left_side.st...
[ "def", "parse_equality", "(", "cls", ",", "equality_string", ")", ":", "cls", ".", "register", "(", ")", "assert", "'='", "in", "equality_string", ",", "\"There must be an '=' sign in the equality\"", "[", "left_side", ",", "right_side", "]", "=", "equality_string",...
Parse some simple equality statements
[ "Parse", "some", "simple", "equality", "statements" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/parser.py#L89-L100
train
MillionIntegrals/vel
vel/storage/backend/mongodb.py
MongoDbBackend.clean
def clean(self, initial_epoch): """ Remove entries from database that would get overwritten """ self.db.metrics.delete_many({'run_name': self.model_config.run_name, 'epoch_idx': {'$gt': initial_epoch}})
python
def clean(self, initial_epoch): """ Remove entries from database that would get overwritten """ self.db.metrics.delete_many({'run_name': self.model_config.run_name, 'epoch_idx': {'$gt': initial_epoch}})
[ "def", "clean", "(", "self", ",", "initial_epoch", ")", ":", "self", ".", "db", ".", "metrics", ".", "delete_many", "(", "{", "'run_name'", ":", "self", ".", "model_config", ".", "run_name", ",", "'epoch_idx'", ":", "{", "'$gt'", ":", "initial_epoch", "}...
Remove entries from database that would get overwritten
[ "Remove", "entries", "from", "database", "that", "would", "get", "overwritten" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/backend/mongodb.py#L13-L15
train
MillionIntegrals/vel
vel/storage/backend/mongodb.py
MongoDbBackend.store_config
def store_config(self, configuration): """ Store model parameters in the database """ run_name = self.model_config.run_name self.db.configs.delete_many({'run_name': self.model_config.run_name}) configuration = configuration.copy() configuration['run_name'] = run_name s...
python
def store_config(self, configuration): """ Store model parameters in the database """ run_name = self.model_config.run_name self.db.configs.delete_many({'run_name': self.model_config.run_name}) configuration = configuration.copy() configuration['run_name'] = run_name s...
[ "def", "store_config", "(", "self", ",", "configuration", ")", ":", "run_name", "=", "self", ".", "model_config", ".", "run_name", "self", ".", "db", ".", "configs", ".", "delete_many", "(", "{", "'run_name'", ":", "self", ".", "model_config", ".", "run_na...
Store model parameters in the database
[ "Store", "model", "parameters", "in", "the", "database" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/backend/mongodb.py#L17-L26
train
MillionIntegrals/vel
vel/storage/backend/mongodb.py
MongoDbBackend.get_frame
def get_frame(self): """ Get a dataframe of metrics from this storage """ metric_items = list(self.db.metrics.find({'run_name': self.model_config.run_name}).sort('epoch_idx')) if len(metric_items) == 0: return pd.DataFrame(columns=['run_name']) else: return pd.Dat...
python
def get_frame(self): """ Get a dataframe of metrics from this storage """ metric_items = list(self.db.metrics.find({'run_name': self.model_config.run_name}).sort('epoch_idx')) if len(metric_items) == 0: return pd.DataFrame(columns=['run_name']) else: return pd.Dat...
[ "def", "get_frame", "(", "self", ")", ":", "metric_items", "=", "list", "(", "self", ".", "db", ".", "metrics", ".", "find", "(", "{", "'run_name'", ":", "self", ".", "model_config", ".", "run_name", "}", ")", ".", "sort", "(", "'epoch_idx'", ")", ")...
Get a dataframe of metrics from this storage
[ "Get", "a", "dataframe", "of", "metrics", "from", "this", "storage" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/backend/mongodb.py#L28-L34
train
MillionIntegrals/vel
vel/rl/buffers/prioritized_circular_replay_buffer.py
PrioritizedCircularReplayBuffer._get_transitions
def _get_transitions(self, probs, indexes, tree_idxs, batch_info, forward_steps=1, discount_factor=1.0): """ Return batch of frames for given indexes """ if forward_steps > 1: transition_arrays = self.backend.get_transitions_forward_steps(indexes, forward_steps, discount_factor) else...
python
def _get_transitions(self, probs, indexes, tree_idxs, batch_info, forward_steps=1, discount_factor=1.0): """ Return batch of frames for given indexes """ if forward_steps > 1: transition_arrays = self.backend.get_transitions_forward_steps(indexes, forward_steps, discount_factor) else...
[ "def", "_get_transitions", "(", "self", ",", "probs", ",", "indexes", ",", "tree_idxs", ",", "batch_info", ",", "forward_steps", "=", "1", ",", "discount_factor", "=", "1.0", ")", ":", "if", "forward_steps", ">", "1", ":", "transition_arrays", "=", "self", ...
Return batch of frames for given indexes
[ "Return", "batch", "of", "frames", "for", "given", "indexes" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/buffers/prioritized_circular_replay_buffer.py#L46-L75
train
MillionIntegrals/vel
vel/rl/api/env_roller.py
EnvRollerBase.rollout
def rollout(self, batch_info: BatchInfo, model: Model, number_of_steps: int) -> Rollout: """ Roll-out the environment and return it """ raise NotImplementedError
python
def rollout(self, batch_info: BatchInfo, model: Model, number_of_steps: int) -> Rollout: """ Roll-out the environment and return it """ raise NotImplementedError
[ "def", "rollout", "(", "self", ",", "batch_info", ":", "BatchInfo", ",", "model", ":", "Model", ",", "number_of_steps", ":", "int", ")", "->", "Rollout", ":", "raise", "NotImplementedError" ]
Roll-out the environment and return it
[ "Roll", "-", "out", "the", "environment", "and", "return", "it" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/api/env_roller.py#L17-L19
train
MillionIntegrals/vel
vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py
BufferedMixedPolicyIterationReinforcer.train_epoch
def train_epoch(self, epoch_info: EpochInfo, interactive=True): """ Train model on an epoch of a fixed number of batch updates """ epoch_info.on_epoch_begin() if interactive: iterator = tqdm.trange(epoch_info.batches_per_epoch, file=sys.stdout, desc="Training", unit="batch") ...
python
def train_epoch(self, epoch_info: EpochInfo, interactive=True): """ Train model on an epoch of a fixed number of batch updates """ epoch_info.on_epoch_begin() if interactive: iterator = tqdm.trange(epoch_info.batches_per_epoch, file=sys.stdout, desc="Training", unit="batch") ...
[ "def", "train_epoch", "(", "self", ",", "epoch_info", ":", "EpochInfo", ",", "interactive", "=", "True", ")", ":", "epoch_info", ".", "on_epoch_begin", "(", ")", "if", "interactive", ":", "iterator", "=", "tqdm", ".", "trange", "(", "epoch_info", ".", "bat...
Train model on an epoch of a fixed number of batch updates
[ "Train", "model", "on", "an", "epoch", "of", "a", "fixed", "number", "of", "batch", "updates" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py#L75-L92
train
MillionIntegrals/vel
vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py
BufferedMixedPolicyIterationReinforcer.train_batch
def train_batch(self, batch_info: BatchInfo): """ Single, most atomic 'step' of learning this reinforcer can perform """ batch_info['sub_batch_data'] = [] self.on_policy_train_batch(batch_info) if self.settings.experience_replay > 0 and self.env_roller.is_ready_for_sampling(): ...
python
def train_batch(self, batch_info: BatchInfo): """ Single, most atomic 'step' of learning this reinforcer can perform """ batch_info['sub_batch_data'] = [] self.on_policy_train_batch(batch_info) if self.settings.experience_replay > 0 and self.env_roller.is_ready_for_sampling(): ...
[ "def", "train_batch", "(", "self", ",", "batch_info", ":", "BatchInfo", ")", ":", "batch_info", "[", "'sub_batch_data'", "]", "=", "[", "]", "self", ".", "on_policy_train_batch", "(", "batch_info", ")", "if", "self", ".", "settings", ".", "experience_replay", ...
Single, most atomic 'step' of learning this reinforcer can perform
[ "Single", "most", "atomic", "step", "of", "learning", "this", "reinforcer", "can", "perform" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py#L94-L110
train
MillionIntegrals/vel
vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py
BufferedMixedPolicyIterationReinforcer.on_policy_train_batch
def on_policy_train_batch(self, batch_info: BatchInfo): """ Perform an 'on-policy' training step of evaluating an env and a single backpropagation step """ self.model.train() rollout = self.env_roller.rollout(batch_info, self.model, self.settings.number_of_steps).to_device(self.device) ...
python
def on_policy_train_batch(self, batch_info: BatchInfo): """ Perform an 'on-policy' training step of evaluating an env and a single backpropagation step """ self.model.train() rollout = self.env_roller.rollout(batch_info, self.model, self.settings.number_of_steps).to_device(self.device) ...
[ "def", "on_policy_train_batch", "(", "self", ",", "batch_info", ":", "BatchInfo", ")", ":", "self", ".", "model", ".", "train", "(", ")", "rollout", "=", "self", ".", "env_roller", ".", "rollout", "(", "batch_info", ",", "self", ".", "model", ",", "self"...
Perform an 'on-policy' training step of evaluating an env and a single backpropagation step
[ "Perform", "an", "on", "-", "policy", "training", "step", "of", "evaluating", "an", "env", "and", "a", "single", "backpropagation", "step" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py#L112-L127
train
MillionIntegrals/vel
vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py
BufferedMixedPolicyIterationReinforcer.off_policy_train_batch
def off_policy_train_batch(self, batch_info: BatchInfo): """ Perform an 'off-policy' training step of sampling the replay buffer and gradient descent """ self.model.train() rollout = self.env_roller.sample(batch_info, self.model, self.settings.number_of_steps).to_device(self.device) ba...
python
def off_policy_train_batch(self, batch_info: BatchInfo): """ Perform an 'off-policy' training step of sampling the replay buffer and gradient descent """ self.model.train() rollout = self.env_roller.sample(batch_info, self.model, self.settings.number_of_steps).to_device(self.device) ba...
[ "def", "off_policy_train_batch", "(", "self", ",", "batch_info", ":", "BatchInfo", ")", ":", "self", ".", "model", ".", "train", "(", ")", "rollout", "=", "self", ".", "env_roller", ".", "sample", "(", "batch_info", ",", "self", ".", "model", ",", "self"...
Perform an 'off-policy' training step of sampling the replay buffer and gradient descent
[ "Perform", "an", "off", "-", "policy", "training", "step", "of", "sampling", "the", "replay", "buffer", "and", "gradient", "descent" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/reinforcers/buffered_mixed_policy_iteration_reinforcer.py#L129-L142
train
MillionIntegrals/vel
vel/storage/strategy/classic_checkpoint_strategy.py
ClassicCheckpointStrategy.should_store_best_checkpoint
def should_store_best_checkpoint(self, epoch_idx, metrics) -> bool: """ Should we store current checkpoint as the best """ if not self.store_best: return False metric = metrics[self.metric] if better(self._current_best_metric_value, metric, self.metric_mode): se...
python
def should_store_best_checkpoint(self, epoch_idx, metrics) -> bool: """ Should we store current checkpoint as the best """ if not self.store_best: return False metric = metrics[self.metric] if better(self._current_best_metric_value, metric, self.metric_mode): se...
[ "def", "should_store_best_checkpoint", "(", "self", ",", "epoch_idx", ",", "metrics", ")", "->", "bool", ":", "if", "not", "self", ".", "store_best", ":", "return", "False", "metric", "=", "metrics", "[", "self", ".", "metric", "]", "if", "better", "(", ...
Should we store current checkpoint as the best
[ "Should", "we", "store", "current", "checkpoint", "as", "the", "best" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/strategy/classic_checkpoint_strategy.py#L27-L38
train
MillionIntegrals/vel
vel/sources/nlp/imdb.py
create
def create(model_config, batch_size, vectors=None): """ Create an IMDB dataset """ path = model_config.data_dir('imdb') text_field = data.Field(lower=True, tokenize='spacy', batch_first=True) label_field = data.LabelField(is_target=True) train_source, test_source = IMDBCached.splits( root=...
python
def create(model_config, batch_size, vectors=None): """ Create an IMDB dataset """ path = model_config.data_dir('imdb') text_field = data.Field(lower=True, tokenize='spacy', batch_first=True) label_field = data.LabelField(is_target=True) train_source, test_source = IMDBCached.splits( root=...
[ "def", "create", "(", "model_config", ",", "batch_size", ",", "vectors", "=", "None", ")", ":", "path", "=", "model_config", ".", "data_dir", "(", "'imdb'", ")", "text_field", "=", "data", ".", "Field", "(", "lower", "=", "True", ",", "tokenize", "=", ...
Create an IMDB dataset
[ "Create", "an", "IMDB", "dataset" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/sources/nlp/imdb.py#L48-L73
train
MillionIntegrals/vel
vel/commands/augvis_command.py
AugmentationVisualizationCommand.run
def run(self): """ Run the visualization """ dataset = self.source.train_dataset() num_samples = len(dataset) fig, ax = plt.subplots(self.cases, self.samples+1) selected_sample = np.sort(np.random.choice(num_samples, self.cases, replace=False)) for i in range(self.case...
python
def run(self): """ Run the visualization """ dataset = self.source.train_dataset() num_samples = len(dataset) fig, ax = plt.subplots(self.cases, self.samples+1) selected_sample = np.sort(np.random.choice(num_samples, self.cases, replace=False)) for i in range(self.case...
[ "def", "run", "(", "self", ")", ":", "dataset", "=", "self", ".", "source", ".", "train_dataset", "(", ")", "num_samples", "=", "len", "(", "dataset", ")", "fig", ",", "ax", "=", "plt", ".", "subplots", "(", "self", ".", "cases", ",", "self", ".", ...
Run the visualization
[ "Run", "the", "visualization" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/commands/augvis_command.py#L14-L34
train
MillionIntegrals/vel
vel/rl/env/classic_control.py
env_maker
def env_maker(environment_id, seed, serial_id, monitor=False, allow_early_resets=False): """ Create a classic control environment with basic set of wrappers """ env = gym.make(environment_id) env.seed(seed + serial_id) # Monitoring the env if monitor: logdir = logger.get_dir() and os.path.j...
python
def env_maker(environment_id, seed, serial_id, monitor=False, allow_early_resets=False): """ Create a classic control environment with basic set of wrappers """ env = gym.make(environment_id) env.seed(seed + serial_id) # Monitoring the env if monitor: logdir = logger.get_dir() and os.path.j...
[ "def", "env_maker", "(", "environment_id", ",", "seed", ",", "serial_id", ",", "monitor", "=", "False", ",", "allow_early_resets", "=", "False", ")", ":", "env", "=", "gym", ".", "make", "(", "environment_id", ")", "env", ".", "seed", "(", "seed", "+", ...
Create a classic control environment with basic set of wrappers
[ "Create", "a", "classic", "control", "environment", "with", "basic", "set", "of", "wrappers" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/env/classic_control.py#L25-L38
train
MillionIntegrals/vel
vel/models/imagenet/resnet34.py
Resnet34.freeze
def freeze(self, number=None): """ Freeze given number of layers in the model """ if number is None: number = self.head_layers for idx, child in enumerate(self.model.children()): if idx < number: mu.freeze_layer(child)
python
def freeze(self, number=None): """ Freeze given number of layers in the model """ if number is None: number = self.head_layers for idx, child in enumerate(self.model.children()): if idx < number: mu.freeze_layer(child)
[ "def", "freeze", "(", "self", ",", "number", "=", "None", ")", ":", "if", "number", "is", "None", ":", "number", "=", "self", ".", "head_layers", "for", "idx", ",", "child", "in", "enumerate", "(", "self", ".", "model", ".", "children", "(", ")", "...
Freeze given number of layers in the model
[ "Freeze", "given", "number", "of", "layers", "in", "the", "model" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/models/imagenet/resnet34.py#L66-L73
train
MillionIntegrals/vel
vel/models/imagenet/resnet34.py
Resnet34.unfreeze
def unfreeze(self): """ Unfreeze model layers """ for idx, child in enumerate(self.model.children()): mu.unfreeze_layer(child)
python
def unfreeze(self): """ Unfreeze model layers """ for idx, child in enumerate(self.model.children()): mu.unfreeze_layer(child)
[ "def", "unfreeze", "(", "self", ")", ":", "for", "idx", ",", "child", "in", "enumerate", "(", "self", ".", "model", ".", "children", "(", ")", ")", ":", "mu", ".", "unfreeze_layer", "(", "child", ")" ]
Unfreeze model layers
[ "Unfreeze", "model", "layers" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/models/imagenet/resnet34.py#L75-L78
train
MillionIntegrals/vel
vel/rl/algo/policy_gradient/acer.py
AcerPolicyGradient.update_average_model
def update_average_model(self, model): """ Update weights of the average model with new model observation """ for model_param, average_param in zip(model.parameters(), self.average_model.parameters()): # EWMA average model update average_param.data.mul_(self.average_model_alpha)....
python
def update_average_model(self, model): """ Update weights of the average model with new model observation """ for model_param, average_param in zip(model.parameters(), self.average_model.parameters()): # EWMA average model update average_param.data.mul_(self.average_model_alpha)....
[ "def", "update_average_model", "(", "self", ",", "model", ")", ":", "for", "model_param", ",", "average_param", "in", "zip", "(", "model", ".", "parameters", "(", ")", ",", "self", ".", "average_model", ".", "parameters", "(", ")", ")", ":", "average_param...
Update weights of the average model with new model observation
[ "Update", "weights", "of", "the", "average", "model", "with", "new", "model", "observation" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/acer.py#L43-L47
train
MillionIntegrals/vel
vel/rl/algo/policy_gradient/acer.py
AcerPolicyGradient.retrace
def retrace(self, rewards, dones, q_values, state_values, rho, final_values): """ Calculate Q retraced targets """ rho_bar = torch.min(torch.ones_like(rho) * self.retrace_rho_cap, rho) q_retraced_buffer = torch.zeros_like(rewards) next_value = final_values for i in reversed(ra...
python
def retrace(self, rewards, dones, q_values, state_values, rho, final_values): """ Calculate Q retraced targets """ rho_bar = torch.min(torch.ones_like(rho) * self.retrace_rho_cap, rho) q_retraced_buffer = torch.zeros_like(rewards) next_value = final_values for i in reversed(ra...
[ "def", "retrace", "(", "self", ",", "rewards", ",", "dones", ",", "q_values", ",", "state_values", ",", "rho", ",", "final_values", ")", ":", "rho_bar", "=", "torch", ".", "min", "(", "torch", ".", "ones_like", "(", "rho", ")", "*", "self", ".", "ret...
Calculate Q retraced targets
[ "Calculate", "Q", "retraced", "targets" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/algo/policy_gradient/acer.py#L170-L186
train
MillionIntegrals/vel
vel/rl/modules/action_head.py
DiagGaussianActionHead.logprob
def logprob(self, action_sample, pd_params): """ Log-likelihood """ means = pd_params[:, :, 0] log_std = pd_params[:, :, 1] std = torch.exp(log_std) z_score = (action_sample - means) / std return - (0.5 * ((z_score**2 + self.LOG2PI).sum(dim=-1)) + log_std.sum(dim=-1))
python
def logprob(self, action_sample, pd_params): """ Log-likelihood """ means = pd_params[:, :, 0] log_std = pd_params[:, :, 1] std = torch.exp(log_std) z_score = (action_sample - means) / std return - (0.5 * ((z_score**2 + self.LOG2PI).sum(dim=-1)) + log_std.sum(dim=-1))
[ "def", "logprob", "(", "self", ",", "action_sample", ",", "pd_params", ")", ":", "means", "=", "pd_params", "[", ":", ",", ":", ",", "0", "]", "log_std", "=", "pd_params", "[", ":", ",", ":", ",", "1", "]", "std", "=", "torch", ".", "exp", "(", ...
Log-likelihood
[ "Log", "-", "likelihood" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/action_head.py#L45-L54
train
MillionIntegrals/vel
vel/rl/modules/action_head.py
CategoricalActionHead.logprob
def logprob(self, actions, action_logits): """ Logarithm of probability of given sample """ neg_log_prob = F.nll_loss(action_logits, actions, reduction='none') return -neg_log_prob
python
def logprob(self, actions, action_logits): """ Logarithm of probability of given sample """ neg_log_prob = F.nll_loss(action_logits, actions, reduction='none') return -neg_log_prob
[ "def", "logprob", "(", "self", ",", "actions", ",", "action_logits", ")", ":", "neg_log_prob", "=", "F", ".", "nll_loss", "(", "action_logits", ",", "actions", ",", "reduction", "=", "'none'", ")", "return", "-", "neg_log_prob" ]
Logarithm of probability of given sample
[ "Logarithm", "of", "probability", "of", "given", "sample" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/action_head.py#L103-L106
train
MillionIntegrals/vel
vel/metrics/accuracy.py
Accuracy._value_function
def _value_function(self, x_input, y_true, y_pred): """ Return classification accuracy of input """ if len(y_true.shape) == 1: return y_pred.argmax(1).eq(y_true).double().mean().item() else: raise NotImplementedError
python
def _value_function(self, x_input, y_true, y_pred): """ Return classification accuracy of input """ if len(y_true.shape) == 1: return y_pred.argmax(1).eq(y_true).double().mean().item() else: raise NotImplementedError
[ "def", "_value_function", "(", "self", ",", "x_input", ",", "y_true", ",", "y_pred", ")", ":", "if", "len", "(", "y_true", ".", "shape", ")", "==", "1", ":", "return", "y_pred", ".", "argmax", "(", "1", ")", ".", "eq", "(", "y_true", ")", ".", "d...
Return classification accuracy of input
[ "Return", "classification", "accuracy", "of", "input" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/metrics/accuracy.py#L9-L14
train
MillionIntegrals/vel
vel/storage/streaming/visdom.py
VisdomStreaming.on_epoch_end
def on_epoch_end(self, epoch_info): """ Update data in visdom on push """ metrics_df = pd.DataFrame([epoch_info.result]).set_index('epoch_idx') visdom_append_metrics( self.vis, metrics_df, first_epoch=epoch_info.global_epoch_idx == 1 )
python
def on_epoch_end(self, epoch_info): """ Update data in visdom on push """ metrics_df = pd.DataFrame([epoch_info.result]).set_index('epoch_idx') visdom_append_metrics( self.vis, metrics_df, first_epoch=epoch_info.global_epoch_idx == 1 )
[ "def", "on_epoch_end", "(", "self", ",", "epoch_info", ")", ":", "metrics_df", "=", "pd", ".", "DataFrame", "(", "[", "epoch_info", ".", "result", "]", ")", ".", "set_index", "(", "'epoch_idx'", ")", "visdom_append_metrics", "(", "self", ".", "vis", ",", ...
Update data in visdom on push
[ "Update", "data", "in", "visdom", "on", "push" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/streaming/visdom.py#L22-L30
train
MillionIntegrals/vel
vel/storage/streaming/visdom.py
VisdomStreaming.on_batch_end
def on_batch_end(self, batch_info): """ Stream LR to visdom """ if self.settings.stream_lr: iteration_idx = ( float(batch_info.epoch_number) + float(batch_info.batch_number) / batch_info.batches_per_epoch ) lr = bat...
python
def on_batch_end(self, batch_info): """ Stream LR to visdom """ if self.settings.stream_lr: iteration_idx = ( float(batch_info.epoch_number) + float(batch_info.batch_number) / batch_info.batches_per_epoch ) lr = bat...
[ "def", "on_batch_end", "(", "self", ",", "batch_info", ")", ":", "if", "self", ".", "settings", ".", "stream_lr", ":", "iteration_idx", "=", "(", "float", "(", "batch_info", ".", "epoch_number", ")", "+", "float", "(", "batch_info", ".", "batch_number", ")...
Stream LR to visdom
[ "Stream", "LR", "to", "visdom" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/storage/streaming/visdom.py#L32-L48
train
MillionIntegrals/vel
vel/launcher.py
main
def main(): """ Paperboy entry point - parse the arguments and run a command """ parser = argparse.ArgumentParser(description='Paperboy deep learning launcher') parser.add_argument('config', metavar='FILENAME', help='Configuration file for the run') parser.add_argument('command', metavar='COMMAND', hel...
python
def main(): """ Paperboy entry point - parse the arguments and run a command """ parser = argparse.ArgumentParser(description='Paperboy deep learning launcher') parser.add_argument('config', metavar='FILENAME', help='Configuration file for the run') parser.add_argument('command', metavar='COMMAND', hel...
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Paperboy deep learning launcher'", ")", "parser", ".", "add_argument", "(", "'config'", ",", "metavar", "=", "'FILENAME'", ",", "help", "=", "'Configuratio...
Paperboy entry point - parse the arguments and run a command
[ "Paperboy", "entry", "point", "-", "parse", "the", "arguments", "and", "run", "a", "command" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/launcher.py#L10-L72
train
MillionIntegrals/vel
vel/util/random.py
set_seed
def set_seed(seed: int): """ Set random seed for python, numpy and pytorch RNGs """ random.seed(seed) np.random.seed(seed) torch.random.manual_seed(seed)
python
def set_seed(seed: int): """ Set random seed for python, numpy and pytorch RNGs """ random.seed(seed) np.random.seed(seed) torch.random.manual_seed(seed)
[ "def", "set_seed", "(", "seed", ":", "int", ")", ":", "random", ".", "seed", "(", "seed", ")", "np", ".", "random", ".", "seed", "(", "seed", ")", "torch", ".", "random", ".", "manual_seed", "(", "seed", ")" ]
Set random seed for python, numpy and pytorch RNGs
[ "Set", "random", "seed", "for", "python", "numpy", "and", "pytorch", "RNGs" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/random.py#L6-L10
train
MillionIntegrals/vel
vel/util/better.py
better
def better(old_value, new_value, mode): """ Check if new value is better than the old value""" if (old_value is None or np.isnan(old_value)) and (new_value is not None and not np.isnan(new_value)): return True if mode == 'min': return new_value < old_value elif mode == 'max': re...
python
def better(old_value, new_value, mode): """ Check if new value is better than the old value""" if (old_value is None or np.isnan(old_value)) and (new_value is not None and not np.isnan(new_value)): return True if mode == 'min': return new_value < old_value elif mode == 'max': re...
[ "def", "better", "(", "old_value", ",", "new_value", ",", "mode", ")", ":", "if", "(", "old_value", "is", "None", "or", "np", ".", "isnan", "(", "old_value", ")", ")", "and", "(", "new_value", "is", "not", "None", "and", "not", "np", ".", "isnan", ...
Check if new value is better than the old value
[ "Check", "if", "new", "value", "is", "better", "than", "the", "old", "value" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/util/better.py#L4-L14
train
MillionIntegrals/vel
vel/rl/modules/deterministic_critic_head.py
DeterministicCriticHead.reset_weights
def reset_weights(self): """ Initialize weights to sane defaults """ init.uniform_(self.linear.weight, -3e-3, 3e-3) init.zeros_(self.linear.bias)
python
def reset_weights(self): """ Initialize weights to sane defaults """ init.uniform_(self.linear.weight, -3e-3, 3e-3) init.zeros_(self.linear.bias)
[ "def", "reset_weights", "(", "self", ")", ":", "init", ".", "uniform_", "(", "self", ".", "linear", ".", "weight", ",", "-", "3e-3", ",", "3e-3", ")", "init", ".", "zeros_", "(", "self", ".", "linear", ".", "bias", ")" ]
Initialize weights to sane defaults
[ "Initialize", "weights", "to", "sane", "defaults" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/modules/deterministic_critic_head.py#L20-L23
train
MillionIntegrals/vel
vel/rl/discount_bootstrap.py
discount_bootstrap
def discount_bootstrap(rewards_buffer, dones_buffer, final_values, discount_factor, number_of_steps): """ Calculate state values bootstrapping off the following state values """ true_value_buffer = torch.zeros_like(rewards_buffer) # discount/bootstrap off value fn current_value = final_values for ...
python
def discount_bootstrap(rewards_buffer, dones_buffer, final_values, discount_factor, number_of_steps): """ Calculate state values bootstrapping off the following state values """ true_value_buffer = torch.zeros_like(rewards_buffer) # discount/bootstrap off value fn current_value = final_values for ...
[ "def", "discount_bootstrap", "(", "rewards_buffer", ",", "dones_buffer", ",", "final_values", ",", "discount_factor", ",", "number_of_steps", ")", ":", "true_value_buffer", "=", "torch", ".", "zeros_like", "(", "rewards_buffer", ")", "current_value", "=", "final_value...
Calculate state values bootstrapping off the following state values
[ "Calculate", "state", "values", "bootstrapping", "off", "the", "following", "state", "values" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/discount_bootstrap.py#L4-L15
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.find_project_directory
def find_project_directory(start_path) -> str: """ Locate top-level project directory """ start_path = os.path.realpath(start_path) possible_name = os.path.join(start_path, ModelConfig.PROJECT_FILE_NAME) if os.path.exists(possible_name): return start_path else: ...
python
def find_project_directory(start_path) -> str: """ Locate top-level project directory """ start_path = os.path.realpath(start_path) possible_name = os.path.join(start_path, ModelConfig.PROJECT_FILE_NAME) if os.path.exists(possible_name): return start_path else: ...
[ "def", "find_project_directory", "(", "start_path", ")", "->", "str", ":", "start_path", "=", "os", ".", "path", ".", "realpath", "(", "start_path", ")", "possible_name", "=", "os", ".", "path", ".", "join", "(", "start_path", ",", "ModelConfig", ".", "PRO...
Locate top-level project directory
[ "Locate", "top", "-", "level", "project", "directory" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L18-L30
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.from_file
def from_file(cls, filename: str, run_number: int, continue_training: bool = False, seed: int = None, device: str = 'cuda', params=None): """ Create model config from file """ with open(filename, 'r') as fp: model_config_contents = Parser.parse(fp) project_config_p...
python
def from_file(cls, filename: str, run_number: int, continue_training: bool = False, seed: int = None, device: str = 'cuda', params=None): """ Create model config from file """ with open(filename, 'r') as fp: model_config_contents = Parser.parse(fp) project_config_p...
[ "def", "from_file", "(", "cls", ",", "filename", ":", "str", ",", "run_number", ":", "int", ",", "continue_training", ":", "bool", "=", "False", ",", "seed", ":", "int", "=", "None", ",", "device", ":", "str", "=", "'cuda'", ",", "params", "=", "None...
Create model config from file
[ "Create", "model", "config", "from", "file" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L33-L58
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.from_memory
def from_memory(cls, model_data: dict, run_number: int, project_dir: str, continue_training=False, seed: int = None, device: str = 'cuda', params=None): """ Create model config from supplied data """ return ModelConfig( filename="[memory]", configuration=model...
python
def from_memory(cls, model_data: dict, run_number: int, project_dir: str, continue_training=False, seed: int = None, device: str = 'cuda', params=None): """ Create model config from supplied data """ return ModelConfig( filename="[memory]", configuration=model...
[ "def", "from_memory", "(", "cls", ",", "model_data", ":", "dict", ",", "run_number", ":", "int", ",", "project_dir", ":", "str", ",", "continue_training", "=", "False", ",", "seed", ":", "int", "=", "None", ",", "device", ":", "str", "=", "'cuda'", ","...
Create model config from supplied data
[ "Create", "model", "config", "from", "supplied", "data" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L61-L73
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.run_command
def run_command(self, command_name, varargs): """ Instantiate model class """ command_descriptor = self.get_command(command_name) return command_descriptor.run(*varargs)
python
def run_command(self, command_name, varargs): """ Instantiate model class """ command_descriptor = self.get_command(command_name) return command_descriptor.run(*varargs)
[ "def", "run_command", "(", "self", ",", "command_name", ",", "varargs", ")", ":", "command_descriptor", "=", "self", ".", "get_command", "(", "command_name", ")", "return", "command_descriptor", ".", "run", "(", "*", "varargs", ")" ]
Instantiate model class
[ "Instantiate", "model", "class" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L109-L112
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.project_data_dir
def project_data_dir(self, *args) -> str: """ Directory where to store data """ return os.path.normpath(os.path.join(self.project_dir, 'data', *args))
python
def project_data_dir(self, *args) -> str: """ Directory where to store data """ return os.path.normpath(os.path.join(self.project_dir, 'data', *args))
[ "def", "project_data_dir", "(", "self", ",", "*", "args", ")", "->", "str", ":", "return", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "self", ".", "project_dir", ",", "'data'", ",", "*", "args", ")", ")" ]
Directory where to store data
[ "Directory", "where", "to", "store", "data" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L128-L130
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.output_dir
def output_dir(self, *args) -> str: """ Directory where to store output """ return os.path.join(self.project_dir, 'output', *args)
python
def output_dir(self, *args) -> str: """ Directory where to store output """ return os.path.join(self.project_dir, 'output', *args)
[ "def", "output_dir", "(", "self", ",", "*", "args", ")", "->", "str", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "project_dir", ",", "'output'", ",", "*", "args", ")" ]
Directory where to store output
[ "Directory", "where", "to", "store", "output" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L132-L134
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.project_top_dir
def project_top_dir(self, *args) -> str: """ Project top-level directory """ return os.path.join(self.project_dir, *args)
python
def project_top_dir(self, *args) -> str: """ Project top-level directory """ return os.path.join(self.project_dir, *args)
[ "def", "project_top_dir", "(", "self", ",", "*", "args", ")", "->", "str", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "project_dir", ",", "*", "args", ")" ]
Project top-level directory
[ "Project", "top", "-", "level", "directory" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L136-L138
train
MillionIntegrals/vel
vel/internals/model_config.py
ModelConfig.provide_with_default
def provide_with_default(self, name, default=None): """ Return a dependency-injected instance """ return self.provider.instantiate_by_name_with_default(name, default_value=default)
python
def provide_with_default(self, name, default=None): """ Return a dependency-injected instance """ return self.provider.instantiate_by_name_with_default(name, default_value=default)
[ "def", "provide_with_default", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "return", "self", ".", "provider", ".", "instantiate_by_name_with_default", "(", "name", ",", "default_value", "=", "default", ")" ]
Return a dependency-injected instance
[ "Return", "a", "dependency", "-", "injected", "instance" ]
e0726e1f63742b728966ccae0c8b825ea0ba491a
https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/internals/model_config.py#L165-L167
train
douban/libmc
misc/runbench.py
benchmark_method
def benchmark_method(f): "decorator to turn f into a factory of benchmarks" @wraps(f) def inner(name, *args, **kwargs): return Benchmark(name, f, args, kwargs) return inner
python
def benchmark_method(f): "decorator to turn f into a factory of benchmarks" @wraps(f) def inner(name, *args, **kwargs): return Benchmark(name, f, args, kwargs) return inner
[ "def", "benchmark_method", "(", "f", ")", ":", "\"decorator to turn f into a factory of benchmarks\"", "@", "wraps", "(", "f", ")", "def", "inner", "(", "name", ",", "*", "args", ",", "**", "kwargs", ")", ":", "return", "Benchmark", "(", "name", ",", "f", ...
decorator to turn f into a factory of benchmarks
[ "decorator", "to", "turn", "f", "into", "a", "factory", "of", "benchmarks" ]
12e5528e55708d08003671c10267287ed77e4dc4
https://github.com/douban/libmc/blob/12e5528e55708d08003671c10267287ed77e4dc4/misc/runbench.py#L118-L123
train
douban/libmc
misc/runbench.py
bench
def bench(participants=participants, benchmarks=benchmarks, bench_time=BENCH_TIME): """Do you even lift?""" mcs = [p.factory() for p in participants] means = [[] for p in participants] stddevs = [[] for p in participants] # Have each lifter do one benchmark each last_fn = None fo...
python
def bench(participants=participants, benchmarks=benchmarks, bench_time=BENCH_TIME): """Do you even lift?""" mcs = [p.factory() for p in participants] means = [[] for p in participants] stddevs = [[] for p in participants] # Have each lifter do one benchmark each last_fn = None fo...
[ "def", "bench", "(", "participants", "=", "participants", ",", "benchmarks", "=", "benchmarks", ",", "bench_time", "=", "BENCH_TIME", ")", ":", "mcs", "=", "[", "p", ".", "factory", "(", ")", "for", "p", "in", "participants", "]", "means", "=", "[", "[...
Do you even lift?
[ "Do", "you", "even", "lift?" ]
12e5528e55708d08003671c10267287ed77e4dc4
https://github.com/douban/libmc/blob/12e5528e55708d08003671c10267287ed77e4dc4/misc/runbench.py#L266-L297
train
liampauling/betfair
betfairlightweight/resources/baseresource.py
BaseResource.strip_datetime
def strip_datetime(value): """ Converts value to datetime if string or int. """ if isinstance(value, basestring): try: return parse_datetime(value) except ValueError: return elif isinstance(value, integer_types): ...
python
def strip_datetime(value): """ Converts value to datetime if string or int. """ if isinstance(value, basestring): try: return parse_datetime(value) except ValueError: return elif isinstance(value, integer_types): ...
[ "def", "strip_datetime", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "basestring", ")", ":", "try", ":", "return", "parse_datetime", "(", "value", ")", "except", "ValueError", ":", "return", "elif", "isinstance", "(", "value", ",", "inte...
Converts value to datetime if string or int.
[ "Converts", "value", "to", "datetime", "if", "string", "or", "int", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/resources/baseresource.py#L26-L39
train
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.set_session_token
def set_session_token(self, session_token): """ Sets session token and new login time. :param str session_token: Session token from request. """ self.session_token = session_token self._login_time = datetime.datetime.now()
python
def set_session_token(self, session_token): """ Sets session token and new login time. :param str session_token: Session token from request. """ self.session_token = session_token self._login_time = datetime.datetime.now()
[ "def", "set_session_token", "(", "self", ",", "session_token", ")", ":", "self", ".", "session_token", "=", "session_token", "self", ".", "_login_time", "=", "datetime", ".", "datetime", ".", "now", "(", ")" ]
Sets session token and new login time. :param str session_token: Session token from request.
[ "Sets", "session", "token", "and", "new", "login", "time", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L78-L85
train
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.get_password
def get_password(self): """ If password is not provided will look in environment variables for username+'password'. """ if self.password is None: if os.environ.get(self.username+'password'): self.password = os.environ.get(self.username+'password') ...
python
def get_password(self): """ If password is not provided will look in environment variables for username+'password'. """ if self.password is None: if os.environ.get(self.username+'password'): self.password = os.environ.get(self.username+'password') ...
[ "def", "get_password", "(", "self", ")", ":", "if", "self", ".", "password", "is", "None", ":", "if", "os", ".", "environ", ".", "get", "(", "self", ".", "username", "+", "'password'", ")", ":", "self", ".", "password", "=", "os", ".", "environ", "...
If password is not provided will look in environment variables for username+'password'.
[ "If", "password", "is", "not", "provided", "will", "look", "in", "environment", "variables", "for", "username", "+", "password", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L87-L96
train
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.get_app_key
def get_app_key(self): """ If app_key is not provided will look in environment variables for username. """ if self.app_key is None: if os.environ.get(self.username): self.app_key = os.environ.get(self.username) else: raise A...
python
def get_app_key(self): """ If app_key is not provided will look in environment variables for username. """ if self.app_key is None: if os.environ.get(self.username): self.app_key = os.environ.get(self.username) else: raise A...
[ "def", "get_app_key", "(", "self", ")", ":", "if", "self", ".", "app_key", "is", "None", ":", "if", "os", ".", "environ", ".", "get", "(", "self", ".", "username", ")", ":", "self", ".", "app_key", "=", "os", ".", "environ", ".", "get", "(", "sel...
If app_key is not provided will look in environment variables for username.
[ "If", "app_key", "is", "not", "provided", "will", "look", "in", "environment", "variables", "for", "username", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L98-L107
train
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.session_expired
def session_expired(self): """ Returns True if login_time not set or seconds since login time is greater than 200 mins. """ if not self._login_time or (datetime.datetime.now()-self._login_time).total_seconds() > 12000: return True
python
def session_expired(self): """ Returns True if login_time not set or seconds since login time is greater than 200 mins. """ if not self._login_time or (datetime.datetime.now()-self._login_time).total_seconds() > 12000: return True
[ "def", "session_expired", "(", "self", ")", ":", "if", "not", "self", ".", "_login_time", "or", "(", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "self", ".", "_login_time", ")", ".", "total_seconds", "(", ")", ">", "12000", ":", "return", ...
Returns True if login_time not set or seconds since login time is greater than 200 mins.
[ "Returns", "True", "if", "login_time", "not", "set", "or", "seconds", "since", "login", "time", "is", "greater", "than", "200", "mins", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L117-L123
train
liampauling/betfair
betfairlightweight/utils.py
check_status_code
def check_status_code(response, codes=None): """ Checks response.status_code is in codes. :param requests.request response: Requests response :param list codes: List of accepted codes or callable :raises: StatusCodeError if code invalid """ codes = codes or [200] if response.status_code...
python
def check_status_code(response, codes=None): """ Checks response.status_code is in codes. :param requests.request response: Requests response :param list codes: List of accepted codes or callable :raises: StatusCodeError if code invalid """ codes = codes or [200] if response.status_code...
[ "def", "check_status_code", "(", "response", ",", "codes", "=", "None", ")", ":", "codes", "=", "codes", "or", "[", "200", "]", "if", "response", ".", "status_code", "not", "in", "codes", ":", "raise", "StatusCodeError", "(", "response", ".", "status_code"...
Checks response.status_code is in codes. :param requests.request response: Requests response :param list codes: List of accepted codes or callable :raises: StatusCodeError if code invalid
[ "Checks", "response", ".", "status_code", "is", "in", "codes", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/utils.py#L7-L17
train
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_runner_book
def list_runner_book(self, market_id, selection_id, handicap=None, price_projection=None, order_projection=None, match_projection=None, include_overall_position=None, partition_matched_by_strategy_ref=None, customer_strategy_refs=None, currency_code=None, matched_since=...
python
def list_runner_book(self, market_id, selection_id, handicap=None, price_projection=None, order_projection=None, match_projection=None, include_overall_position=None, partition_matched_by_strategy_ref=None, customer_strategy_refs=None, currency_code=None, matched_since=...
[ "def", "list_runner_book", "(", "self", ",", "market_id", ",", "selection_id", ",", "handicap", "=", "None", ",", "price_projection", "=", "None", ",", "order_projection", "=", "None", ",", "match_projection", "=", "None", ",", "include_overall_position", "=", "...
Returns a list of dynamic data about a market and a specified runner. Dynamic data includes prices, the status of the market, the status of selections, the traded volume, and the status of any orders you have placed in the market :param unicode market_id: The unique id for the market ...
[ "Returns", "a", "list", "of", "dynamic", "data", "about", "a", "market", "and", "a", "specified", "runner", ".", "Dynamic", "data", "includes", "prices", "the", "status", "of", "the", "market", "the", "status", "of", "selections", "the", "traded", "volume", ...
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L193-L226
train
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_current_orders
def list_current_orders(self, bet_ids=None, market_ids=None, order_projection=None, customer_order_refs=None, customer_strategy_refs=None, date_range=time_range(), order_by=None, sort_dir=None, from_record=None, record_count=None, session=None, lightweight=None): ...
python
def list_current_orders(self, bet_ids=None, market_ids=None, order_projection=None, customer_order_refs=None, customer_strategy_refs=None, date_range=time_range(), order_by=None, sort_dir=None, from_record=None, record_count=None, session=None, lightweight=None): ...
[ "def", "list_current_orders", "(", "self", ",", "bet_ids", "=", "None", ",", "market_ids", "=", "None", ",", "order_projection", "=", "None", ",", "customer_order_refs", "=", "None", ",", "customer_strategy_refs", "=", "None", ",", "date_range", "=", "time_range...
Returns a list of your current orders. :param list bet_ids: If you ask for orders, restricts the results to orders with the specified bet IDs :param list market_ids: One or more market ids :param str order_projection: Optionally restricts the results to the specified order status :param...
[ "Returns", "a", "list", "of", "your", "current", "orders", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L228-L255
train
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_cleared_orders
def list_cleared_orders(self, bet_status='SETTLED', event_type_ids=None, event_ids=None, market_ids=None, runner_ids=None, bet_ids=None, customer_order_refs=None, customer_strategy_refs=None, side=None, settled_date_range=time_range(), group_by=None, include_item_...
python
def list_cleared_orders(self, bet_status='SETTLED', event_type_ids=None, event_ids=None, market_ids=None, runner_ids=None, bet_ids=None, customer_order_refs=None, customer_strategy_refs=None, side=None, settled_date_range=time_range(), group_by=None, include_item_...
[ "def", "list_cleared_orders", "(", "self", ",", "bet_status", "=", "'SETTLED'", ",", "event_type_ids", "=", "None", ",", "event_ids", "=", "None", ",", "market_ids", "=", "None", ",", "runner_ids", "=", "None", ",", "bet_ids", "=", "None", ",", "customer_ord...
Returns a list of settled bets based on the bet status, ordered by settled date. :param str bet_status: Restricts the results to the specified status :param list event_type_ids: Optionally restricts the results to the specified Event Type IDs :param list event_ids: Optionally restricts ...
[ "Returns", "a", "list", "of", "settled", "bets", "based", "on", "the", "bet", "status", "ordered", "by", "settled", "date", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L257-L289
train
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_market_profit_and_loss
def list_market_profit_and_loss(self, market_ids, include_settled_bets=None, include_bsp_bets=None, net_of_commission=None, session=None, lightweight=None): """ Retrieve profit and loss for a given list of OPEN markets. :param list market_ids: List of markets...
python
def list_market_profit_and_loss(self, market_ids, include_settled_bets=None, include_bsp_bets=None, net_of_commission=None, session=None, lightweight=None): """ Retrieve profit and loss for a given list of OPEN markets. :param list market_ids: List of markets...
[ "def", "list_market_profit_and_loss", "(", "self", ",", "market_ids", ",", "include_settled_bets", "=", "None", ",", "include_bsp_bets", "=", "None", ",", "net_of_commission", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", ...
Retrieve profit and loss for a given list of OPEN markets. :param list market_ids: List of markets to calculate profit and loss :param bool include_settled_bets: Option to include settled bets (partially settled markets only) :param bool include_bsp_bets: Option to include BSP bets :par...
[ "Retrieve", "profit", "and", "loss", "for", "a", "given", "list", "of", "OPEN", "markets", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L291-L309
train
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.place_orders
def place_orders(self, market_id, instructions, customer_ref=None, market_version=None, customer_strategy_ref=None, async_=None, session=None, lightweight=None): """ Place new orders into market. :param str market_id: The market id these orders are to be placed on :...
python
def place_orders(self, market_id, instructions, customer_ref=None, market_version=None, customer_strategy_ref=None, async_=None, session=None, lightweight=None): """ Place new orders into market. :param str market_id: The market id these orders are to be placed on :...
[ "def", "place_orders", "(", "self", ",", "market_id", ",", "instructions", ",", "customer_ref", "=", "None", ",", "market_version", "=", "None", ",", "customer_strategy_ref", "=", "None", ",", "async_", "=", "None", ",", "session", "=", "None", ",", "lightwe...
Place new orders into market. :param str market_id: The market id these orders are to be placed on :param list instructions: The number of place instructions :param str customer_ref: Optional parameter allowing the client to pass a unique string (up to 32 chars) that is used to de-dupe ...
[ "Place", "new", "orders", "into", "market", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L311-L334
train
liampauling/betfair
betfairlightweight/streaming/cache.py
MarketBookCache.serialise
def serialise(self): """Creates standard market book json response, will error if EX_MARKET_DEF not incl. """ return { 'marketId': self.market_id, 'totalAvailable': None, 'isMarketDataDelayed': None, 'lastMatchTime': None, 'betD...
python
def serialise(self): """Creates standard market book json response, will error if EX_MARKET_DEF not incl. """ return { 'marketId': self.market_id, 'totalAvailable': None, 'isMarketDataDelayed': None, 'lastMatchTime': None, 'betD...
[ "def", "serialise", "(", "self", ")", ":", "return", "{", "'marketId'", ":", "self", ".", "market_id", ",", "'totalAvailable'", ":", "None", ",", "'isMarketDataDelayed'", ":", "None", ",", "'lastMatchTime'", ":", "None", ",", "'betDelay'", ":", "self", ".", ...
Creates standard market book json response, will error if EX_MARKET_DEF not incl.
[ "Creates", "standard", "market", "book", "json", "response", "will", "error", "if", "EX_MARKET_DEF", "not", "incl", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/cache.py#L223-L253
train
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_race_details
def list_race_details(self, meeting_ids=None, race_ids=None, session=None, lightweight=None): """ Search for races to get their details. :param dict meeting_ids: Optionally restricts the results to the specified meeting IDs. The unique Id for the meeting equivalent to the eventId for th...
python
def list_race_details(self, meeting_ids=None, race_ids=None, session=None, lightweight=None): """ Search for races to get their details. :param dict meeting_ids: Optionally restricts the results to the specified meeting IDs. The unique Id for the meeting equivalent to the eventId for th...
[ "def", "list_race_details", "(", "self", ",", "meeting_ids", "=", "None", ",", "race_ids", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", ...
Search for races to get their details. :param dict meeting_ids: Optionally restricts the results to the specified meeting IDs. The unique Id for the meeting equivalent to the eventId for that specific race as returned by listEvents :param str race_ids: Optionally restricts the results t...
[ "Search", "for", "races", "to", "get", "their", "details", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L13-L30
train
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_available_events
def list_available_events(self, event_ids=None, event_type_ids=None, event_status=None, session=None, lightweight=None): """ Search for events that have live score data available. :param list event_ids: Optionally restricts the results to the specified event IDs ...
python
def list_available_events(self, event_ids=None, event_type_ids=None, event_status=None, session=None, lightweight=None): """ Search for events that have live score data available. :param list event_ids: Optionally restricts the results to the specified event IDs ...
[ "def", "list_available_events", "(", "self", ",", "event_ids", "=", "None", ",", "event_type_ids", "=", "None", ",", "event_status", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "l...
Search for events that have live score data available. :param list event_ids: Optionally restricts the results to the specified event IDs :param list event_type_ids: Optionally restricts the results to the specified event type IDs :param list event_status: Optionally restricts the results to th...
[ "Search", "for", "events", "that", "have", "live", "score", "data", "available", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L34-L50
train
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_scores
def list_scores(self, update_keys, session=None, lightweight=None): """ Returns a list of current scores for the given events. :param list update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'las...
python
def list_scores(self, update_keys, session=None, lightweight=None): """ Returns a list of current scores for the given events. :param list update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'las...
[ "def", "list_scores", "(", "self", ",", "update_keys", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", "'%s%s'", "%", "(", "self", ".", "URI", ",", "'...
Returns a list of current scores for the given events. :param list update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastUpdateSequenceProcessed': 2}] :param requests.session session: Requests session...
[ "Returns", "a", "list", "of", "current", "scores", "for", "the", "given", "events", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L52-L66
train
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_incidents
def list_incidents(self, update_keys, session=None, lightweight=None): """ Returns a list of incidents for the given events. :param dict update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastU...
python
def list_incidents(self, update_keys, session=None, lightweight=None): """ Returns a list of incidents for the given events. :param dict update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastU...
[ "def", "list_incidents", "(", "self", ",", "update_keys", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", "'%s%s'", "%", "(", "self", ".", "URI", ",", ...
Returns a list of incidents for the given events. :param dict update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastUpdateSequenceProcessed': 2}] :param requests.session session: Requests session obje...
[ "Returns", "a", "list", "of", "incidents", "for", "the", "given", "events", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L68-L82
train
liampauling/betfair
betfairlightweight/endpoints/inplayservice.py
InPlayService.get_event_timeline
def get_event_timeline(self, event_id, session=None, lightweight=None): """ Returns event timeline for event id provided. :param int event_id: Event id to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a reso...
python
def get_event_timeline(self, event_id, session=None, lightweight=None): """ Returns event timeline for event id provided. :param int event_id: Event id to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a reso...
[ "def", "get_event_timeline", "(", "self", ",", "event_id", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "url", ",", "'eventTimeline'", ")", "params", "=", "{", "'eventId'", ":", "e...
Returns event timeline for event id provided. :param int event_id: Event id to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource :rtype: resources.EventTimeline
[ "Returns", "event", "timeline", "for", "event", "id", "provided", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/inplayservice.py#L18-L36
train
liampauling/betfair
betfairlightweight/endpoints/inplayservice.py
InPlayService.get_event_timelines
def get_event_timelines(self, event_ids, session=None, lightweight=None): """ Returns a list of event timelines based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightwei...
python
def get_event_timelines(self, event_ids, session=None, lightweight=None): """ Returns a list of event timelines based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightwei...
[ "def", "get_event_timelines", "(", "self", ",", "event_ids", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "url", ",", "'eventTimelines'", ")", "params", "=", "{", "'eventIds'", ":", ...
Returns a list of event timelines based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource :rtype: list[resources.EventTimeline]
[ "Returns", "a", "list", "of", "event", "timelines", "based", "on", "event", "id", "s", "supplied", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/inplayservice.py#L38-L57
train
liampauling/betfair
betfairlightweight/endpoints/inplayservice.py
InPlayService.get_scores
def get_scores(self, event_ids, session=None, lightweight=None): """ Returns a list of scores based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will ...
python
def get_scores(self, event_ids, session=None, lightweight=None): """ Returns a list of scores based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will ...
[ "def", "get_scores", "(", "self", ",", "event_ids", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "url", ",", "'scores'", ")", "params", "=", "{", "'eventIds'", ":", "','", ".", ...
Returns a list of scores based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource :rtype: list[resources.Scores]
[ "Returns", "a", "list", "of", "scores", "based", "on", "event", "id", "s", "supplied", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/inplayservice.py#L59-L78
train
liampauling/betfair
betfairlightweight/endpoints/streaming.py
Streaming.create_stream
def create_stream(self, unique_id=0, listener=None, timeout=11, buffer_size=1024, description='BetfairSocket', host=None): """ Creates BetfairStream. :param dict unique_id: Id used to start unique id's of the stream (+1 before every request) :param resources.Listen...
python
def create_stream(self, unique_id=0, listener=None, timeout=11, buffer_size=1024, description='BetfairSocket', host=None): """ Creates BetfairStream. :param dict unique_id: Id used to start unique id's of the stream (+1 before every request) :param resources.Listen...
[ "def", "create_stream", "(", "self", ",", "unique_id", "=", "0", ",", "listener", "=", "None", ",", "timeout", "=", "11", ",", "buffer_size", "=", "1024", ",", "description", "=", "'BetfairSocket'", ",", "host", "=", "None", ")", ":", "listener", "=", ...
Creates BetfairStream. :param dict unique_id: Id used to start unique id's of the stream (+1 before every request) :param resources.Listener listener: Listener class to use :param float timeout: Socket timeout :param int buffer_size: Socket buffer size :param str description: B...
[ "Creates", "BetfairStream", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/streaming.py#L19-L43
train
liampauling/betfair
betfairlightweight/endpoints/historic.py
Historic.get_my_data
def get_my_data(self, session=None): """ Returns a list of data descriptions for data which has been purchased by the signed in user. :param requests.session session: Requests session object :rtype: dict """ params = clean_locals(locals()) method = 'GetMyData' ...
python
def get_my_data(self, session=None): """ Returns a list of data descriptions for data which has been purchased by the signed in user. :param requests.session session: Requests session object :rtype: dict """ params = clean_locals(locals()) method = 'GetMyData' ...
[ "def", "get_my_data", "(", "self", ",", "session", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", "'GetMyData'", "(", "response", ",", "elapsed_time", ")", "=", "self", ".", "request", "(", "method", ...
Returns a list of data descriptions for data which has been purchased by the signed in user. :param requests.session session: Requests session object :rtype: dict
[ "Returns", "a", "list", "of", "data", "descriptions", "for", "data", "which", "has", "been", "purchased", "by", "the", "signed", "in", "user", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/historic.py#L22-L33
train
liampauling/betfair
betfairlightweight/endpoints/historic.py
Historic.get_data_size
def get_data_size(self, sport, plan, from_day, from_month, from_year, to_day, to_month, to_year, event_id=None, event_name=None, market_types_collection=None, countries_collection=None, file_type_collection=None, session=None): """ Returns a dictionary of file...
python
def get_data_size(self, sport, plan, from_day, from_month, from_year, to_day, to_month, to_year, event_id=None, event_name=None, market_types_collection=None, countries_collection=None, file_type_collection=None, session=None): """ Returns a dictionary of file...
[ "def", "get_data_size", "(", "self", ",", "sport", ",", "plan", ",", "from_day", ",", "from_month", ",", "from_year", ",", "to_day", ",", "to_month", ",", "to_year", ",", "event_id", "=", "None", ",", "event_name", "=", "None", ",", "market_types_collection"...
Returns a dictionary of file count and combines size files. :param sport: sport to filter data for. :param plan: plan type to filter for, Basic Plan, Advanced Plan or Pro Plan. :param from_day: day of month to start data from. :param from_month: month to start data from. :param ...
[ "Returns", "a", "dictionary", "of", "file", "count", "and", "combines", "size", "files", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/historic.py#L63-L89
train
liampauling/betfair
betfairlightweight/endpoints/racecard.py
RaceCard.login
def login(self, session=None): """ Parses app key from betfair exchange site. :param requests.session session: Requests session object """ session = session or self.client.session try: response = session.get(self.login_url) except ConnectionError: ...
python
def login(self, session=None): """ Parses app key from betfair exchange site. :param requests.session session: Requests session object """ session = session or self.client.session try: response = session.get(self.login_url) except ConnectionError: ...
[ "def", "login", "(", "self", ",", "session", "=", "None", ")", ":", "session", "=", "session", "or", "self", ".", "client", ".", "session", "try", ":", "response", "=", "session", ".", "get", "(", "self", ".", "login_url", ")", "except", "ConnectionErr...
Parses app key from betfair exchange site. :param requests.session session: Requests session object
[ "Parses", "app", "key", "from", "betfair", "exchange", "site", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/racecard.py#L22-L39
train
liampauling/betfair
betfairlightweight/endpoints/racecard.py
RaceCard.get_race_card
def get_race_card(self, market_ids, data_entries=None, session=None, lightweight=None): """ Returns a list of race cards based on market ids provided. :param list market_ids: The filter to select desired markets :param str data_entries: Data to be returned :param requests.sessio...
python
def get_race_card(self, market_ids, data_entries=None, session=None, lightweight=None): """ Returns a list of race cards based on market ids provided. :param list market_ids: The filter to select desired markets :param str data_entries: Data to be returned :param requests.sessio...
[ "def", "get_race_card", "(", "self", ",", "market_ids", ",", "data_entries", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "if", "not", "self", ".", "app_key", ":", "raise", "RaceCardError", "(", "\"You need to login be...
Returns a list of race cards based on market ids provided. :param list market_ids: The filter to select desired markets :param str data_entries: Data to be returned :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource ...
[ "Returns", "a", "list", "of", "race", "cards", "based", "on", "market", "ids", "provided", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/racecard.py#L41-L57
train
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener.on_data
def on_data(self, raw_data): """Called when raw data is received from connection. Override this method if you wish to manually handle the stream data :param raw_data: Received raw data :return: Return False to stop stream and close connection """ try: ...
python
def on_data(self, raw_data): """Called when raw data is received from connection. Override this method if you wish to manually handle the stream data :param raw_data: Received raw data :return: Return False to stop stream and close connection """ try: ...
[ "def", "on_data", "(", "self", ",", "raw_data", ")", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "raw_data", ")", "except", "ValueError", ":", "logger", ".", "error", "(", "'value error: %s'", "%", "raw_data", ")", "return", "unique_id", "="...
Called when raw data is received from connection. Override this method if you wish to manually handle the stream data :param raw_data: Received raw data :return: Return False to stop stream and close connection
[ "Called", "when", "raw", "data", "is", "received", "from", "connection", ".", "Override", "this", "method", "if", "you", "wish", "to", "manually", "handle", "the", "stream", "data" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L85-L115
train
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener._on_connection
def _on_connection(self, data, unique_id): """Called on collection operation :param data: Received data """ if unique_id is None: unique_id = self.stream_unique_id self.connection_id = data.get('connectionId') logger.info('[Connect: %s]: connection_id: %s' % ...
python
def _on_connection(self, data, unique_id): """Called on collection operation :param data: Received data """ if unique_id is None: unique_id = self.stream_unique_id self.connection_id = data.get('connectionId') logger.info('[Connect: %s]: connection_id: %s' % ...
[ "def", "_on_connection", "(", "self", ",", "data", ",", "unique_id", ")", ":", "if", "unique_id", "is", "None", ":", "unique_id", "=", "self", ".", "stream_unique_id", "self", ".", "connection_id", "=", "data", ".", "get", "(", "'connectionId'", ")", "logg...
Called on collection operation :param data: Received data
[ "Called", "on", "collection", "operation" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L117-L125
train
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener._on_status
def _on_status(data, unique_id): """Called on status operation :param data: Received data """ status_code = data.get('statusCode') logger.info('[Subscription: %s]: %s' % (unique_id, status_code))
python
def _on_status(data, unique_id): """Called on status operation :param data: Received data """ status_code = data.get('statusCode') logger.info('[Subscription: %s]: %s' % (unique_id, status_code))
[ "def", "_on_status", "(", "data", ",", "unique_id", ")", ":", "status_code", "=", "data", ".", "get", "(", "'statusCode'", ")", "logger", ".", "info", "(", "'[Subscription: %s]: %s'", "%", "(", "unique_id", ",", "status_code", ")", ")" ]
Called on status operation :param data: Received data
[ "Called", "on", "status", "operation" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L128-L134
train
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener._error_handler
def _error_handler(data, unique_id): """Called when data first received :param data: Received data :param unique_id: Unique id :return: True if error present """ if data.get('statusCode') == 'FAILURE': logger.error('[Subscription: %s] %s: %s' % (unique_id, da...
python
def _error_handler(data, unique_id): """Called when data first received :param data: Received data :param unique_id: Unique id :return: True if error present """ if data.get('statusCode') == 'FAILURE': logger.error('[Subscription: %s] %s: %s' % (unique_id, da...
[ "def", "_error_handler", "(", "data", ",", "unique_id", ")", ":", "if", "data", ".", "get", "(", "'statusCode'", ")", "==", "'FAILURE'", ":", "logger", ".", "error", "(", "'[Subscription: %s] %s: %s'", "%", "(", "unique_id", ",", "data", ".", "get", "(", ...
Called when data first received :param data: Received data :param unique_id: Unique id :return: True if error present
[ "Called", "when", "data", "first", "received" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L157-L171
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.stop
def stop(self): """Stops read loop and closes socket if it has been created. """ self._running = False if self._socket is None: return try: self._socket.shutdown(socket.SHUT_RDWR) self._socket.close() except socket.error: p...
python
def stop(self): """Stops read loop and closes socket if it has been created. """ self._running = False if self._socket is None: return try: self._socket.shutdown(socket.SHUT_RDWR) self._socket.close() except socket.error: p...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_running", "=", "False", "if", "self", ".", "_socket", "is", "None", ":", "return", "try", ":", "self", ".", "_socket", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "self", ".", "_socket",...
Stops read loop and closes socket if it has been created.
[ "Stops", "read", "loop", "and", "closes", "socket", "if", "it", "has", "been", "created", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L62-L74
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.authenticate
def authenticate(self): """Authentication request. """ unique_id = self.new_unique_id() message = { 'op': 'authentication', 'id': unique_id, 'appKey': self.app_key, 'session': self.session_token, } self._send(message) ...
python
def authenticate(self): """Authentication request. """ unique_id = self.new_unique_id() message = { 'op': 'authentication', 'id': unique_id, 'appKey': self.app_key, 'session': self.session_token, } self._send(message) ...
[ "def", "authenticate", "(", "self", ")", ":", "unique_id", "=", "self", ".", "new_unique_id", "(", ")", "message", "=", "{", "'op'", ":", "'authentication'", ",", "'id'", ":", "unique_id", ",", "'appKey'", ":", "self", ".", "app_key", ",", "'session'", "...
Authentication request.
[ "Authentication", "request", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L76-L87
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.heartbeat
def heartbeat(self): """Heartbeat request to keep session alive. """ unique_id = self.new_unique_id() message = { 'op': 'heartbeat', 'id': unique_id, } self._send(message) return unique_id
python
def heartbeat(self): """Heartbeat request to keep session alive. """ unique_id = self.new_unique_id() message = { 'op': 'heartbeat', 'id': unique_id, } self._send(message) return unique_id
[ "def", "heartbeat", "(", "self", ")", ":", "unique_id", "=", "self", ".", "new_unique_id", "(", ")", "message", "=", "{", "'op'", ":", "'heartbeat'", ",", "'id'", ":", "unique_id", ",", "}", "self", ".", "_send", "(", "message", ")", "return", "unique_...
Heartbeat request to keep session alive.
[ "Heartbeat", "request", "to", "keep", "session", "alive", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L89-L98
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.subscribe_to_markets
def subscribe_to_markets(self, market_filter, market_data_filter, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Market subscription request. :param dict market_filter: Market filter :param dict market_data_f...
python
def subscribe_to_markets(self, market_filter, market_data_filter, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Market subscription request. :param dict market_filter: Market filter :param dict market_data_f...
[ "def", "subscribe_to_markets", "(", "self", ",", "market_filter", ",", "market_data_filter", ",", "initial_clk", "=", "None", ",", "clk", "=", "None", ",", "conflate_ms", "=", "None", ",", "heartbeat_ms", "=", "None", ",", "segmentation_enabled", "=", "True", ...
Market subscription request. :param dict market_filter: Market filter :param dict market_data_filter: Market data filter :param str initial_clk: Sequence token for reconnect :param str clk: Sequence token for reconnect :param int conflate_ms: conflation rate (bounds are 0 to 120...
[ "Market", "subscription", "request", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L100-L132
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.subscribe_to_orders
def subscribe_to_orders(self, order_filter=None, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Order subscription request. :param dict order_filter: Order filter to be applied :param str initial_clk: Sequence...
python
def subscribe_to_orders(self, order_filter=None, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Order subscription request. :param dict order_filter: Order filter to be applied :param str initial_clk: Sequence...
[ "def", "subscribe_to_orders", "(", "self", ",", "order_filter", "=", "None", ",", "initial_clk", "=", "None", ",", "clk", "=", "None", ",", "conflate_ms", "=", "None", ",", "heartbeat_ms", "=", "None", ",", "segmentation_enabled", "=", "True", ")", ":", "u...
Order subscription request. :param dict order_filter: Order filter to be applied :param str initial_clk: Sequence token for reconnect :param str clk: Sequence token for reconnect :param int conflate_ms: conflation rate (bounds are 0 to 120000) :param int heartbeat_ms: heartbeat ...
[ "Order", "subscription", "request", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L134-L164
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._create_socket
def _create_socket(self): """Creates ssl socket, connects to stream api and sets timeout. """ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = ssl.wrap_socket(s) s.connect((self.host, self.__port)) s.settimeout(self.timeout) return s
python
def _create_socket(self): """Creates ssl socket, connects to stream api and sets timeout. """ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = ssl.wrap_socket(s) s.connect((self.host, self.__port)) s.settimeout(self.timeout) return s
[ "def", "_create_socket", "(", "self", ")", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "s", "=", "ssl", ".", "wrap_socket", "(", "s", ")", "s", ".", "connect", "(", "(", "self", "."...
Creates ssl socket, connects to stream api and sets timeout.
[ "Creates", "ssl", "socket", "connects", "to", "stream", "api", "and", "sets", "timeout", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L176-L184
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._read_loop
def _read_loop(self): """Read loop, splits by CRLF and pushes received data to _data. """ while self._running: received_data_raw = self._receive_all() if self._running: self.receive_count += 1 self.datetime_last_received = datetime....
python
def _read_loop(self): """Read loop, splits by CRLF and pushes received data to _data. """ while self._running: received_data_raw = self._receive_all() if self._running: self.receive_count += 1 self.datetime_last_received = datetime....
[ "def", "_read_loop", "(", "self", ")", ":", "while", "self", ".", "_running", ":", "received_data_raw", "=", "self", ".", "_receive_all", "(", ")", "if", "self", ".", "_running", ":", "self", ".", "receive_count", "+=", "1", "self", ".", "datetime_last_rec...
Read loop, splits by CRLF and pushes received data to _data.
[ "Read", "loop", "splits", "by", "CRLF", "and", "pushes", "received", "data", "to", "_data", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L186-L198
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._receive_all
def _receive_all(self): """Whilst socket is running receives data from socket, till CRLF is detected. """ (data, part) = ('', '') if is_py3: crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding) else: crlf_bytes = self.__CRLF while sel...
python
def _receive_all(self): """Whilst socket is running receives data from socket, till CRLF is detected. """ (data, part) = ('', '') if is_py3: crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding) else: crlf_bytes = self.__CRLF while sel...
[ "def", "_receive_all", "(", "self", ")", ":", "(", "data", ",", "part", ")", "=", "(", "''", ",", "''", ")", "if", "is_py3", ":", "crlf_bytes", "=", "bytes", "(", "self", ".", "__CRLF", ",", "encoding", "=", "self", ".", "__encoding", ")", "else", ...
Whilst socket is running receives data from socket, till CRLF is detected.
[ "Whilst", "socket", "is", "running", "receives", "data", "from", "socket", "till", "CRLF", "is", "detected", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L200-L226
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._data
def _data(self, received_data): """Sends data to listener, if False is returned; socket is closed. :param received_data: Decoded data received from socket. """ if self.listener.on_data(received_data) is False: self.stop() raise ListenerError(self.listener...
python
def _data(self, received_data): """Sends data to listener, if False is returned; socket is closed. :param received_data: Decoded data received from socket. """ if self.listener.on_data(received_data) is False: self.stop() raise ListenerError(self.listener...
[ "def", "_data", "(", "self", ",", "received_data", ")", ":", "if", "self", ".", "listener", ".", "on_data", "(", "received_data", ")", "is", "False", ":", "self", ".", "stop", "(", ")", "raise", "ListenerError", "(", "self", ".", "listener", ".", "conn...
Sends data to listener, if False is returned; socket is closed. :param received_data: Decoded data received from socket.
[ "Sends", "data", "to", "listener", "if", "False", "is", "returned", ";", "socket", "is", "closed", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L228-L236
train
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._send
def _send(self, message): """If not running connects socket and authenticates. Adds CRLF and sends message to Betfair. :param message: Data to be sent to Betfair. """ if not self._running: self._connect() self.authenticate() message_dumped...
python
def _send(self, message): """If not running connects socket and authenticates. Adds CRLF and sends message to Betfair. :param message: Data to be sent to Betfair. """ if not self._running: self._connect() self.authenticate() message_dumped...
[ "def", "_send", "(", "self", ",", "message", ")", ":", "if", "not", "self", ".", "_running", ":", "self", ".", "_connect", "(", ")", "self", ".", "authenticate", "(", ")", "message_dumped", "=", "json", ".", "dumps", "(", "message", ")", "+", "self",...
If not running connects socket and authenticates. Adds CRLF and sends message to Betfair. :param message: Data to be sent to Betfair.
[ "If", "not", "running", "connects", "socket", "and", "authenticates", ".", "Adds", "CRLF", "and", "sends", "message", "to", "Betfair", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L238-L253
train
dmbee/seglearn
seglearn/pipe.py
Pype.fit_transform
def fit_transform(self, X, y=None, **fit_params): """ Fit the model and transform with the final estimator Fits all the transforms one after the other and transforms the data, then uses fit_transform on transformed data with the final estimator. Parameters ------...
python
def fit_transform(self, X, y=None, **fit_params): """ Fit the model and transform with the final estimator Fits all the transforms one after the other and transforms the data, then uses fit_transform on transformed data with the final estimator. Parameters ------...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "**", "fit_params", ")", ":", "Xt", ",", "yt", ",", "fit_params", "=", "self", ".", "_fit", "(", "X", ",", "y", ",", "**", "fit_params", ")", "if", "isinstance", "(", "sel...
Fit the model and transform with the final estimator Fits all the transforms one after the other and transforms the data, then uses fit_transform on transformed data with the final estimator. Parameters ---------- X : iterable Training data. Must fulfill inpu...
[ "Fit", "the", "model", "and", "transform", "with", "the", "final", "estimator", "Fits", "all", "the", "transforms", "one", "after", "the", "other", "and", "transforms", "the", "data", "then", "uses", "fit_transform", "on", "transformed", "data", "with", "the",...
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L173-L214
train
dmbee/seglearn
seglearn/pipe.py
Pype.predict
def predict(self, X): """ Apply transforms to the data, and predict with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- yp ...
python
def predict(self, X): """ Apply transforms to the data, and predict with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- yp ...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "predict", "(", "Xt", ")" ]
Apply transforms to the data, and predict with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- yp : array-like Predicted transfo...
[ "Apply", "transforms", "to", "the", "data", "and", "predict", "with", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L216-L232
train
dmbee/seglearn
seglearn/pipe.py
Pype.transform_predict
def transform_predict(self, X, y): """ Apply transforms to the data, and predict with the final estimator. Unlike predict, this also returns the transformed target Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first...
python
def transform_predict(self, X, y): """ Apply transforms to the data, and predict with the final estimator. Unlike predict, this also returns the transformed target Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first...
[ "def", "transform_predict", "(", "self", ",", "X", ",", "y", ")", ":", "Xt", ",", "yt", ",", "_", "=", "self", ".", "_transform", "(", "X", ",", "y", ")", "yp", "=", "self", ".", "_final_estimator", ".", "predict", "(", "Xt", ")", "return", "yt",...
Apply transforms to the data, and predict with the final estimator. Unlike predict, this also returns the transformed target Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : array-li...
[ "Apply", "transforms", "to", "the", "data", "and", "predict", "with", "the", "final", "estimator", ".", "Unlike", "predict", "this", "also", "returns", "the", "transformed", "target" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L234-L256
train
dmbee/seglearn
seglearn/pipe.py
Pype.score
def score(self, X, y=None, sample_weight=None): """ Apply transforms, and score with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : iterable, default=No...
python
def score(self, X, y=None, sample_weight=None): """ Apply transforms, and score with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : iterable, default=No...
[ "def", "score", "(", "self", ",", "X", ",", "y", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "Xt", ",", "yt", ",", "swt", "=", "self", ".", "_transform", "(", "X", ",", "y", ",", "sample_weight", ")", "self", ".", "N_test", "=", "...
Apply transforms, and score with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : iterable, default=None Targets used for scoring. Must fulfill label requirem...
[ "Apply", "transforms", "and", "score", "with", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L258-L290
train
dmbee/seglearn
seglearn/pipe.py
Pype.predict_proba
def predict_proba(self, X): """ Apply transforms, and predict_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_pro...
python
def predict_proba(self, X): """ Apply transforms, and predict_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_pro...
[ "def", "predict_proba", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "predict_proba", "(", "Xt", ")" ]
Apply transforms, and predict_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_proba : array-like, shape = [n_samples, n_classes] ...
[ "Apply", "transforms", "and", "predict_proba", "of", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L292-L308
train
dmbee/seglearn
seglearn/pipe.py
Pype.decision_function
def decision_function(self, X): """ Apply transforms, and decision_function of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- ...
python
def decision_function(self, X): """ Apply transforms, and decision_function of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- ...
[ "def", "decision_function", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "decision_function", "(", "Xt", ")" ]
Apply transforms, and decision_function of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_score : array-like, shape = [n_samples, n_class...
[ "Apply", "transforms", "and", "decision_function", "of", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L310-L325
train