repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
ClassSelector.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, Instances): inst = None data = self.input.payload elif isinstance(self.input.payload, Instance): inst = self.input.payload data = inst.dataset index = str(self.resolve_option("index")) unset = bool(self.resolve_option("unset")) if unset: data.no_class() else: if index == "first": data.class_is_first() elif index == "last": data.class_is_last() else: data.class_index = int(index) - 1 if inst is None: self._output.append(Token(data)) else: self._output.append(Token(inst)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, Instances): inst = None data = self.input.payload elif isinstance(self.input.payload, Instance): inst = self.input.payload data = inst.dataset index = str(self.resolve_option("index")) unset = bool(self.resolve_option("unset")) if unset: data.no_class() else: if index == "first": data.class_is_first() elif index == "last": data.class_is_last() else: data.class_index = int(index) - 1 if inst is None: self._output.append(Token(data)) else: self._output.append(Token(inst)) return None
[ "def", "do_execute", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "input", ".", "payload", ",", "Instances", ")", ":", "inst", "=", "None", "data", "=", "self", ".", "input", ".", "payload", "elif", "isinstance", "(", "self", ".", "input", ".", "payload", ",", "Instance", ")", ":", "inst", "=", "self", ".", "input", ".", "payload", "data", "=", "inst", ".", "dataset", "index", "=", "str", "(", "self", ".", "resolve_option", "(", "\"index\"", ")", ")", "unset", "=", "bool", "(", "self", ".", "resolve_option", "(", "\"unset\"", ")", ")", "if", "unset", ":", "data", ".", "no_class", "(", ")", "else", ":", "if", "index", "==", "\"first\"", ":", "data", ".", "class_is_first", "(", ")", "elif", "index", "==", "\"last\"", ":", "data", ".", "class_is_last", "(", ")", "else", ":", "data", ".", "class_index", "=", "int", "(", "index", ")", "-", "1", "if", "inst", "is", "None", ":", "self", ".", "_output", ".", "append", "(", "Token", "(", "data", ")", ")", "else", ":", "self", ".", "_output", ".", "append", "(", "Token", "(", "inst", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L687-L718
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Train.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Train, self).fix_config(options) opt = "setup" if opt not in options: options[opt] = Classifier(classname="weka.classifiers.rules.ZeroR") if opt not in self.help: self.help[opt] = "The classifier/clusterer/associator to train (Classifier/Clusterer/Associator)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Train, self).fix_config(options) opt = "setup" if opt not in options: options[opt] = Classifier(classname="weka.classifiers.rules.ZeroR") if opt not in self.help: self.help[opt] = "The classifier/clusterer/associator to train (Classifier/Clusterer/Associator)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "Train", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"setup\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "Classifier", "(", "classname", "=", "\"weka.classifiers.rules.ZeroR\"", ")", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The classifier/clusterer/associator to train (Classifier/Clusterer/Associator).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L761-L778
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Train.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, Instances): inst = None data = self.input.payload else: inst = self.input.payload data = inst.dataset retrain = False if (self._header is None) or (self._header.equal_headers(data) is not None) or (inst is None): retrain = True self._header = Instances.template_instances(data, 0) if retrain or (self._model is None): cls = self.resolve_option("setup") if isinstance(cls, Classifier): self._model = Classifier.make_copy(cls) elif isinstance(cls, Clusterer): self._model = Clusterer.make_copy(cls) elif isinstance(cls, Associator): self._model = Associator.make_copy(cls) else: return "Unhandled class: " + classes.get_classname(cls) if retrain: if inst is not None: data = Instances.template_instances(data, 1) data.add_instance(inst) if isinstance(self._model, Classifier): self._model.build_classifier(data) elif isinstance(self._model, Clusterer): self._model.build_clusterer(data) elif isinstance(self._model, Associator): self._model.build_associations(data) else: if isinstance(self._model, Classifier): self._model.update_classifier(inst) elif isinstance(self._model, Clusterer): self._model.update_clusterer(inst) else: return "Cannot train incrementally: " + classes.get_classname(self._model) cont = ModelContainer(model=self._model, header=self._header) self._output.append(Token(cont)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, Instances): inst = None data = self.input.payload else: inst = self.input.payload data = inst.dataset retrain = False if (self._header is None) or (self._header.equal_headers(data) is not None) or (inst is None): retrain = True self._header = Instances.template_instances(data, 0) if retrain or (self._model is None): cls = self.resolve_option("setup") if isinstance(cls, Classifier): self._model = Classifier.make_copy(cls) elif isinstance(cls, Clusterer): self._model = Clusterer.make_copy(cls) elif isinstance(cls, Associator): self._model = Associator.make_copy(cls) else: return "Unhandled class: " + classes.get_classname(cls) if retrain: if inst is not None: data = Instances.template_instances(data, 1) data.add_instance(inst) if isinstance(self._model, Classifier): self._model.build_classifier(data) elif isinstance(self._model, Clusterer): self._model.build_clusterer(data) elif isinstance(self._model, Associator): self._model.build_associations(data) else: if isinstance(self._model, Classifier): self._model.update_classifier(inst) elif isinstance(self._model, Clusterer): self._model.update_clusterer(inst) else: return "Cannot train incrementally: " + classes.get_classname(self._model) cont = ModelContainer(model=self._model, header=self._header) self._output.append(Token(cont)) return None
[ "def", "do_execute", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "input", ".", "payload", ",", "Instances", ")", ":", "inst", "=", "None", "data", "=", "self", ".", "input", ".", "payload", "else", ":", "inst", "=", "self", ".", "input", ".", "payload", "data", "=", "inst", ".", "dataset", "retrain", "=", "False", "if", "(", "self", ".", "_header", "is", "None", ")", "or", "(", "self", ".", "_header", ".", "equal_headers", "(", "data", ")", "is", "not", "None", ")", "or", "(", "inst", "is", "None", ")", ":", "retrain", "=", "True", "self", ".", "_header", "=", "Instances", ".", "template_instances", "(", "data", ",", "0", ")", "if", "retrain", "or", "(", "self", ".", "_model", "is", "None", ")", ":", "cls", "=", "self", ".", "resolve_option", "(", "\"setup\"", ")", "if", "isinstance", "(", "cls", ",", "Classifier", ")", ":", "self", ".", "_model", "=", "Classifier", ".", "make_copy", "(", "cls", ")", "elif", "isinstance", "(", "cls", ",", "Clusterer", ")", ":", "self", ".", "_model", "=", "Clusterer", ".", "make_copy", "(", "cls", ")", "elif", "isinstance", "(", "cls", ",", "Associator", ")", ":", "self", ".", "_model", "=", "Associator", ".", "make_copy", "(", "cls", ")", "else", ":", "return", "\"Unhandled class: \"", "+", "classes", ".", "get_classname", "(", "cls", ")", "if", "retrain", ":", "if", "inst", "is", "not", "None", ":", "data", "=", "Instances", ".", "template_instances", "(", "data", ",", "1", ")", "data", ".", "add_instance", "(", "inst", ")", "if", "isinstance", "(", "self", ".", "_model", ",", "Classifier", ")", ":", "self", ".", "_model", ".", "build_classifier", "(", "data", ")", "elif", "isinstance", "(", "self", ".", "_model", ",", "Clusterer", ")", ":", "self", ".", "_model", ".", "build_clusterer", "(", "data", ")", "elif", "isinstance", "(", "self", ".", "_model", ",", "Associator", ")", ":", "self", ".", "_model", ".", "build_associations", "(", "data", ")", "else", ":", "if", "isinstance", "(", "self", ".", "_model", ",", "Classifier", ")", ":", "self", ".", "_model", ".", "update_classifier", "(", "inst", ")", "elif", "isinstance", "(", "self", ".", "_model", ",", "Clusterer", ")", ":", "self", ".", "_model", ".", "update_clusterer", "(", "inst", ")", "else", ":", "return", "\"Cannot train incrementally: \"", "+", "classes", ".", "get_classname", "(", "self", ".", "_model", ")", "cont", "=", "ModelContainer", "(", "model", "=", "self", ".", "_model", ",", "header", "=", "self", ".", "_header", ")", "self", ".", "_output", ".", "append", "(", "Token", "(", "cont", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L793-L843
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Filter.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "setup" if opt not in options: options[opt] = filters.Filter(classname="weka.filters.AllFilter") if opt not in self.help: self.help[opt] = "The filter to apply to the dataset (Filter)." opt = "keep_relationname" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to keep the original relation name (bool)." return super(Filter, self).fix_config(options)
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "setup" if opt not in options: options[opt] = filters.Filter(classname="weka.filters.AllFilter") if opt not in self.help: self.help[opt] = "The filter to apply to the dataset (Filter)." opt = "keep_relationname" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to keep the original relation name (bool)." return super(Filter, self).fix_config(options)
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "opt", "=", "\"setup\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "filters", ".", "Filter", "(", "classname", "=", "\"weka.filters.AllFilter\"", ")", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The filter to apply to the dataset (Filter).\"", "opt", "=", "\"keep_relationname\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "False", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"Whether to keep the original relation name (bool).\"", "return", "super", "(", "Filter", ",", "self", ")", ".", "fix_config", "(", "options", ")" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L885-L906
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Filter.check_input
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if token is None: raise Exception(self.full_name + ": No token provided!") if isinstance(token.payload, Instances): return if isinstance(token.payload, Instance): return raise Exception(self.full_name + ": Unhandled class: " + classes.get_classname(token.payload))
python
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if token is None: raise Exception(self.full_name + ": No token provided!") if isinstance(token.payload, Instances): return if isinstance(token.payload, Instance): return raise Exception(self.full_name + ": Unhandled class: " + classes.get_classname(token.payload))
[ "def", "check_input", "(", "self", ",", "token", ")", ":", "if", "token", "is", "None", ":", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": No token provided!\"", ")", "if", "isinstance", "(", "token", ".", "payload", ",", "Instances", ")", ":", "return", "if", "isinstance", "(", "token", ".", "payload", ",", "Instance", ")", ":", "return", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": Unhandled class: \"", "+", "classes", ".", "get_classname", "(", "token", ".", "payload", ")", ")" ]
Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token
[ "Performs", "checks", "on", "the", "input", "token", ".", "Raises", "an", "exception", "if", "unsupported", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L908-L921
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Filter.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, Instance): inst = self.input.payload data = Instances.template_instances(inst.dataset, 1) data.add_instance(inst) else: inst = None data = self.input.payload relname = data.relationname keep = self.resolve_option("keep_relationname") if inst is None: if (self._filter is None) or self._header.equal_headers(data) is not None: self._header = Instances.template_instances(data) self._filter = filters.Filter.make_copy(self.resolve_option("setup")) self._filter.inputformat(data) filtered = self._filter.filter(data) if keep: filtered.relationname = relname self._output.append(Token(filtered)) else: if (self._filter is None) or self._header.equal_headers(data) is not None: self._header = Instances.template_instances(data) self._filter = filters.Filter.make_copy(self.resolve_option("setup")) self._filter.inputformat(data) filtered = self._filter.filter(data) if keep: filtered.relationname = relname self._output.append(Token(filtered.get_instance(0))) else: self._filter.input(inst) self._filter.batch_finished() filtered = self._filter.output() if keep: filtered.dataset.relationname = relname self._output.append(Token(filtered)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, Instance): inst = self.input.payload data = Instances.template_instances(inst.dataset, 1) data.add_instance(inst) else: inst = None data = self.input.payload relname = data.relationname keep = self.resolve_option("keep_relationname") if inst is None: if (self._filter is None) or self._header.equal_headers(data) is not None: self._header = Instances.template_instances(data) self._filter = filters.Filter.make_copy(self.resolve_option("setup")) self._filter.inputformat(data) filtered = self._filter.filter(data) if keep: filtered.relationname = relname self._output.append(Token(filtered)) else: if (self._filter is None) or self._header.equal_headers(data) is not None: self._header = Instances.template_instances(data) self._filter = filters.Filter.make_copy(self.resolve_option("setup")) self._filter.inputformat(data) filtered = self._filter.filter(data) if keep: filtered.relationname = relname self._output.append(Token(filtered.get_instance(0))) else: self._filter.input(inst) self._filter.batch_finished() filtered = self._filter.output() if keep: filtered.dataset.relationname = relname self._output.append(Token(filtered)) return None
[ "def", "do_execute", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "input", ".", "payload", ",", "Instance", ")", ":", "inst", "=", "self", ".", "input", ".", "payload", "data", "=", "Instances", ".", "template_instances", "(", "inst", ".", "dataset", ",", "1", ")", "data", ".", "add_instance", "(", "inst", ")", "else", ":", "inst", "=", "None", "data", "=", "self", ".", "input", ".", "payload", "relname", "=", "data", ".", "relationname", "keep", "=", "self", ".", "resolve_option", "(", "\"keep_relationname\"", ")", "if", "inst", "is", "None", ":", "if", "(", "self", ".", "_filter", "is", "None", ")", "or", "self", ".", "_header", ".", "equal_headers", "(", "data", ")", "is", "not", "None", ":", "self", ".", "_header", "=", "Instances", ".", "template_instances", "(", "data", ")", "self", ".", "_filter", "=", "filters", ".", "Filter", ".", "make_copy", "(", "self", ".", "resolve_option", "(", "\"setup\"", ")", ")", "self", ".", "_filter", ".", "inputformat", "(", "data", ")", "filtered", "=", "self", ".", "_filter", ".", "filter", "(", "data", ")", "if", "keep", ":", "filtered", ".", "relationname", "=", "relname", "self", ".", "_output", ".", "append", "(", "Token", "(", "filtered", ")", ")", "else", ":", "if", "(", "self", ".", "_filter", "is", "None", ")", "or", "self", ".", "_header", ".", "equal_headers", "(", "data", ")", "is", "not", "None", ":", "self", ".", "_header", "=", "Instances", ".", "template_instances", "(", "data", ")", "self", ".", "_filter", "=", "filters", ".", "Filter", ".", "make_copy", "(", "self", ".", "resolve_option", "(", "\"setup\"", ")", ")", "self", ".", "_filter", ".", "inputformat", "(", "data", ")", "filtered", "=", "self", ".", "_filter", ".", "filter", "(", "data", ")", "if", "keep", ":", "filtered", ".", "relationname", "=", "relname", "self", ".", "_output", ".", "append", "(", "Token", "(", "filtered", ".", "get_instance", "(", "0", ")", ")", ")", "else", ":", "self", ".", "_filter", ".", "input", "(", "inst", ")", "self", ".", "_filter", ".", "batch_finished", "(", ")", "filtered", "=", "self", ".", "_filter", ".", "output", "(", ")", "if", "keep", ":", "filtered", ".", "dataset", ".", "relationname", "=", "relname", "self", ".", "_output", ".", "append", "(", "Token", "(", "filtered", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L923-L966
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
DeleteFile.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(DeleteFile, self).fix_config(options) opt = "regexp" if opt not in options: options[opt] = ".*" if opt not in self.help: self.help[opt] = "The regular expression that the files must match (string)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(DeleteFile, self).fix_config(options) opt = "regexp" if opt not in options: options[opt] = ".*" if opt not in self.help: self.help[opt] = "The regular expression that the files must match (string)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "DeleteFile", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"regexp\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "\".*\"", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The regular expression that the files must match (string).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1004-L1021
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
DeleteFile.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ fname = str(self.input.payload) spattern = str(self.resolve_option("regexp")) pattern = None if (spattern is not None) and (spattern != ".*"): pattern = re.compile(spattern) if (pattern is None) or (pattern.match(fname)): os.remove(fname) self._output.append(self.input) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ fname = str(self.input.payload) spattern = str(self.resolve_option("regexp")) pattern = None if (spattern is not None) and (spattern != ".*"): pattern = re.compile(spattern) if (pattern is None) or (pattern.match(fname)): os.remove(fname) self._output.append(self.input) return None
[ "def", "do_execute", "(", "self", ")", ":", "fname", "=", "str", "(", "self", ".", "input", ".", "payload", ")", "spattern", "=", "str", "(", "self", ".", "resolve_option", "(", "\"regexp\"", ")", ")", "pattern", "=", "None", "if", "(", "spattern", "is", "not", "None", ")", "and", "(", "spattern", "!=", "\".*\"", ")", ":", "pattern", "=", "re", ".", "compile", "(", "spattern", ")", "if", "(", "pattern", "is", "None", ")", "or", "(", "pattern", ".", "match", "(", "fname", ")", ")", ":", "os", ".", "remove", "(", "fname", ")", "self", ".", "_output", ".", "append", "(", "self", ".", "input", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1023-L1038
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
CrossValidate.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(CrossValidate, self).fix_config(options) opt = "setup" if opt not in options: options[opt] = Classifier(classname="weka.classifiers.rules.ZeroR") if opt not in self.help: self.help[opt] = "The classifier/clusterer to train (Classifier/Clusterer)." opt = "folds" if opt not in options: options[opt] = 10 if opt not in self.help: self.help[opt] = "The number of folds for CV (int)." opt = "seed" if opt not in options: options[opt] = 1 if opt not in self.help: self.help[opt] = "The seed value for randomizing the data (int)." opt = "discard_predictions" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Discard classifier predictions to save memory (bool)." opt = "output" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "For capturing the classifier's prediction output (PredictionOutput)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(CrossValidate, self).fix_config(options) opt = "setup" if opt not in options: options[opt] = Classifier(classname="weka.classifiers.rules.ZeroR") if opt not in self.help: self.help[opt] = "The classifier/clusterer to train (Classifier/Clusterer)." opt = "folds" if opt not in options: options[opt] = 10 if opt not in self.help: self.help[opt] = "The number of folds for CV (int)." opt = "seed" if opt not in options: options[opt] = 1 if opt not in self.help: self.help[opt] = "The seed value for randomizing the data (int)." opt = "discard_predictions" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Discard classifier predictions to save memory (bool)." opt = "output" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "For capturing the classifier's prediction output (PredictionOutput)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "CrossValidate", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"setup\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "Classifier", "(", "classname", "=", "\"weka.classifiers.rules.ZeroR\"", ")", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The classifier/clusterer to train (Classifier/Clusterer).\"", "opt", "=", "\"folds\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "10", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The number of folds for CV (int).\"", "opt", "=", "\"seed\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "1", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The seed value for randomizing the data (int).\"", "opt", "=", "\"discard_predictions\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "False", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"Discard classifier predictions to save memory (bool).\"", "opt", "=", "\"output\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "None", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"For capturing the classifier's prediction output (PredictionOutput).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1078-L1119
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
CrossValidate.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ data = self.input.payload cls = self.resolve_option("setup") if isinstance(cls, Classifier): cls = Classifier.make_copy(cls) evl = Evaluation(data) evl.discard_predictions = bool(self.resolve_option("discard_predictions")) evl.crossvalidate_model( cls, data, int(self.resolve_option("folds")), Random(int(self.resolve_option("seed"))), self.resolve_option("output")) self._output.append(Token(evl)) elif isinstance(cls, Clusterer): cls = Clusterer.make_copy(cls) evl = ClusterEvaluation() llh = evl.crossvalidate_model( cls, data, int(self.resolve_option("folds")), Random(int(self.resolve_option("seed")))) self._output.append(Token(llh)) else: return "Unhandled class: " + classes.get_classname(cls) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ data = self.input.payload cls = self.resolve_option("setup") if isinstance(cls, Classifier): cls = Classifier.make_copy(cls) evl = Evaluation(data) evl.discard_predictions = bool(self.resolve_option("discard_predictions")) evl.crossvalidate_model( cls, data, int(self.resolve_option("folds")), Random(int(self.resolve_option("seed"))), self.resolve_option("output")) self._output.append(Token(evl)) elif isinstance(cls, Clusterer): cls = Clusterer.make_copy(cls) evl = ClusterEvaluation() llh = evl.crossvalidate_model( cls, data, int(self.resolve_option("folds")), Random(int(self.resolve_option("seed")))) self._output.append(Token(llh)) else: return "Unhandled class: " + classes.get_classname(cls) return None
[ "def", "do_execute", "(", "self", ")", ":", "data", "=", "self", ".", "input", ".", "payload", "cls", "=", "self", ".", "resolve_option", "(", "\"setup\"", ")", "if", "isinstance", "(", "cls", ",", "Classifier", ")", ":", "cls", "=", "Classifier", ".", "make_copy", "(", "cls", ")", "evl", "=", "Evaluation", "(", "data", ")", "evl", ".", "discard_predictions", "=", "bool", "(", "self", ".", "resolve_option", "(", "\"discard_predictions\"", ")", ")", "evl", ".", "crossvalidate_model", "(", "cls", ",", "data", ",", "int", "(", "self", ".", "resolve_option", "(", "\"folds\"", ")", ")", ",", "Random", "(", "int", "(", "self", ".", "resolve_option", "(", "\"seed\"", ")", ")", ")", ",", "self", ".", "resolve_option", "(", "\"output\"", ")", ")", "self", ".", "_output", ".", "append", "(", "Token", "(", "evl", ")", ")", "elif", "isinstance", "(", "cls", ",", "Clusterer", ")", ":", "cls", "=", "Clusterer", ".", "make_copy", "(", "cls", ")", "evl", "=", "ClusterEvaluation", "(", ")", "llh", "=", "evl", ".", "crossvalidate_model", "(", "cls", ",", "data", ",", "int", "(", "self", ".", "resolve_option", "(", "\"folds\"", ")", ")", ",", "Random", "(", "int", "(", "self", ".", "resolve_option", "(", "\"seed\"", ")", ")", ")", ")", "self", ".", "_output", ".", "append", "(", "Token", "(", "llh", ")", ")", "else", ":", "return", "\"Unhandled class: \"", "+", "classes", ".", "get_classname", "(", "cls", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1132-L1163
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Evaluate.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Evaluate, self).fix_config(options) opt = "storage_name" if opt not in options: options[opt] = "unknown" if opt not in self.help: self.help[opt] = "The name of the classifier model in storage (string)." opt = "discard_predictions" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Discard classifier predictions to save memory (bool)." opt = "output" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "For capturing the classifier's prediction output (PredictionOutput)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Evaluate, self).fix_config(options) opt = "storage_name" if opt not in options: options[opt] = "unknown" if opt not in self.help: self.help[opt] = "The name of the classifier model in storage (string)." opt = "discard_predictions" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Discard classifier predictions to save memory (bool)." opt = "output" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "For capturing the classifier's prediction output (PredictionOutput)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "Evaluate", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"storage_name\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "\"unknown\"", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The name of the classifier model in storage (string).\"", "opt", "=", "\"discard_predictions\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "False", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"Discard classifier predictions to save memory (bool).\"", "opt", "=", "\"output\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "None", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"For capturing the classifier's prediction output (PredictionOutput).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1201-L1230
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Evaluate.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ data = self.input.payload if self.storagehandler is None: return "No storage handler available!" sname = str(self.resolve_option("storage_name")) if sname not in self.storagehandler.storage: return "No storage item called '" + sname + "' present!" cls = self.storagehandler.storage[sname] if isinstance(cls, Classifier): evl = Evaluation(data) evl.discard_predictions = bool(self.resolve_option("discard_predictions")) evl.test_model( cls, data, self.resolve_option("output")) elif isinstance(cls, Clusterer): evl = ClusterEvaluation() evl.set_model(cls) evl.test_model(data) else: return "Unhandled class: " + classes.get_classname(cls) self._output.append(Token(evl)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ data = self.input.payload if self.storagehandler is None: return "No storage handler available!" sname = str(self.resolve_option("storage_name")) if sname not in self.storagehandler.storage: return "No storage item called '" + sname + "' present!" cls = self.storagehandler.storage[sname] if isinstance(cls, Classifier): evl = Evaluation(data) evl.discard_predictions = bool(self.resolve_option("discard_predictions")) evl.test_model( cls, data, self.resolve_option("output")) elif isinstance(cls, Clusterer): evl = ClusterEvaluation() evl.set_model(cls) evl.test_model(data) else: return "Unhandled class: " + classes.get_classname(cls) self._output.append(Token(evl)) return None
[ "def", "do_execute", "(", "self", ")", ":", "data", "=", "self", ".", "input", ".", "payload", "if", "self", ".", "storagehandler", "is", "None", ":", "return", "\"No storage handler available!\"", "sname", "=", "str", "(", "self", ".", "resolve_option", "(", "\"storage_name\"", ")", ")", "if", "sname", "not", "in", "self", ".", "storagehandler", ".", "storage", ":", "return", "\"No storage item called '\"", "+", "sname", "+", "\"' present!\"", "cls", "=", "self", ".", "storagehandler", ".", "storage", "[", "sname", "]", "if", "isinstance", "(", "cls", ",", "Classifier", ")", ":", "evl", "=", "Evaluation", "(", "data", ")", "evl", ".", "discard_predictions", "=", "bool", "(", "self", ".", "resolve_option", "(", "\"discard_predictions\"", ")", ")", "evl", ".", "test_model", "(", "cls", ",", "data", ",", "self", ".", "resolve_option", "(", "\"output\"", ")", ")", "elif", "isinstance", "(", "cls", ",", "Clusterer", ")", ":", "evl", "=", "ClusterEvaluation", "(", ")", "evl", ".", "set_model", "(", "cls", ")", "evl", ".", "test_model", "(", "data", ")", "else", ":", "return", "\"Unhandled class: \"", "+", "classes", ".", "get_classname", "(", "cls", ")", "self", ".", "_output", ".", "append", "(", "Token", "(", "evl", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1243-L1271
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
EvaluationSummary.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(EvaluationSummary, self).fix_config(options) opt = "title" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "The title for the output (string)." opt = "complexity" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to output classifier complexity information (bool)." opt = "matrix" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to output the classifier confusion matrix (bool)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(EvaluationSummary, self).fix_config(options) opt = "title" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "The title for the output (string)." opt = "complexity" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to output classifier complexity information (bool)." opt = "matrix" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to output the classifier confusion matrix (bool)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "EvaluationSummary", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"title\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "None", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The title for the output (string).\"", "opt", "=", "\"complexity\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "False", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"Whether to output classifier complexity information (bool).\"", "opt", "=", "\"matrix\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "False", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"Whether to output the classifier confusion matrix (bool).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1311-L1340
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
EvaluationSummary.check_input
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if isinstance(token.payload, Evaluation): return None if isinstance(token.payload, ClusterEvaluation): return None raise Exception( self.full_name + ": Input token is not a supported Evaluation object - " + classes.get_classname(token.payload))
python
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if isinstance(token.payload, Evaluation): return None if isinstance(token.payload, ClusterEvaluation): return None raise Exception( self.full_name + ": Input token is not a supported Evaluation object - " + classes.get_classname(token.payload))
[ "def", "check_input", "(", "self", ",", "token", ")", ":", "if", "isinstance", "(", "token", ".", "payload", ",", "Evaluation", ")", ":", "return", "None", "if", "isinstance", "(", "token", ".", "payload", ",", "ClusterEvaluation", ")", ":", "return", "None", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": Input token is not a supported Evaluation object - \"", "+", "classes", ".", "get_classname", "(", "token", ".", "payload", ")", ")" ]
Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token
[ "Performs", "checks", "on", "the", "input", "token", ".", "Raises", "an", "exception", "if", "unsupported", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1342-L1355
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
EvaluationSummary.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ evl = self.input.payload if isinstance(evl, Evaluation): summary = evl.summary(title=self.resolve_option("title"), complexity=bool(self.resolve_option("complexity"))) if bool(self.resolve_option("matrix")): summary += "\n" + evl.matrix(title=self.resolve_option("title")) else: summary = evl.cluster_results self._output.append(Token(summary)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ evl = self.input.payload if isinstance(evl, Evaluation): summary = evl.summary(title=self.resolve_option("title"), complexity=bool(self.resolve_option("complexity"))) if bool(self.resolve_option("matrix")): summary += "\n" + evl.matrix(title=self.resolve_option("title")) else: summary = evl.cluster_results self._output.append(Token(summary)) return None
[ "def", "do_execute", "(", "self", ")", ":", "evl", "=", "self", ".", "input", ".", "payload", "if", "isinstance", "(", "evl", ",", "Evaluation", ")", ":", "summary", "=", "evl", ".", "summary", "(", "title", "=", "self", ".", "resolve_option", "(", "\"title\"", ")", ",", "complexity", "=", "bool", "(", "self", ".", "resolve_option", "(", "\"complexity\"", ")", ")", ")", "if", "bool", "(", "self", ".", "resolve_option", "(", "\"matrix\"", ")", ")", ":", "summary", "+=", "\"\\n\"", "+", "evl", ".", "matrix", "(", "title", "=", "self", ".", "resolve_option", "(", "\"title\"", ")", ")", "else", ":", "summary", "=", "evl", ".", "cluster_results", "self", ".", "_output", ".", "append", "(", "Token", "(", "summary", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1357-L1372
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
ModelReader.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ fname = self.input.payload data = serialization.read_all(fname) if len(data) == 1: if is_instance_of(data[0], "weka.classifiers.Classifier"): cont = ModelContainer(model=Classifier(jobject=data[0])) elif is_instance_of(data[0], "weka.clusterers.Clusterer"): cont = ModelContainer(model=Clusterer(jobject=data[0])) else: return "Unhandled class: " + classes.get_classname(data[0]) elif len(data) == 2: if is_instance_of(data[0], "weka.classifiers.Classifier"): cont = ModelContainer(model=Classifier(jobject=data[0]), header=Instances(data[1])) elif is_instance_of(data[0], "weka.clusterers.Clusterer"): cont = ModelContainer(model=Clusterer(jobject=data[0]), header=Instances(data[1])) else: return "Unhandled class: " + classes.get_classname(data[0]) else: return "Expected 1 or 2 objects, but got " + str(len(data)) + " instead reading: " + fname self._output.append(Token(cont)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ fname = self.input.payload data = serialization.read_all(fname) if len(data) == 1: if is_instance_of(data[0], "weka.classifiers.Classifier"): cont = ModelContainer(model=Classifier(jobject=data[0])) elif is_instance_of(data[0], "weka.clusterers.Clusterer"): cont = ModelContainer(model=Clusterer(jobject=data[0])) else: return "Unhandled class: " + classes.get_classname(data[0]) elif len(data) == 2: if is_instance_of(data[0], "weka.classifiers.Classifier"): cont = ModelContainer(model=Classifier(jobject=data[0]), header=Instances(data[1])) elif is_instance_of(data[0], "weka.clusterers.Clusterer"): cont = ModelContainer(model=Clusterer(jobject=data[0]), header=Instances(data[1])) else: return "Unhandled class: " + classes.get_classname(data[0]) else: return "Expected 1 or 2 objects, but got " + str(len(data)) + " instead reading: " + fname self._output.append(Token(cont)) return None
[ "def", "do_execute", "(", "self", ")", ":", "fname", "=", "self", ".", "input", ".", "payload", "data", "=", "serialization", ".", "read_all", "(", "fname", ")", "if", "len", "(", "data", ")", "==", "1", ":", "if", "is_instance_of", "(", "data", "[", "0", "]", ",", "\"weka.classifiers.Classifier\"", ")", ":", "cont", "=", "ModelContainer", "(", "model", "=", "Classifier", "(", "jobject", "=", "data", "[", "0", "]", ")", ")", "elif", "is_instance_of", "(", "data", "[", "0", "]", ",", "\"weka.clusterers.Clusterer\"", ")", ":", "cont", "=", "ModelContainer", "(", "model", "=", "Clusterer", "(", "jobject", "=", "data", "[", "0", "]", ")", ")", "else", ":", "return", "\"Unhandled class: \"", "+", "classes", ".", "get_classname", "(", "data", "[", "0", "]", ")", "elif", "len", "(", "data", ")", "==", "2", ":", "if", "is_instance_of", "(", "data", "[", "0", "]", ",", "\"weka.classifiers.Classifier\"", ")", ":", "cont", "=", "ModelContainer", "(", "model", "=", "Classifier", "(", "jobject", "=", "data", "[", "0", "]", ")", ",", "header", "=", "Instances", "(", "data", "[", "1", "]", ")", ")", "elif", "is_instance_of", "(", "data", "[", "0", "]", ",", "\"weka.clusterers.Clusterer\"", ")", ":", "cont", "=", "ModelContainer", "(", "model", "=", "Clusterer", "(", "jobject", "=", "data", "[", "0", "]", ")", ",", "header", "=", "Instances", "(", "data", "[", "1", "]", ")", ")", "else", ":", "return", "\"Unhandled class: \"", "+", "classes", ".", "get_classname", "(", "data", "[", "0", "]", ")", "else", ":", "return", "\"Expected 1 or 2 objects, but got \"", "+", "str", "(", "len", "(", "data", ")", ")", "+", "\" instead reading: \"", "+", "fname", "self", ".", "_output", ".", "append", "(", "Token", "(", "cont", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1400-L1426
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Convert.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "setup" if opt not in options: options[opt] = conversion.PassThrough() if opt not in self.help: self.help[opt] = "The conversion to apply to the input data (Conversion)." return super(Convert, self).fix_config(options)
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "setup" if opt not in options: options[opt] = conversion.PassThrough() if opt not in self.help: self.help[opt] = "The conversion to apply to the input data (Conversion)." return super(Convert, self).fix_config(options)
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "opt", "=", "\"setup\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "conversion", ".", "PassThrough", "(", ")", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The conversion to apply to the input data (Conversion).\"", "return", "super", "(", "Convert", ",", "self", ")", ".", "fix_config", "(", "options", ")" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1464-L1479
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Convert.check_input
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if token is None: raise Exception(self.full_name + ": No token provided!") self.config["setup"].check_input(token.payload)
python
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if token is None: raise Exception(self.full_name + ": No token provided!") self.config["setup"].check_input(token.payload)
[ "def", "check_input", "(", "self", ",", "token", ")", ":", "if", "token", "is", "None", ":", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": No token provided!\"", ")", "self", ".", "config", "[", "\"setup\"", "]", ".", "check_input", "(", "token", ".", "payload", ")" ]
Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token
[ "Performs", "checks", "on", "the", "input", "token", ".", "Raises", "an", "exception", "if", "unsupported", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1481-L1490
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Convert.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ conv = self.config["setup"].shallow_copy() conv.input = self._input.payload result = conv.convert() if result is None: if conv.output is not None: self._output.append(Token(conv.output)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ conv = self.config["setup"].shallow_copy() conv.input = self._input.payload result = conv.convert() if result is None: if conv.output is not None: self._output.append(Token(conv.output)) return None
[ "def", "do_execute", "(", "self", ")", ":", "conv", "=", "self", ".", "config", "[", "\"setup\"", "]", ".", "shallow_copy", "(", ")", "conv", ".", "input", "=", "self", ".", "_input", ".", "payload", "result", "=", "conv", ".", "convert", "(", ")", "if", "result", "is", "None", ":", "if", "conv", ".", "output", "is", "not", "None", ":", "self", ".", "_output", ".", "append", "(", "Token", "(", "conv", ".", "output", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1492-L1505
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
AttributeSelection.quickinfo
def quickinfo(self): """ Returns a short string describing some of the options of the actor. :return: the info, None if not available :rtype: str """ return "search: " + base.to_commandline(self.config["search"]) + ", eval: " \ + base.to_commandline(self.config["eval"])
python
def quickinfo(self): """ Returns a short string describing some of the options of the actor. :return: the info, None if not available :rtype: str """ return "search: " + base.to_commandline(self.config["search"]) + ", eval: " \ + base.to_commandline(self.config["eval"])
[ "def", "quickinfo", "(", "self", ")", ":", "return", "\"search: \"", "+", "base", ".", "to_commandline", "(", "self", ".", "config", "[", "\"search\"", "]", ")", "+", "\", eval: \"", "+", "base", ".", "to_commandline", "(", "self", ".", "config", "[", "\"eval\"", "]", ")" ]
Returns a short string describing some of the options of the actor. :return: the info, None if not available :rtype: str
[ "Returns", "a", "short", "string", "describing", "some", "of", "the", "options", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1537-L1545
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
AttributeSelection.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "search" if opt not in options: options[opt] = attsel.ASSearch(classname="weka.attributeSelection.BestFirst") if opt not in self.help: self.help[opt] = "The search algorithm to use (ASSearch)." opt = "eval" if opt not in options: options[opt] = attsel.ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval") if opt not in self.help: self.help[opt] = "The evaluation algorithm to use (ASEvaluation)." return super(AttributeSelection, self).fix_config(options)
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "search" if opt not in options: options[opt] = attsel.ASSearch(classname="weka.attributeSelection.BestFirst") if opt not in self.help: self.help[opt] = "The search algorithm to use (ASSearch)." opt = "eval" if opt not in options: options[opt] = attsel.ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval") if opt not in self.help: self.help[opt] = "The evaluation algorithm to use (ASEvaluation)." return super(AttributeSelection, self).fix_config(options)
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "opt", "=", "\"search\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "attsel", ".", "ASSearch", "(", "classname", "=", "\"weka.attributeSelection.BestFirst\"", ")", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The search algorithm to use (ASSearch).\"", "opt", "=", "\"eval\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "attsel", ".", "ASEvaluation", "(", "classname", "=", "\"weka.attributeSelection.CfsSubsetEval\"", ")", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The evaluation algorithm to use (ASEvaluation).\"", "return", "super", "(", "AttributeSelection", ",", "self", ")", ".", "fix_config", "(", "options", ")" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1547-L1568
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
AttributeSelection.check_input
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if token is None: raise Exception(self.full_name + ": No token provided!") if not isinstance(token.payload, Instances): raise Exception(self.full_name + ": Not an Instances object!")
python
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if token is None: raise Exception(self.full_name + ": No token provided!") if not isinstance(token.payload, Instances): raise Exception(self.full_name + ": Not an Instances object!")
[ "def", "check_input", "(", "self", ",", "token", ")", ":", "if", "token", "is", "None", ":", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": No token provided!\"", ")", "if", "not", "isinstance", "(", "token", ".", "payload", ",", "Instances", ")", ":", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": Not an Instances object!\"", ")" ]
Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token
[ "Performs", "checks", "on", "the", "input", "token", ".", "Raises", "an", "exception", "if", "unsupported", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1570-L1580
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
AttributeSelection.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ data = self.input.payload search = self.config["search"].shallow_copy() evl = self.config["eval"].shallow_copy() asel = attsel.AttributeSelection() asel.search(search) asel.evaluator(evl) asel.select_attributes(data) cont = AttributeSelectionContainer( original=data, reduced=asel.reduce_dimensionality(data), num_atts=asel.number_attributes_selected, selected=asel.selected_attributes, results=asel.results_string) self._output.append(Token(cont)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ data = self.input.payload search = self.config["search"].shallow_copy() evl = self.config["eval"].shallow_copy() asel = attsel.AttributeSelection() asel.search(search) asel.evaluator(evl) asel.select_attributes(data) cont = AttributeSelectionContainer( original=data, reduced=asel.reduce_dimensionality(data), num_atts=asel.number_attributes_selected, selected=asel.selected_attributes, results=asel.results_string) self._output.append(Token(cont)) return None
[ "def", "do_execute", "(", "self", ")", ":", "data", "=", "self", ".", "input", ".", "payload", "search", "=", "self", ".", "config", "[", "\"search\"", "]", ".", "shallow_copy", "(", ")", "evl", "=", "self", ".", "config", "[", "\"eval\"", "]", ".", "shallow_copy", "(", ")", "asel", "=", "attsel", ".", "AttributeSelection", "(", ")", "asel", ".", "search", "(", "search", ")", "asel", ".", "evaluator", "(", "evl", ")", "asel", ".", "select_attributes", "(", "data", ")", "cont", "=", "AttributeSelectionContainer", "(", "original", "=", "data", ",", "reduced", "=", "asel", ".", "reduce_dimensionality", "(", "data", ")", ",", "num_atts", "=", "asel", ".", "number_attributes_selected", ",", "selected", "=", "asel", ".", "selected_attributes", ",", "results", "=", "asel", ".", "results_string", ")", "self", ".", "_output", ".", "append", "(", "Token", "(", "cont", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1582-L1603
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
RenameRelation.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(RenameRelation, self).fix_config(options) opt = "name" if opt not in options: options[opt] = "newname" if opt not in self.help: self.help[opt] = "The new relation name to use (string)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(RenameRelation, self).fix_config(options) opt = "name" if opt not in options: options[opt] = "newname" if opt not in self.help: self.help[opt] = "The new relation name to use (string)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "RenameRelation", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"name\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "\"newname\"", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The new relation name to use (string).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1641-L1658
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
RenameRelation.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ relname = self.resolve_option("name") if isinstance(self.input.payload, Instance): self.input.payload.dataset.relationname = relname else: self.input.payload.relationname = relname self._output.append(self.input) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ relname = self.resolve_option("name") if isinstance(self.input.payload, Instance): self.input.payload.dataset.relationname = relname else: self.input.payload.relationname = relname self._output.append(self.input) return None
[ "def", "do_execute", "(", "self", ")", ":", "relname", "=", "self", ".", "resolve_option", "(", "\"name\"", ")", "if", "isinstance", "(", "self", ".", "input", ".", "payload", ",", "Instance", ")", ":", "self", ".", "input", ".", "payload", ".", "dataset", ".", "relationname", "=", "relname", "else", ":", "self", ".", "input", ".", "payload", ".", "relationname", "=", "relname", "self", ".", "_output", ".", "append", "(", "self", ".", "input", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1673-L1686
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Copy.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, classes.JavaObject) and self.input.payload.is_serializable: copy = serialization.deepcopy(self.input.payload) if copy is not None: self._output.append(Token(copy)) else: self._output.append(self.input) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ if isinstance(self.input.payload, classes.JavaObject) and self.input.payload.is_serializable: copy = serialization.deepcopy(self.input.payload) if copy is not None: self._output.append(Token(copy)) else: self._output.append(self.input) return None
[ "def", "do_execute", "(", "self", ")", ":", "if", "isinstance", "(", "self", ".", "input", ".", "payload", ",", "classes", ".", "JavaObject", ")", "and", "self", ".", "input", ".", "payload", ".", "is_serializable", ":", "copy", "=", "serialization", ".", "deepcopy", "(", "self", ".", "input", ".", "payload", ")", "if", "copy", "is", "not", "None", ":", "self", ".", "_output", ".", "append", "(", "Token", "(", "copy", ")", ")", "else", ":", "self", ".", "_output", ".", "append", "(", "self", ".", "input", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1716-L1729
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Predict.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Predict, self).fix_config(options) opt = "model" if opt not in options: options[opt] = "." if opt not in self.help: self.help[opt] = "The serialized model to use for making predictions (string)." opt = "storage_name" if opt not in options: options[opt] = "unknown" if opt not in self.help: self.help[opt] = "The name of the model (or ModelContainer) in storage to use (string)." return options
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ options = super(Predict, self).fix_config(options) opt = "model" if opt not in options: options[opt] = "." if opt not in self.help: self.help[opt] = "The serialized model to use for making predictions (string)." opt = "storage_name" if opt not in options: options[opt] = "unknown" if opt not in self.help: self.help[opt] = "The name of the model (or ModelContainer) in storage to use (string)." return options
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "options", "=", "super", "(", "Predict", ",", "self", ")", ".", "fix_config", "(", "options", ")", "opt", "=", "\"model\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "\".\"", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The serialized model to use for making predictions (string).\"", "opt", "=", "\"storage_name\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "\"unknown\"", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The name of the model (or ModelContainer) in storage to use (string).\"", "return", "options" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1774-L1797
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Predict.check_input
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if isinstance(token.payload, Instance): return raise Exception(self.full_name + ": Unhandled data type: " + str(token.payload.__class__.__name__))
python
def check_input(self, token): """ Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token """ if isinstance(token.payload, Instance): return raise Exception(self.full_name + ": Unhandled data type: " + str(token.payload.__class__.__name__))
[ "def", "check_input", "(", "self", ",", "token", ")", ":", "if", "isinstance", "(", "token", ".", "payload", ",", "Instance", ")", ":", "return", "raise", "Exception", "(", "self", ".", "full_name", "+", "\": Unhandled data type: \"", "+", "str", "(", "token", ".", "payload", ".", "__class__", ".", "__name__", ")", ")" ]
Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token
[ "Performs", "checks", "on", "the", "input", "token", ".", "Raises", "an", "exception", "if", "unsupported", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1799-L1808
fracpete/python-weka-wrapper3
python/weka/flow/transformer.py
Predict.do_execute
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ inst = self.input.payload if not inst.has_class: return "No class set!" # load model? if self._model is None: model = None fname = str(self.resolve_option("model")) if os.path.isfile(fname): model = serialization.read(fname) else: name = self.resolve_option("storage_name") if name in self.storagehandler.storage: model = self.storagehandler.storage.get(name) if isinstance(model, ModelContainer): model = model.get("Model").jobject if model is None: return "No model available from storage or serialized file!" self._is_classifier = is_instance_of(model, "weka.classifiers.Classifier") if self._is_classifier: self._model = Classifier(jobject=model) else: self._model = Clusterer(jobject=model) if self._is_classifier: cls = self._model.classify_instance(inst) dist = self._model.distribution_for_instance(inst) label = inst.class_attribute.value(int(cls)) cont = ClassificationContainer(inst=inst, classification=cls, distribution=dist, label=label) else: cls = self._model.cluster_instance(inst) dist = self._model.distribution_for_instance(inst) cont = ClusteringContainer(inst=inst, cluster=int(cls), distribution=dist) self._output.append(Token(cont)) return None
python
def do_execute(self): """ The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str """ inst = self.input.payload if not inst.has_class: return "No class set!" # load model? if self._model is None: model = None fname = str(self.resolve_option("model")) if os.path.isfile(fname): model = serialization.read(fname) else: name = self.resolve_option("storage_name") if name in self.storagehandler.storage: model = self.storagehandler.storage.get(name) if isinstance(model, ModelContainer): model = model.get("Model").jobject if model is None: return "No model available from storage or serialized file!" self._is_classifier = is_instance_of(model, "weka.classifiers.Classifier") if self._is_classifier: self._model = Classifier(jobject=model) else: self._model = Clusterer(jobject=model) if self._is_classifier: cls = self._model.classify_instance(inst) dist = self._model.distribution_for_instance(inst) label = inst.class_attribute.value(int(cls)) cont = ClassificationContainer(inst=inst, classification=cls, distribution=dist, label=label) else: cls = self._model.cluster_instance(inst) dist = self._model.distribution_for_instance(inst) cont = ClusteringContainer(inst=inst, cluster=int(cls), distribution=dist) self._output.append(Token(cont)) return None
[ "def", "do_execute", "(", "self", ")", ":", "inst", "=", "self", ".", "input", ".", "payload", "if", "not", "inst", ".", "has_class", ":", "return", "\"No class set!\"", "# load model?", "if", "self", ".", "_model", "is", "None", ":", "model", "=", "None", "fname", "=", "str", "(", "self", ".", "resolve_option", "(", "\"model\"", ")", ")", "if", "os", ".", "path", ".", "isfile", "(", "fname", ")", ":", "model", "=", "serialization", ".", "read", "(", "fname", ")", "else", ":", "name", "=", "self", ".", "resolve_option", "(", "\"storage_name\"", ")", "if", "name", "in", "self", ".", "storagehandler", ".", "storage", ":", "model", "=", "self", ".", "storagehandler", ".", "storage", ".", "get", "(", "name", ")", "if", "isinstance", "(", "model", ",", "ModelContainer", ")", ":", "model", "=", "model", ".", "get", "(", "\"Model\"", ")", ".", "jobject", "if", "model", "is", "None", ":", "return", "\"No model available from storage or serialized file!\"", "self", ".", "_is_classifier", "=", "is_instance_of", "(", "model", ",", "\"weka.classifiers.Classifier\"", ")", "if", "self", ".", "_is_classifier", ":", "self", ".", "_model", "=", "Classifier", "(", "jobject", "=", "model", ")", "else", ":", "self", ".", "_model", "=", "Clusterer", "(", "jobject", "=", "model", ")", "if", "self", ".", "_is_classifier", ":", "cls", "=", "self", ".", "_model", ".", "classify_instance", "(", "inst", ")", "dist", "=", "self", ".", "_model", ".", "distribution_for_instance", "(", "inst", ")", "label", "=", "inst", ".", "class_attribute", ".", "value", "(", "int", "(", "cls", ")", ")", "cont", "=", "ClassificationContainer", "(", "inst", "=", "inst", ",", "classification", "=", "cls", ",", "distribution", "=", "dist", ",", "label", "=", "label", ")", "else", ":", "cls", "=", "self", ".", "_model", ".", "cluster_instance", "(", "inst", ")", "dist", "=", "self", ".", "_model", ".", "distribution_for_instance", "(", "inst", ")", "cont", "=", "ClusteringContainer", "(", "inst", "=", "inst", ",", "cluster", "=", "int", "(", "cls", ")", ",", "distribution", "=", "dist", ")", "self", ".", "_output", ".", "append", "(", "Token", "(", "cont", ")", ")", "return", "None" ]
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
[ "The", "actual", "execution", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/transformer.py#L1810-L1852
fracpete/python-weka-wrapper3
python/weka/plot/graph.py
plot_dot_graph
def plot_dot_graph(graph, filename=None): """ Plots a graph in graphviz dot notation. :param graph: the dot notation graph :type graph: str :param filename: the (optional) file to save the generated plot to. The extension determines the file format. :type filename: str """ if not plot.pygraphviz_available: logger.error("Pygraphviz is not installed, cannot generate graph plot!") return if not plot.PIL_available: logger.error("PIL is not installed, cannot display graph plot!") return agraph = AGraph(graph) agraph.layout(prog='dot') if filename is None: filename = tempfile.mktemp(suffix=".png") agraph.draw(filename) image = Image.open(filename) image.show()
python
def plot_dot_graph(graph, filename=None): """ Plots a graph in graphviz dot notation. :param graph: the dot notation graph :type graph: str :param filename: the (optional) file to save the generated plot to. The extension determines the file format. :type filename: str """ if not plot.pygraphviz_available: logger.error("Pygraphviz is not installed, cannot generate graph plot!") return if not plot.PIL_available: logger.error("PIL is not installed, cannot display graph plot!") return agraph = AGraph(graph) agraph.layout(prog='dot') if filename is None: filename = tempfile.mktemp(suffix=".png") agraph.draw(filename) image = Image.open(filename) image.show()
[ "def", "plot_dot_graph", "(", "graph", ",", "filename", "=", "None", ")", ":", "if", "not", "plot", ".", "pygraphviz_available", ":", "logger", ".", "error", "(", "\"Pygraphviz is not installed, cannot generate graph plot!\"", ")", "return", "if", "not", "plot", ".", "PIL_available", ":", "logger", ".", "error", "(", "\"PIL is not installed, cannot display graph plot!\"", ")", "return", "agraph", "=", "AGraph", "(", "graph", ")", "agraph", ".", "layout", "(", "prog", "=", "'dot'", ")", "if", "filename", "is", "None", ":", "filename", "=", "tempfile", ".", "mktemp", "(", "suffix", "=", "\".png\"", ")", "agraph", ".", "draw", "(", "filename", ")", "image", "=", "Image", ".", "open", "(", "filename", ")", "image", ".", "show", "(", ")" ]
Plots a graph in graphviz dot notation. :param graph: the dot notation graph :type graph: str :param filename: the (optional) file to save the generated plot to. The extension determines the file format. :type filename: str
[ "Plots", "a", "graph", "in", "graphviz", "dot", "notation", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/plot/graph.py#L29-L51
fracpete/python-weka-wrapper3
python/weka/core/stemmers.py
Stemmer.stem
def stem(self, s): """ Performs stemming on the string. :param s: the string to stem :type s: str :return: the stemmed string :rtype: str """ return javabridge.get_env().get_string(self.__stem(javabridge.get_env().new_string_utf(s)))
python
def stem(self, s): """ Performs stemming on the string. :param s: the string to stem :type s: str :return: the stemmed string :rtype: str """ return javabridge.get_env().get_string(self.__stem(javabridge.get_env().new_string_utf(s)))
[ "def", "stem", "(", "self", ",", "s", ")", ":", "return", "javabridge", ".", "get_env", "(", ")", ".", "get_string", "(", "self", ".", "__stem", "(", "javabridge", ".", "get_env", "(", ")", ".", "new_string_utf", "(", "s", ")", ")", ")" ]
Performs stemming on the string. :param s: the string to stem :type s: str :return: the stemmed string :rtype: str
[ "Performs", "stemming", "on", "the", "string", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/stemmers.py#L43-L52
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
create_instances_from_matrices
def create_instances_from_matrices(x, y=None, name="data"): """ Allows the generation of an Instances object from a 2-dimensional matrix for X and a 1-dimensional matrix for Y (optional). All data must be numerical. Attributes can be converted to nominal with the weka.filters.unsupervised.attribute.NumericToNominal filter. :param x: the input variables :type x: ndarray :param y: the output variable (optional) :type y: ndarray :param name: the name of the dataset :type name: str :return: the generated dataset :rtype: Instances """ if y is not None: if len(x) != len(y): raise Exception("Dimensions of x and y differ: " + str(len(x)) + " != " + str(len(y))) # create header atts = [] for i in range(len(x[0])): atts.append(Attribute.create_numeric("x" + str(i+1))) if y is not None: atts.append(Attribute.create_numeric("y")) result = Instances.create_instances(name, atts, len(x)) # add data for i in range(len(x)): values = list(x[i]) if y is not None: values.append(y[i]) result.add_instance(Instance.create_instance(values)) return result
python
def create_instances_from_matrices(x, y=None, name="data"): """ Allows the generation of an Instances object from a 2-dimensional matrix for X and a 1-dimensional matrix for Y (optional). All data must be numerical. Attributes can be converted to nominal with the weka.filters.unsupervised.attribute.NumericToNominal filter. :param x: the input variables :type x: ndarray :param y: the output variable (optional) :type y: ndarray :param name: the name of the dataset :type name: str :return: the generated dataset :rtype: Instances """ if y is not None: if len(x) != len(y): raise Exception("Dimensions of x and y differ: " + str(len(x)) + " != " + str(len(y))) # create header atts = [] for i in range(len(x[0])): atts.append(Attribute.create_numeric("x" + str(i+1))) if y is not None: atts.append(Attribute.create_numeric("y")) result = Instances.create_instances(name, atts, len(x)) # add data for i in range(len(x)): values = list(x[i]) if y is not None: values.append(y[i]) result.add_instance(Instance.create_instance(values)) return result
[ "def", "create_instances_from_matrices", "(", "x", ",", "y", "=", "None", ",", "name", "=", "\"data\"", ")", ":", "if", "y", "is", "not", "None", ":", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", ":", "raise", "Exception", "(", "\"Dimensions of x and y differ: \"", "+", "str", "(", "len", "(", "x", ")", ")", "+", "\" != \"", "+", "str", "(", "len", "(", "y", ")", ")", ")", "# create header", "atts", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "x", "[", "0", "]", ")", ")", ":", "atts", ".", "append", "(", "Attribute", ".", "create_numeric", "(", "\"x\"", "+", "str", "(", "i", "+", "1", ")", ")", ")", "if", "y", "is", "not", "None", ":", "atts", ".", "append", "(", "Attribute", ".", "create_numeric", "(", "\"y\"", ")", ")", "result", "=", "Instances", ".", "create_instances", "(", "name", ",", "atts", ",", "len", "(", "x", ")", ")", "# add data", "for", "i", "in", "range", "(", "len", "(", "x", ")", ")", ":", "values", "=", "list", "(", "x", "[", "i", "]", ")", "if", "y", "is", "not", "None", ":", "values", ".", "append", "(", "y", "[", "i", "]", ")", "result", ".", "add_instance", "(", "Instance", ".", "create_instance", "(", "values", ")", ")", "return", "result" ]
Allows the generation of an Instances object from a 2-dimensional matrix for X and a 1-dimensional matrix for Y (optional). All data must be numerical. Attributes can be converted to nominal with the weka.filters.unsupervised.attribute.NumericToNominal filter. :param x: the input variables :type x: ndarray :param y: the output variable (optional) :type y: ndarray :param name: the name of the dataset :type name: str :return: the generated dataset :rtype: Instances
[ "Allows", "the", "generation", "of", "an", "Instances", "object", "from", "a", "2", "-", "dimensional", "matrix", "for", "X", "and", "a", "1", "-", "dimensional", "matrix", "for", "Y", "(", "optional", ")", ".", "All", "data", "must", "be", "numerical", ".", "Attributes", "can", "be", "converted", "to", "nominal", "with", "the", "weka", ".", "filters", ".", "unsupervised", ".", "attribute", ".", "NumericToNominal", "filter", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L1528-L1560
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.attribute_by_name
def attribute_by_name(self, name): """ Returns the specified attribute, None if not found. :param name: the name of the attribute :type name: str :return: the attribute or None :rtype: Attribute """ att = self.__attribute_by_name(javabridge.get_env().new_string(name)) if att is None: return None else: return Attribute(att)
python
def attribute_by_name(self, name): """ Returns the specified attribute, None if not found. :param name: the name of the attribute :type name: str :return: the attribute or None :rtype: Attribute """ att = self.__attribute_by_name(javabridge.get_env().new_string(name)) if att is None: return None else: return Attribute(att)
[ "def", "attribute_by_name", "(", "self", ",", "name", ")", ":", "att", "=", "self", ".", "__attribute_by_name", "(", "javabridge", ".", "get_env", "(", ")", ".", "new_string", "(", "name", ")", ")", "if", "att", "is", "None", ":", "return", "None", "else", ":", "return", "Attribute", "(", "att", ")" ]
Returns the specified attribute, None if not found. :param name: the name of the attribute :type name: str :return: the attribute or None :rtype: Attribute
[ "Returns", "the", "specified", "attribute", "None", "if", "not", "found", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L118-L131
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.add_instance
def add_instance(self, inst, index=None): """ Adds the specified instance to the dataset. :param inst: the Instance to add :type inst: Instance :param index: the 0-based index where to add the Instance :type index: int """ if index is None: self.__append_instance(inst.jobject) else: self.__insert_instance(index, inst.jobject)
python
def add_instance(self, inst, index=None): """ Adds the specified instance to the dataset. :param inst: the Instance to add :type inst: Instance :param index: the 0-based index where to add the Instance :type index: int """ if index is None: self.__append_instance(inst.jobject) else: self.__insert_instance(index, inst.jobject)
[ "def", "add_instance", "(", "self", ",", "inst", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "self", ".", "__append_instance", "(", "inst", ".", "jobject", ")", "else", ":", "self", ".", "__insert_instance", "(", "index", ",", "inst", ".", "jobject", ")" ]
Adds the specified instance to the dataset. :param inst: the Instance to add :type inst: Instance :param index: the 0-based index where to add the Instance :type index: int
[ "Adds", "the", "specified", "instance", "to", "the", "dataset", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L235-L247
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.set_instance
def set_instance(self, index, inst): """ Sets the Instance at the specified location in the dataset. :param index: the 0-based index of the instance to replace :type index: int :param inst: the Instance to set :type inst: Instance :return: the instance :rtype: Instance """ return Instance( self.__set_instance(index, inst.jobject))
python
def set_instance(self, index, inst): """ Sets the Instance at the specified location in the dataset. :param index: the 0-based index of the instance to replace :type index: int :param inst: the Instance to set :type inst: Instance :return: the instance :rtype: Instance """ return Instance( self.__set_instance(index, inst.jobject))
[ "def", "set_instance", "(", "self", ",", "index", ",", "inst", ")", ":", "return", "Instance", "(", "self", ".", "__set_instance", "(", "index", ",", "inst", ".", "jobject", ")", ")" ]
Sets the Instance at the specified location in the dataset. :param index: the 0-based index of the instance to replace :type index: int :param inst: the Instance to set :type inst: Instance :return: the instance :rtype: Instance
[ "Sets", "the", "Instance", "at", "the", "specified", "location", "in", "the", "dataset", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L249-L261
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.delete
def delete(self, index=None): """ Removes either the specified Instance or all Instance objects. :param index: the 0-based index of the instance to remove :type index: int """ if index is None: javabridge.call(self.jobject, "delete", "()V") else: javabridge.call(self.jobject, "delete", "(I)V", index)
python
def delete(self, index=None): """ Removes either the specified Instance or all Instance objects. :param index: the 0-based index of the instance to remove :type index: int """ if index is None: javabridge.call(self.jobject, "delete", "()V") else: javabridge.call(self.jobject, "delete", "(I)V", index)
[ "def", "delete", "(", "self", ",", "index", "=", "None", ")", ":", "if", "index", "is", "None", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"delete\"", ",", "\"()V\"", ")", "else", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"delete\"", ",", "\"(I)V\"", ",", "index", ")" ]
Removes either the specified Instance or all Instance objects. :param index: the 0-based index of the instance to remove :type index: int
[ "Removes", "either", "the", "specified", "Instance", "or", "all", "Instance", "objects", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L263-L273
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.insert_attribute
def insert_attribute(self, att, index): """ Inserts the attribute at the specified location. :param att: the attribute to insert :type att: Attribute :param index: the index to insert the attribute at :type index: int """ javabridge.call(self.jobject, "insertAttributeAt", "(Lweka/core/Attribute;I)V", att.jobject, index)
python
def insert_attribute(self, att, index): """ Inserts the attribute at the specified location. :param att: the attribute to insert :type att: Attribute :param index: the index to insert the attribute at :type index: int """ javabridge.call(self.jobject, "insertAttributeAt", "(Lweka/core/Attribute;I)V", att.jobject, index)
[ "def", "insert_attribute", "(", "self", ",", "att", ",", "index", ")", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"insertAttributeAt\"", ",", "\"(Lweka/core/Attribute;I)V\"", ",", "att", ".", "jobject", ",", "index", ")" ]
Inserts the attribute at the specified location. :param att: the attribute to insert :type att: Attribute :param index: the index to insert the attribute at :type index: int
[ "Inserts", "the", "attribute", "at", "the", "specified", "location", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L314-L323
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.train_cv
def train_cv(self, num_folds, fold, random=None): """ Generates a training fold for cross-validation. :param num_folds: the number of folds of cross-validation, eg 10 :type num_folds: int :param fold: the current fold (0-based) :type fold: int :param random: the random number generator :type random: Random :return: the training fold :rtype: Instances """ if random is None: return Instances( javabridge.call(self.jobject, "trainCV", "(II)Lweka/core/Instances;", num_folds, fold)) else: return Instances( javabridge.call(self.jobject, "trainCV", "(IILjava/util/Random;)Lweka/core/Instances;", num_folds, fold, random.jobject))
python
def train_cv(self, num_folds, fold, random=None): """ Generates a training fold for cross-validation. :param num_folds: the number of folds of cross-validation, eg 10 :type num_folds: int :param fold: the current fold (0-based) :type fold: int :param random: the random number generator :type random: Random :return: the training fold :rtype: Instances """ if random is None: return Instances( javabridge.call(self.jobject, "trainCV", "(II)Lweka/core/Instances;", num_folds, fold)) else: return Instances( javabridge.call(self.jobject, "trainCV", "(IILjava/util/Random;)Lweka/core/Instances;", num_folds, fold, random.jobject))
[ "def", "train_cv", "(", "self", ",", "num_folds", ",", "fold", ",", "random", "=", "None", ")", ":", "if", "random", "is", "None", ":", "return", "Instances", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"trainCV\"", ",", "\"(II)Lweka/core/Instances;\"", ",", "num_folds", ",", "fold", ")", ")", "else", ":", "return", "Instances", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"trainCV\"", ",", "\"(IILjava/util/Random;)Lweka/core/Instances;\"", ",", "num_folds", ",", "fold", ",", "random", ".", "jobject", ")", ")" ]
Generates a training fold for cross-validation. :param num_folds: the number of folds of cross-validation, eg 10 :type num_folds: int :param fold: the current fold (0-based) :type fold: int :param random: the random number generator :type random: Random :return: the training fold :rtype: Instances
[ "Generates", "a", "training", "fold", "for", "cross", "-", "validation", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L358-L378
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.copy_instances
def copy_instances(cls, dataset, from_row=None, num_rows=None): """ Creates a copy of the Instances. If either from_row or num_rows are None, then all of the data is being copied. :param dataset: the original dataset :type dataset: Instances :param from_row: the 0-based start index of the rows to copy :type from_row: int :param num_rows: the number of rows to copy :type num_rows: int :return: the copy of the data :rtype: Instances """ if from_row is None or num_rows is None: return Instances( javabridge.make_instance( "weka/core/Instances", "(Lweka/core/Instances;)V", dataset.jobject)) else: dataset = cls.copy_instances(dataset) return Instances( javabridge.make_instance( "weka/core/Instances", "(Lweka/core/Instances;II)V", dataset.jobject, from_row, num_rows))
python
def copy_instances(cls, dataset, from_row=None, num_rows=None): """ Creates a copy of the Instances. If either from_row or num_rows are None, then all of the data is being copied. :param dataset: the original dataset :type dataset: Instances :param from_row: the 0-based start index of the rows to copy :type from_row: int :param num_rows: the number of rows to copy :type num_rows: int :return: the copy of the data :rtype: Instances """ if from_row is None or num_rows is None: return Instances( javabridge.make_instance( "weka/core/Instances", "(Lweka/core/Instances;)V", dataset.jobject)) else: dataset = cls.copy_instances(dataset) return Instances( javabridge.make_instance( "weka/core/Instances", "(Lweka/core/Instances;II)V", dataset.jobject, from_row, num_rows))
[ "def", "copy_instances", "(", "cls", ",", "dataset", ",", "from_row", "=", "None", ",", "num_rows", "=", "None", ")", ":", "if", "from_row", "is", "None", "or", "num_rows", "is", "None", ":", "return", "Instances", "(", "javabridge", ".", "make_instance", "(", "\"weka/core/Instances\"", ",", "\"(Lweka/core/Instances;)V\"", ",", "dataset", ".", "jobject", ")", ")", "else", ":", "dataset", "=", "cls", ".", "copy_instances", "(", "dataset", ")", "return", "Instances", "(", "javabridge", ".", "make_instance", "(", "\"weka/core/Instances\"", ",", "\"(Lweka/core/Instances;II)V\"", ",", "dataset", ".", "jobject", ",", "from_row", ",", "num_rows", ")", ")" ]
Creates a copy of the Instances. If either from_row or num_rows are None, then all of the data is being copied. :param dataset: the original dataset :type dataset: Instances :param from_row: the 0-based start index of the rows to copy :type from_row: int :param num_rows: the number of rows to copy :type num_rows: int :return: the copy of the data :rtype: Instances
[ "Creates", "a", "copy", "of", "the", "Instances", ".", "If", "either", "from_row", "or", "num_rows", "are", "None", "then", "all", "of", "the", "data", "is", "being", "copied", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L408-L432
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.template_instances
def template_instances(cls, dataset, capacity=0): """ Uses the Instances as template to create an empty dataset. :param dataset: the original dataset :type dataset: Instances :param capacity: how many data rows to reserve initially (see compactify) :type capacity: int :return: the empty dataset :rtype: Instances """ return Instances( javabridge.make_instance( "weka/core/Instances", "(Lweka/core/Instances;I)V", dataset.jobject, capacity))
python
def template_instances(cls, dataset, capacity=0): """ Uses the Instances as template to create an empty dataset. :param dataset: the original dataset :type dataset: Instances :param capacity: how many data rows to reserve initially (see compactify) :type capacity: int :return: the empty dataset :rtype: Instances """ return Instances( javabridge.make_instance( "weka/core/Instances", "(Lweka/core/Instances;I)V", dataset.jobject, capacity))
[ "def", "template_instances", "(", "cls", ",", "dataset", ",", "capacity", "=", "0", ")", ":", "return", "Instances", "(", "javabridge", ".", "make_instance", "(", "\"weka/core/Instances\"", ",", "\"(Lweka/core/Instances;I)V\"", ",", "dataset", ".", "jobject", ",", "capacity", ")", ")" ]
Uses the Instances as template to create an empty dataset. :param dataset: the original dataset :type dataset: Instances :param capacity: how many data rows to reserve initially (see compactify) :type capacity: int :return: the empty dataset :rtype: Instances
[ "Uses", "the", "Instances", "as", "template", "to", "create", "an", "empty", "dataset", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L435-L448
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.create_instances
def create_instances(cls, name, atts, capacity): """ Creates a new Instances. :param name: the relation name :type name: str :param atts: the list of attributes to use for the dataset :type atts: list of Attribute :param capacity: how many data rows to reserve initially (see compactify) :type capacity: int :return: the dataset :rtype: Instances """ attributes = [] for att in atts: attributes.append(att.jobject) return Instances( javabridge.make_instance( "weka/core/Instances", "(Ljava/lang/String;Ljava/util/ArrayList;I)V", name, javabridge.make_list(attributes), capacity))
python
def create_instances(cls, name, atts, capacity): """ Creates a new Instances. :param name: the relation name :type name: str :param atts: the list of attributes to use for the dataset :type atts: list of Attribute :param capacity: how many data rows to reserve initially (see compactify) :type capacity: int :return: the dataset :rtype: Instances """ attributes = [] for att in atts: attributes.append(att.jobject) return Instances( javabridge.make_instance( "weka/core/Instances", "(Ljava/lang/String;Ljava/util/ArrayList;I)V", name, javabridge.make_list(attributes), capacity))
[ "def", "create_instances", "(", "cls", ",", "name", ",", "atts", ",", "capacity", ")", ":", "attributes", "=", "[", "]", "for", "att", "in", "atts", ":", "attributes", ".", "append", "(", "att", ".", "jobject", ")", "return", "Instances", "(", "javabridge", ".", "make_instance", "(", "\"weka/core/Instances\"", ",", "\"(Ljava/lang/String;Ljava/util/ArrayList;I)V\"", ",", "name", ",", "javabridge", ".", "make_list", "(", "attributes", ")", ",", "capacity", ")", ")" ]
Creates a new Instances. :param name: the relation name :type name: str :param atts: the list of attributes to use for the dataset :type atts: list of Attribute :param capacity: how many data rows to reserve initially (see compactify) :type capacity: int :return: the dataset :rtype: Instances
[ "Creates", "a", "new", "Instances", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L451-L470
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instances.merge_instances
def merge_instances(cls, inst1, inst2): """ Merges the two datasets (side-by-side). :param inst1: the first dataset :type inst1: Instances or str :param inst2: the first dataset :type inst2: Instances :return: the combined dataset :rtype: Instances """ return Instances(javabridge.static_call( "weka/core/Instances", "mergeInstances", "(Lweka/core/Instances;Lweka/core/Instances;)Lweka/core/Instances;", inst1.jobject, inst2.jobject))
python
def merge_instances(cls, inst1, inst2): """ Merges the two datasets (side-by-side). :param inst1: the first dataset :type inst1: Instances or str :param inst2: the first dataset :type inst2: Instances :return: the combined dataset :rtype: Instances """ return Instances(javabridge.static_call( "weka/core/Instances", "mergeInstances", "(Lweka/core/Instances;Lweka/core/Instances;)Lweka/core/Instances;", inst1.jobject, inst2.jobject))
[ "def", "merge_instances", "(", "cls", ",", "inst1", ",", "inst2", ")", ":", "return", "Instances", "(", "javabridge", ".", "static_call", "(", "\"weka/core/Instances\"", ",", "\"mergeInstances\"", ",", "\"(Lweka/core/Instances;Lweka/core/Instances;)Lweka/core/Instances;\"", ",", "inst1", ".", "jobject", ",", "inst2", ".", "jobject", ")", ")" ]
Merges the two datasets (side-by-side). :param inst1: the first dataset :type inst1: Instances or str :param inst2: the first dataset :type inst2: Instances :return: the combined dataset :rtype: Instances
[ "Merges", "the", "two", "datasets", "(", "side", "-", "by", "-", "side", ")", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L473-L486
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instance.dataset
def dataset(self): """ Returns the dataset that this instance belongs to. :return: the dataset or None if no dataset set :rtype: Instances """ dataset = javabridge.call(self.jobject, "dataset", "()Lweka/core/Instances;") if dataset is None: return None else: return Instances(dataset)
python
def dataset(self): """ Returns the dataset that this instance belongs to. :return: the dataset or None if no dataset set :rtype: Instances """ dataset = javabridge.call(self.jobject, "dataset", "()Lweka/core/Instances;") if dataset is None: return None else: return Instances(dataset)
[ "def", "dataset", "(", "self", ")", ":", "dataset", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"dataset\"", ",", "\"()Lweka/core/Instances;\"", ")", "if", "dataset", "is", "None", ":", "return", "None", "else", ":", "return", "Instances", "(", "dataset", ")" ]
Returns the dataset that this instance belongs to. :return: the dataset or None if no dataset set :rtype: Instances
[ "Returns", "the", "dataset", "that", "this", "instance", "belongs", "to", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L577-L588
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instance.set_string_value
def set_string_value(self, index, s): """ Sets the string value at the specified position (0-based). :param index: the 0-based index of the inernal value :type index: int :param s: the string value :type s: str """ return self.__set_string_value(index, javabridge.get_env().new_string(s))
python
def set_string_value(self, index, s): """ Sets the string value at the specified position (0-based). :param index: the 0-based index of the inernal value :type index: int :param s: the string value :type s: str """ return self.__set_string_value(index, javabridge.get_env().new_string(s))
[ "def", "set_string_value", "(", "self", ",", "index", ",", "s", ")", ":", "return", "self", ".", "__set_string_value", "(", "index", ",", "javabridge", ".", "get_env", "(", ")", ".", "new_string", "(", "s", ")", ")" ]
Sets the string value at the specified position (0-based). :param index: the 0-based index of the inernal value :type index: int :param s: the string value :type s: str
[ "Sets", "the", "string", "value", "at", "the", "specified", "position", "(", "0", "-", "based", ")", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L671-L680
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instance.create_instance
def create_instance(cls, values, classname="weka.core.DenseInstance", weight=1.0): """ Creates a new instance. :param values: the float values (internal format) to use, numpy array or list. :type values: ndarray or list :param classname: the classname of the instance (eg weka.core.DenseInstance). :type classname: str :param weight: the weight of the instance :type weight: float """ jni_classname = classname.replace(".", "/") if type(values) is list: for i in range(len(values)): values[i] = float(values[i]) values = numpy.array(values) return Instance( javabridge.make_instance( jni_classname, "(D[D)V", weight, javabridge.get_env().make_double_array(values)))
python
def create_instance(cls, values, classname="weka.core.DenseInstance", weight=1.0): """ Creates a new instance. :param values: the float values (internal format) to use, numpy array or list. :type values: ndarray or list :param classname: the classname of the instance (eg weka.core.DenseInstance). :type classname: str :param weight: the weight of the instance :type weight: float """ jni_classname = classname.replace(".", "/") if type(values) is list: for i in range(len(values)): values[i] = float(values[i]) values = numpy.array(values) return Instance( javabridge.make_instance( jni_classname, "(D[D)V", weight, javabridge.get_env().make_double_array(values)))
[ "def", "create_instance", "(", "cls", ",", "values", ",", "classname", "=", "\"weka.core.DenseInstance\"", ",", "weight", "=", "1.0", ")", ":", "jni_classname", "=", "classname", ".", "replace", "(", "\".\"", ",", "\"/\"", ")", "if", "type", "(", "values", ")", "is", "list", ":", "for", "i", "in", "range", "(", "len", "(", "values", ")", ")", ":", "values", "[", "i", "]", "=", "float", "(", "values", "[", "i", "]", ")", "values", "=", "numpy", ".", "array", "(", "values", ")", "return", "Instance", "(", "javabridge", ".", "make_instance", "(", "jni_classname", ",", "\"(D[D)V\"", ",", "weight", ",", "javabridge", ".", "get_env", "(", ")", ".", "make_double_array", "(", "values", ")", ")", ")" ]
Creates a new instance. :param values: the float values (internal format) to use, numpy array or list. :type values: ndarray or list :param classname: the classname of the instance (eg weka.core.DenseInstance). :type classname: str :param weight: the weight of the instance :type weight: float
[ "Creates", "a", "new", "instance", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L764-L783
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Instance.create_sparse_instance
def create_sparse_instance(cls, values, max_values, classname="weka.core.SparseInstance", weight=1.0): """ Creates a new sparse instance. :param values: the list of tuples (0-based index and internal format float). The indices of the tuples must be in ascending order and "max_values" must be set to the maximum number of attributes in the dataset. :type values: list :param max_values: the maximum number of attributes :type max_values: int :param classname: the classname of the instance (eg weka.core.SparseInstance). :type classname: str :param weight: the weight of the instance :type weight: float """ jni_classname = classname.replace(".", "/") indices = [] vals = [] for (i, v) in values: indices.append(i) vals.append(float(v)) indices = numpy.array(indices, dtype=numpy.int32) vals = numpy.array(vals) return Instance( javabridge.make_instance( jni_classname, "(D[D[II)V", weight, javabridge.get_env().make_double_array(vals), javabridge.get_env().make_int_array(indices), max_values))
python
def create_sparse_instance(cls, values, max_values, classname="weka.core.SparseInstance", weight=1.0): """ Creates a new sparse instance. :param values: the list of tuples (0-based index and internal format float). The indices of the tuples must be in ascending order and "max_values" must be set to the maximum number of attributes in the dataset. :type values: list :param max_values: the maximum number of attributes :type max_values: int :param classname: the classname of the instance (eg weka.core.SparseInstance). :type classname: str :param weight: the weight of the instance :type weight: float """ jni_classname = classname.replace(".", "/") indices = [] vals = [] for (i, v) in values: indices.append(i) vals.append(float(v)) indices = numpy.array(indices, dtype=numpy.int32) vals = numpy.array(vals) return Instance( javabridge.make_instance( jni_classname, "(D[D[II)V", weight, javabridge.get_env().make_double_array(vals), javabridge.get_env().make_int_array(indices), max_values))
[ "def", "create_sparse_instance", "(", "cls", ",", "values", ",", "max_values", ",", "classname", "=", "\"weka.core.SparseInstance\"", ",", "weight", "=", "1.0", ")", ":", "jni_classname", "=", "classname", ".", "replace", "(", "\".\"", ",", "\"/\"", ")", "indices", "=", "[", "]", "vals", "=", "[", "]", "for", "(", "i", ",", "v", ")", "in", "values", ":", "indices", ".", "append", "(", "i", ")", "vals", ".", "append", "(", "float", "(", "v", ")", ")", "indices", "=", "numpy", ".", "array", "(", "indices", ",", "dtype", "=", "numpy", ".", "int32", ")", "vals", "=", "numpy", ".", "array", "(", "vals", ")", "return", "Instance", "(", "javabridge", ".", "make_instance", "(", "jni_classname", ",", "\"(D[D[II)V\"", ",", "weight", ",", "javabridge", ".", "get_env", "(", ")", ".", "make_double_array", "(", "vals", ")", ",", "javabridge", ".", "get_env", "(", ")", ".", "make_int_array", "(", "indices", ")", ",", "max_values", ")", ")" ]
Creates a new sparse instance. :param values: the list of tuples (0-based index and internal format float). The indices of the tuples must be in ascending order and "max_values" must be set to the maximum number of attributes in the dataset. :type values: list :param max_values: the maximum number of attributes :type max_values: int :param classname: the classname of the instance (eg weka.core.SparseInstance). :type classname: str :param weight: the weight of the instance :type weight: float
[ "Creates", "a", "new", "sparse", "instance", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L786-L813
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Attribute.values
def values(self): """ Returns the labels, strings or relation-values. :return: all the values, None if not NOMINAL, STRING, or RELATION :rtype: list """ enm = javabridge.call(self.jobject, "enumerateValues", "()Ljava/util/Enumeration;") if enm is None: return None else: return typeconv.enumeration_to_list(enm)
python
def values(self): """ Returns the labels, strings or relation-values. :return: all the values, None if not NOMINAL, STRING, or RELATION :rtype: list """ enm = javabridge.call(self.jobject, "enumerateValues", "()Ljava/util/Enumeration;") if enm is None: return None else: return typeconv.enumeration_to_list(enm)
[ "def", "values", "(", "self", ")", ":", "enm", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"enumerateValues\"", ",", "\"()Ljava/util/Enumeration;\"", ")", "if", "enm", "is", "None", ":", "return", "None", "else", ":", "return", "typeconv", ".", "enumeration_to_list", "(", "enm", ")" ]
Returns the labels, strings or relation-values. :return: all the values, None if not NOMINAL, STRING, or RELATION :rtype: list
[ "Returns", "the", "labels", "strings", "or", "relation", "-", "values", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L913-L924
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Attribute.type_str
def type_str(self, short=False): """ Returns the type of the attribute as string. :return: the type :rtype: str """ if short: return javabridge.static_call( "weka/core/Attribute", "typeToStringShort", "(Lweka/core/Attribute;)Ljava/lang/String;", self.jobject) else: return javabridge.static_call( "weka/core/Attribute", "typeToString", "(Lweka/core/Attribute;)Ljava/lang/String;", self.jobject)
python
def type_str(self, short=False): """ Returns the type of the attribute as string. :return: the type :rtype: str """ if short: return javabridge.static_call( "weka/core/Attribute", "typeToStringShort", "(Lweka/core/Attribute;)Ljava/lang/String;", self.jobject) else: return javabridge.static_call( "weka/core/Attribute", "typeToString", "(Lweka/core/Attribute;)Ljava/lang/String;", self.jobject)
[ "def", "type_str", "(", "self", ",", "short", "=", "False", ")", ":", "if", "short", ":", "return", "javabridge", ".", "static_call", "(", "\"weka/core/Attribute\"", ",", "\"typeToStringShort\"", ",", "\"(Lweka/core/Attribute;)Ljava/lang/String;\"", ",", "self", ".", "jobject", ")", "else", ":", "return", "javabridge", ".", "static_call", "(", "\"weka/core/Attribute\"", ",", "\"typeToString\"", ",", "\"(Lweka/core/Attribute;)Ljava/lang/String;\"", ",", "self", ".", "jobject", ")" ]
Returns the type of the attribute as string. :return: the type :rtype: str
[ "Returns", "the", "type", "of", "the", "attribute", "as", "string", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L946-L960
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Attribute.copy
def copy(self, name=None): """ Creates a copy of this attribute. :param name: the new name, uses the old one if None :type name: str :return: the copy of the attribute :rtype: Attribute """ if name is None: return Attribute( javabridge.call(self.jobject, "copy", "()Ljava/lang/Object;")) else: return Attribute( javabridge.call(self.jobject, "copy", "(Ljava/lang/String;)Lweka/core/Attribute;", name))
python
def copy(self, name=None): """ Creates a copy of this attribute. :param name: the new name, uses the old one if None :type name: str :return: the copy of the attribute :rtype: Attribute """ if name is None: return Attribute( javabridge.call(self.jobject, "copy", "()Ljava/lang/Object;")) else: return Attribute( javabridge.call(self.jobject, "copy", "(Ljava/lang/String;)Lweka/core/Attribute;", name))
[ "def", "copy", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "return", "Attribute", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"copy\"", ",", "\"()Ljava/lang/Object;\"", ")", ")", "else", ":", "return", "Attribute", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"copy\"", ",", "\"(Ljava/lang/String;)Lweka/core/Attribute;\"", ",", "name", ")", ")" ]
Creates a copy of this attribute. :param name: the new name, uses the old one if None :type name: str :return: the copy of the attribute :rtype: Attribute
[ "Creates", "a", "copy", "of", "this", "attribute", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L1119-L1133
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Attribute.create_nominal
def create_nominal(cls, name, labels): """ Creates a nominal attribute. :param name: the name of the attribute :type name: str :param labels: the list of string labels to use :type labels: list """ return Attribute( javabridge.make_instance( "weka/core/Attribute", "(Ljava/lang/String;Ljava/util/List;)V", name, javabridge.make_list(labels)))
python
def create_nominal(cls, name, labels): """ Creates a nominal attribute. :param name: the name of the attribute :type name: str :param labels: the list of string labels to use :type labels: list """ return Attribute( javabridge.make_instance( "weka/core/Attribute", "(Ljava/lang/String;Ljava/util/List;)V", name, javabridge.make_list(labels)))
[ "def", "create_nominal", "(", "cls", ",", "name", ",", "labels", ")", ":", "return", "Attribute", "(", "javabridge", ".", "make_instance", "(", "\"weka/core/Attribute\"", ",", "\"(Ljava/lang/String;Ljava/util/List;)V\"", ",", "name", ",", "javabridge", ".", "make_list", "(", "labels", ")", ")", ")" ]
Creates a nominal attribute. :param name: the name of the attribute :type name: str :param labels: the list of string labels to use :type labels: list
[ "Creates", "a", "nominal", "attribute", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L1162-L1173
fracpete/python-weka-wrapper3
python/weka/core/dataset.py
Attribute.create_relational
def create_relational(cls, name, inst): """ Creates a relational attribute. :param name: the name of the attribute :type name: str :param inst: the structure of the relational attribute :type inst: Instances """ return Attribute( javabridge.make_instance( "weka/core/Attribute", "(Ljava/lang/String;Lweka/core/Instances;)V", name, inst.jobject))
python
def create_relational(cls, name, inst): """ Creates a relational attribute. :param name: the name of the attribute :type name: str :param inst: the structure of the relational attribute :type inst: Instances """ return Attribute( javabridge.make_instance( "weka/core/Attribute", "(Ljava/lang/String;Lweka/core/Instances;)V", name, inst.jobject))
[ "def", "create_relational", "(", "cls", ",", "name", ",", "inst", ")", ":", "return", "Attribute", "(", "javabridge", ".", "make_instance", "(", "\"weka/core/Attribute\"", ",", "\"(Ljava/lang/String;Lweka/core/Instances;)V\"", ",", "name", ",", "inst", ".", "jobject", ")", ")" ]
Creates a relational attribute. :param name: the name of the attribute :type name: str :param inst: the structure of the relational attribute :type inst: Instances
[ "Creates", "a", "relational", "attribute", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/dataset.py#L1188-L1199
fracpete/python-weka-wrapper3
python/weka/core/jvm.py
add_bundled_jars
def add_bundled_jars(): """ Adds the bundled jars to the JVM's classpath. """ # determine lib directory with jars rootdir = os.path.split(os.path.dirname(__file__))[0] libdir = rootdir + os.sep + "lib" # add jars from lib directory for l in glob.glob(libdir + os.sep + "*.jar"): if l.lower().find("-src.") == -1: javabridge.JARS.append(str(l))
python
def add_bundled_jars(): """ Adds the bundled jars to the JVM's classpath. """ # determine lib directory with jars rootdir = os.path.split(os.path.dirname(__file__))[0] libdir = rootdir + os.sep + "lib" # add jars from lib directory for l in glob.glob(libdir + os.sep + "*.jar"): if l.lower().find("-src.") == -1: javabridge.JARS.append(str(l))
[ "def", "add_bundled_jars", "(", ")", ":", "# determine lib directory with jars", "rootdir", "=", "os", ".", "path", ".", "split", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "[", "0", "]", "libdir", "=", "rootdir", "+", "os", ".", "sep", "+", "\"lib\"", "# add jars from lib directory", "for", "l", "in", "glob", ".", "glob", "(", "libdir", "+", "os", ".", "sep", "+", "\"*.jar\"", ")", ":", "if", "l", ".", "lower", "(", ")", ".", "find", "(", "\"-src.\"", ")", "==", "-", "1", ":", "javabridge", ".", "JARS", ".", "append", "(", "str", "(", "l", ")", ")" ]
Adds the bundled jars to the JVM's classpath.
[ "Adds", "the", "bundled", "jars", "to", "the", "JVM", "s", "classpath", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/jvm.py#L31-L42
fracpete/python-weka-wrapper3
python/weka/core/jvm.py
add_system_classpath
def add_system_classpath(): """ Adds the system's classpath to the JVM's classpath. """ if 'CLASSPATH' in os.environ: parts = os.environ['CLASSPATH'].split(os.pathsep) for part in parts: javabridge.JARS.append(part)
python
def add_system_classpath(): """ Adds the system's classpath to the JVM's classpath. """ if 'CLASSPATH' in os.environ: parts = os.environ['CLASSPATH'].split(os.pathsep) for part in parts: javabridge.JARS.append(part)
[ "def", "add_system_classpath", "(", ")", ":", "if", "'CLASSPATH'", "in", "os", ".", "environ", ":", "parts", "=", "os", ".", "environ", "[", "'CLASSPATH'", "]", ".", "split", "(", "os", ".", "pathsep", ")", "for", "part", "in", "parts", ":", "javabridge", ".", "JARS", ".", "append", "(", "part", ")" ]
Adds the system's classpath to the JVM's classpath.
[ "Adds", "the", "system", "s", "classpath", "to", "the", "JVM", "s", "classpath", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/jvm.py#L45-L52
fracpete/python-weka-wrapper3
python/weka/core/jvm.py
start
def start(class_path=None, bundled=True, packages=False, system_cp=False, max_heap_size=None): """ Initializes the javabridge connection (starts up the JVM). :param class_path: the additional classpath elements to add :type class_path: list :param bundled: whether to add jars from the "lib" directory :type bundled: bool :param packages: whether to add jars from Weka packages as well (bool) or an alternative Weka home directory (str) :type packages: bool or str :param system_cp: whether to add the system classpath as well :type system_cp: bool :param max_heap_size: the maximum heap size (-Xmx parameter, eg 512m or 4g) :type max_heap_size: str """ global started if started is not None: logger.info("JVM already running, call jvm.stop() first") return # add user-defined jars first if class_path is not None: for cp in class_path: logger.debug("Adding user-supplied classpath=" + cp) javabridge.JARS.append(cp) if bundled: logger.debug("Adding bundled jars") add_bundled_jars() if system_cp: logger.debug("Adding system classpath") add_system_classpath() logger.debug("Classpath=" + str(javabridge.JARS)) logger.debug("MaxHeapSize=" + ("default" if (max_heap_size is None) else max_heap_size)) args = [] weka_home = None if packages is not None: if isinstance(packages, bool): if packages: logger.debug("Package support enabled") else: logger.debug("Package support disabled") args.append("-Dweka.packageManager.loadPackages=false") if isinstance(packages, str): if os.path.exists(packages) and os.path.isdir(packages): logger.debug("Using alternative Weka home directory: " + packages) weka_home = packages else: logger.warning("Invalid Weka home: " + packages) javabridge.start_vm(args=args, run_headless=True, max_heap_size=max_heap_size) javabridge.attach() started = True if weka_home is not None: from weka.core.classes import Environment env = Environment.system_wide() logger.debug("Using alternative Weka home directory: " + packages) env.add_variable("WEKA_HOME", weka_home) # initialize package manager javabridge.static_call( "Lweka/core/WekaPackageManager;", "loadPackages", "(Z)V", False)
python
def start(class_path=None, bundled=True, packages=False, system_cp=False, max_heap_size=None): """ Initializes the javabridge connection (starts up the JVM). :param class_path: the additional classpath elements to add :type class_path: list :param bundled: whether to add jars from the "lib" directory :type bundled: bool :param packages: whether to add jars from Weka packages as well (bool) or an alternative Weka home directory (str) :type packages: bool or str :param system_cp: whether to add the system classpath as well :type system_cp: bool :param max_heap_size: the maximum heap size (-Xmx parameter, eg 512m or 4g) :type max_heap_size: str """ global started if started is not None: logger.info("JVM already running, call jvm.stop() first") return # add user-defined jars first if class_path is not None: for cp in class_path: logger.debug("Adding user-supplied classpath=" + cp) javabridge.JARS.append(cp) if bundled: logger.debug("Adding bundled jars") add_bundled_jars() if system_cp: logger.debug("Adding system classpath") add_system_classpath() logger.debug("Classpath=" + str(javabridge.JARS)) logger.debug("MaxHeapSize=" + ("default" if (max_heap_size is None) else max_heap_size)) args = [] weka_home = None if packages is not None: if isinstance(packages, bool): if packages: logger.debug("Package support enabled") else: logger.debug("Package support disabled") args.append("-Dweka.packageManager.loadPackages=false") if isinstance(packages, str): if os.path.exists(packages) and os.path.isdir(packages): logger.debug("Using alternative Weka home directory: " + packages) weka_home = packages else: logger.warning("Invalid Weka home: " + packages) javabridge.start_vm(args=args, run_headless=True, max_heap_size=max_heap_size) javabridge.attach() started = True if weka_home is not None: from weka.core.classes import Environment env = Environment.system_wide() logger.debug("Using alternative Weka home directory: " + packages) env.add_variable("WEKA_HOME", weka_home) # initialize package manager javabridge.static_call( "Lweka/core/WekaPackageManager;", "loadPackages", "(Z)V", False)
[ "def", "start", "(", "class_path", "=", "None", ",", "bundled", "=", "True", ",", "packages", "=", "False", ",", "system_cp", "=", "False", ",", "max_heap_size", "=", "None", ")", ":", "global", "started", "if", "started", "is", "not", "None", ":", "logger", ".", "info", "(", "\"JVM already running, call jvm.stop() first\"", ")", "return", "# add user-defined jars first", "if", "class_path", "is", "not", "None", ":", "for", "cp", "in", "class_path", ":", "logger", ".", "debug", "(", "\"Adding user-supplied classpath=\"", "+", "cp", ")", "javabridge", ".", "JARS", ".", "append", "(", "cp", ")", "if", "bundled", ":", "logger", ".", "debug", "(", "\"Adding bundled jars\"", ")", "add_bundled_jars", "(", ")", "if", "system_cp", ":", "logger", ".", "debug", "(", "\"Adding system classpath\"", ")", "add_system_classpath", "(", ")", "logger", ".", "debug", "(", "\"Classpath=\"", "+", "str", "(", "javabridge", ".", "JARS", ")", ")", "logger", ".", "debug", "(", "\"MaxHeapSize=\"", "+", "(", "\"default\"", "if", "(", "max_heap_size", "is", "None", ")", "else", "max_heap_size", ")", ")", "args", "=", "[", "]", "weka_home", "=", "None", "if", "packages", "is", "not", "None", ":", "if", "isinstance", "(", "packages", ",", "bool", ")", ":", "if", "packages", ":", "logger", ".", "debug", "(", "\"Package support enabled\"", ")", "else", ":", "logger", ".", "debug", "(", "\"Package support disabled\"", ")", "args", ".", "append", "(", "\"-Dweka.packageManager.loadPackages=false\"", ")", "if", "isinstance", "(", "packages", ",", "str", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "packages", ")", "and", "os", ".", "path", ".", "isdir", "(", "packages", ")", ":", "logger", ".", "debug", "(", "\"Using alternative Weka home directory: \"", "+", "packages", ")", "weka_home", "=", "packages", "else", ":", "logger", ".", "warning", "(", "\"Invalid Weka home: \"", "+", "packages", ")", "javabridge", ".", "start_vm", "(", "args", "=", "args", ",", "run_headless", "=", "True", ",", "max_heap_size", "=", "max_heap_size", ")", "javabridge", ".", "attach", "(", ")", "started", "=", "True", "if", "weka_home", "is", "not", "None", ":", "from", "weka", ".", "core", ".", "classes", "import", "Environment", "env", "=", "Environment", ".", "system_wide", "(", ")", "logger", ".", "debug", "(", "\"Using alternative Weka home directory: \"", "+", "packages", ")", "env", ".", "add_variable", "(", "\"WEKA_HOME\"", ",", "weka_home", ")", "# initialize package manager", "javabridge", ".", "static_call", "(", "\"Lweka/core/WekaPackageManager;\"", ",", "\"loadPackages\"", ",", "\"(Z)V\"", ",", "False", ")" ]
Initializes the javabridge connection (starts up the JVM). :param class_path: the additional classpath elements to add :type class_path: list :param bundled: whether to add jars from the "lib" directory :type bundled: bool :param packages: whether to add jars from Weka packages as well (bool) or an alternative Weka home directory (str) :type packages: bool or str :param system_cp: whether to add the system classpath as well :type system_cp: bool :param max_heap_size: the maximum heap size (-Xmx parameter, eg 512m or 4g) :type max_heap_size: str
[ "Initializes", "the", "javabridge", "connection", "(", "starts", "up", "the", "JVM", ")", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/jvm.py#L55-L123
fracpete/python-weka-wrapper3
python/weka/core/classes.py
get_class
def get_class(classname): """ Returns the class object associated with the dot-notation classname. Taken from here: http://stackoverflow.com/a/452981 :param classname: the classname :type classname: str :return: the class object :rtype: object """ parts = classname.split('.') module = ".".join(parts[:-1]) m = __import__(module) for comp in parts[1:]: m = getattr(m, comp) return m
python
def get_class(classname): """ Returns the class object associated with the dot-notation classname. Taken from here: http://stackoverflow.com/a/452981 :param classname: the classname :type classname: str :return: the class object :rtype: object """ parts = classname.split('.') module = ".".join(parts[:-1]) m = __import__(module) for comp in parts[1:]: m = getattr(m, comp) return m
[ "def", "get_class", "(", "classname", ")", ":", "parts", "=", "classname", ".", "split", "(", "'.'", ")", "module", "=", "\".\"", ".", "join", "(", "parts", "[", ":", "-", "1", "]", ")", "m", "=", "__import__", "(", "module", ")", "for", "comp", "in", "parts", "[", "1", ":", "]", ":", "m", "=", "getattr", "(", "m", ",", "comp", ")", "return", "m" ]
Returns the class object associated with the dot-notation classname. Taken from here: http://stackoverflow.com/a/452981 :param classname: the classname :type classname: str :return: the class object :rtype: object
[ "Returns", "the", "class", "object", "associated", "with", "the", "dot", "-", "notation", "classname", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L33-L49
fracpete/python-weka-wrapper3
python/weka/core/classes.py
get_jclass
def get_jclass(classname): """ Returns the Java class object associated with the dot-notation classname. :param classname: the classname :type classname: str :return: the class object :rtype: JB_Object """ try: return javabridge.class_for_name(classname) except: return javabridge.static_call( "Lweka/core/ClassHelper;", "forName", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Class;", javabridge.class_for_name("java.lang.Object"), classname)
python
def get_jclass(classname): """ Returns the Java class object associated with the dot-notation classname. :param classname: the classname :type classname: str :return: the class object :rtype: JB_Object """ try: return javabridge.class_for_name(classname) except: return javabridge.static_call( "Lweka/core/ClassHelper;", "forName", "(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Class;", javabridge.class_for_name("java.lang.Object"), classname)
[ "def", "get_jclass", "(", "classname", ")", ":", "try", ":", "return", "javabridge", ".", "class_for_name", "(", "classname", ")", "except", ":", "return", "javabridge", ".", "static_call", "(", "\"Lweka/core/ClassHelper;\"", ",", "\"forName\"", ",", "\"(Ljava/lang/Class;Ljava/lang/String;)Ljava/lang/Class;\"", ",", "javabridge", ".", "class_for_name", "(", "\"java.lang.Object\"", ")", ",", "classname", ")" ]
Returns the Java class object associated with the dot-notation classname. :param classname: the classname :type classname: str :return: the class object :rtype: JB_Object
[ "Returns", "the", "Java", "class", "object", "associated", "with", "the", "dot", "-", "notation", "classname", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L52-L67
fracpete/python-weka-wrapper3
python/weka/core/classes.py
get_static_field
def get_static_field(classname, fieldname, signature): """ Returns the Java object associated with the static field of the specified class. :param classname: the classname of the class to get the field from :type classname: str :param fieldname: the name of the field to retriev :type fieldname: str :return: the object :rtype: JB_Object """ try: return javabridge.get_static_field(classname, fieldname, signature) except: return javabridge.static_call( "Lweka/core/ClassHelper;", "getStaticField", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;", classname, fieldname)
python
def get_static_field(classname, fieldname, signature): """ Returns the Java object associated with the static field of the specified class. :param classname: the classname of the class to get the field from :type classname: str :param fieldname: the name of the field to retriev :type fieldname: str :return: the object :rtype: JB_Object """ try: return javabridge.get_static_field(classname, fieldname, signature) except: return javabridge.static_call( "Lweka/core/ClassHelper;", "getStaticField", "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;", classname, fieldname)
[ "def", "get_static_field", "(", "classname", ",", "fieldname", ",", "signature", ")", ":", "try", ":", "return", "javabridge", ".", "get_static_field", "(", "classname", ",", "fieldname", ",", "signature", ")", "except", ":", "return", "javabridge", ".", "static_call", "(", "\"Lweka/core/ClassHelper;\"", ",", "\"getStaticField\"", ",", "\"(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;\"", ",", "classname", ",", "fieldname", ")" ]
Returns the Java object associated with the static field of the specified class. :param classname: the classname of the class to get the field from :type classname: str :param fieldname: the name of the field to retriev :type fieldname: str :return: the object :rtype: JB_Object
[ "Returns", "the", "Java", "object", "associated", "with", "the", "static", "field", "of", "the", "specified", "class", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L70-L87
fracpete/python-weka-wrapper3
python/weka/core/classes.py
get_classname
def get_classname(obj): """ Returns the classname of the JB_Object, Python class or object. :param obj: the java object or Python class/object to get the classname for :type obj: object :return: the classname :rtype: str """ if isinstance(obj, javabridge.JB_Object): cls = javabridge.call(obj, "getClass", "()Ljava/lang/Class;") return javabridge.call(cls, "getName", "()Ljava/lang/String;") elif inspect.isclass(obj): return obj.__module__ + "." + obj.__name__ else: return get_classname(obj.__class__)
python
def get_classname(obj): """ Returns the classname of the JB_Object, Python class or object. :param obj: the java object or Python class/object to get the classname for :type obj: object :return: the classname :rtype: str """ if isinstance(obj, javabridge.JB_Object): cls = javabridge.call(obj, "getClass", "()Ljava/lang/Class;") return javabridge.call(cls, "getName", "()Ljava/lang/String;") elif inspect.isclass(obj): return obj.__module__ + "." + obj.__name__ else: return get_classname(obj.__class__)
[ "def", "get_classname", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "javabridge", ".", "JB_Object", ")", ":", "cls", "=", "javabridge", ".", "call", "(", "obj", ",", "\"getClass\"", ",", "\"()Ljava/lang/Class;\"", ")", "return", "javabridge", ".", "call", "(", "cls", ",", "\"getName\"", ",", "\"()Ljava/lang/String;\"", ")", "elif", "inspect", ".", "isclass", "(", "obj", ")", ":", "return", "obj", ".", "__module__", "+", "\".\"", "+", "obj", ".", "__name__", "else", ":", "return", "get_classname", "(", "obj", ".", "__class__", ")" ]
Returns the classname of the JB_Object, Python class or object. :param obj: the java object or Python class/object to get the classname for :type obj: object :return: the classname :rtype: str
[ "Returns", "the", "classname", "of", "the", "JB_Object", "Python", "class", "or", "object", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L90-L105
fracpete/python-weka-wrapper3
python/weka/core/classes.py
is_instance_of
def is_instance_of(obj, class_or_intf_name): """ Checks whether the Java object implements the specified interface or is a subclass of the superclass. :param obj: the Java object to check :type obj: JB_Object :param class_or_intf_name: the superclass or interface to check, dot notation or with forward slashes :type class_or_intf_name: str :return: true if either implements interface or subclass of superclass :rtype: bool """ class_or_intf_name = class_or_intf_name.replace("/", ".") classname = get_classname(obj) # array? retrieve component type and check that if is_array(obj): jarray = JavaArray(jobject=obj) classname = jarray.component_type() result = javabridge.static_call( "Lweka/core/InheritanceUtils;", "isSubclass", "(Ljava/lang/String;Ljava/lang/String;)Z", class_or_intf_name, classname) if result: return True return javabridge.static_call( "Lweka/core/InheritanceUtils;", "hasInterface", "(Ljava/lang/String;Ljava/lang/String;)Z", class_or_intf_name, classname)
python
def is_instance_of(obj, class_or_intf_name): """ Checks whether the Java object implements the specified interface or is a subclass of the superclass. :param obj: the Java object to check :type obj: JB_Object :param class_or_intf_name: the superclass or interface to check, dot notation or with forward slashes :type class_or_intf_name: str :return: true if either implements interface or subclass of superclass :rtype: bool """ class_or_intf_name = class_or_intf_name.replace("/", ".") classname = get_classname(obj) # array? retrieve component type and check that if is_array(obj): jarray = JavaArray(jobject=obj) classname = jarray.component_type() result = javabridge.static_call( "Lweka/core/InheritanceUtils;", "isSubclass", "(Ljava/lang/String;Ljava/lang/String;)Z", class_or_intf_name, classname) if result: return True return javabridge.static_call( "Lweka/core/InheritanceUtils;", "hasInterface", "(Ljava/lang/String;Ljava/lang/String;)Z", class_or_intf_name, classname)
[ "def", "is_instance_of", "(", "obj", ",", "class_or_intf_name", ")", ":", "class_or_intf_name", "=", "class_or_intf_name", ".", "replace", "(", "\"/\"", ",", "\".\"", ")", "classname", "=", "get_classname", "(", "obj", ")", "# array? retrieve component type and check that", "if", "is_array", "(", "obj", ")", ":", "jarray", "=", "JavaArray", "(", "jobject", "=", "obj", ")", "classname", "=", "jarray", ".", "component_type", "(", ")", "result", "=", "javabridge", ".", "static_call", "(", "\"Lweka/core/InheritanceUtils;\"", ",", "\"isSubclass\"", ",", "\"(Ljava/lang/String;Ljava/lang/String;)Z\"", ",", "class_or_intf_name", ",", "classname", ")", "if", "result", ":", "return", "True", "return", "javabridge", ".", "static_call", "(", "\"Lweka/core/InheritanceUtils;\"", ",", "\"hasInterface\"", ",", "\"(Ljava/lang/String;Ljava/lang/String;)Z\"", ",", "class_or_intf_name", ",", "classname", ")" ]
Checks whether the Java object implements the specified interface or is a subclass of the superclass. :param obj: the Java object to check :type obj: JB_Object :param class_or_intf_name: the superclass or interface to check, dot notation or with forward slashes :type class_or_intf_name: str :return: true if either implements interface or subclass of superclass :rtype: bool
[ "Checks", "whether", "the", "Java", "object", "implements", "the", "specified", "interface", "or", "is", "a", "subclass", "of", "the", "superclass", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L108-L134
fracpete/python-weka-wrapper3
python/weka/core/classes.py
from_commandline
def from_commandline(cmdline, classname=None): """ Creates an OptionHandler based on the provided commandline string. :param cmdline: the commandline string to use :type cmdline: str :param classname: the classname of the wrapper to return other than OptionHandler (in dot-notation) :type classname: str :return: the generated option handler instance :rtype: object """ params = split_options(cmdline) cls = params[0] params = params[1:] handler = OptionHandler(javabridge.static_call( "Lweka/core/Utils;", "forName", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;", javabridge.class_for_name("java.lang.Object"), cls, params)) if classname is None: return handler else: c = get_class(classname) return c(jobject=handler.jobject)
python
def from_commandline(cmdline, classname=None): """ Creates an OptionHandler based on the provided commandline string. :param cmdline: the commandline string to use :type cmdline: str :param classname: the classname of the wrapper to return other than OptionHandler (in dot-notation) :type classname: str :return: the generated option handler instance :rtype: object """ params = split_options(cmdline) cls = params[0] params = params[1:] handler = OptionHandler(javabridge.static_call( "Lweka/core/Utils;", "forName", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;", javabridge.class_for_name("java.lang.Object"), cls, params)) if classname is None: return handler else: c = get_class(classname) return c(jobject=handler.jobject)
[ "def", "from_commandline", "(", "cmdline", ",", "classname", "=", "None", ")", ":", "params", "=", "split_options", "(", "cmdline", ")", "cls", "=", "params", "[", "0", "]", "params", "=", "params", "[", "1", ":", "]", "handler", "=", "OptionHandler", "(", "javabridge", ".", "static_call", "(", "\"Lweka/core/Utils;\"", ",", "\"forName\"", ",", "\"(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;\"", ",", "javabridge", ".", "class_for_name", "(", "\"java.lang.Object\"", ")", ",", "cls", ",", "params", ")", ")", "if", "classname", "is", "None", ":", "return", "handler", "else", ":", "c", "=", "get_class", "(", "classname", ")", "return", "c", "(", "jobject", "=", "handler", ".", "jobject", ")" ]
Creates an OptionHandler based on the provided commandline string. :param cmdline: the commandline string to use :type cmdline: str :param classname: the classname of the wrapper to return other than OptionHandler (in dot-notation) :type classname: str :return: the generated option handler instance :rtype: object
[ "Creates", "an", "OptionHandler", "based", "on", "the", "provided", "commandline", "string", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1683-L1705
fracpete/python-weka-wrapper3
python/weka/core/classes.py
complete_classname
def complete_classname(classname): """ Attempts to complete a partial classname like '.J48' and returns the full classname if a single match was found, otherwise an exception is raised. :param classname: the partial classname to expand :type classname: str :return: the full classname :rtype: str """ result = javabridge.get_collection_wrapper( javabridge.static_call( "Lweka/Run;", "findSchemeMatch", "(Ljava/lang/String;Z)Ljava/util/List;", classname, True)) if len(result) == 1: return str(result[0]) elif len(result) == 0: raise Exception("No classname matches found for: " + classname) else: matches = [] for i in range(len(result)): matches.append(str(result[i])) raise Exception("Found multiple matches for '" + classname + "':\n" + '\n'.join(matches))
python
def complete_classname(classname): """ Attempts to complete a partial classname like '.J48' and returns the full classname if a single match was found, otherwise an exception is raised. :param classname: the partial classname to expand :type classname: str :return: the full classname :rtype: str """ result = javabridge.get_collection_wrapper( javabridge.static_call( "Lweka/Run;", "findSchemeMatch", "(Ljava/lang/String;Z)Ljava/util/List;", classname, True)) if len(result) == 1: return str(result[0]) elif len(result) == 0: raise Exception("No classname matches found for: " + classname) else: matches = [] for i in range(len(result)): matches.append(str(result[i])) raise Exception("Found multiple matches for '" + classname + "':\n" + '\n'.join(matches))
[ "def", "complete_classname", "(", "classname", ")", ":", "result", "=", "javabridge", ".", "get_collection_wrapper", "(", "javabridge", ".", "static_call", "(", "\"Lweka/Run;\"", ",", "\"findSchemeMatch\"", ",", "\"(Ljava/lang/String;Z)Ljava/util/List;\"", ",", "classname", ",", "True", ")", ")", "if", "len", "(", "result", ")", "==", "1", ":", "return", "str", "(", "result", "[", "0", "]", ")", "elif", "len", "(", "result", ")", "==", "0", ":", "raise", "Exception", "(", "\"No classname matches found for: \"", "+", "classname", ")", "else", ":", "matches", "=", "[", "]", "for", "i", "in", "range", "(", "len", "(", "result", ")", ")", ":", "matches", ".", "append", "(", "str", "(", "result", "[", "i", "]", ")", ")", "raise", "Exception", "(", "\"Found multiple matches for '\"", "+", "classname", "+", "\"':\\n\"", "+", "'\\n'", ".", "join", "(", "matches", ")", ")" ]
Attempts to complete a partial classname like '.J48' and returns the full classname if a single match was found, otherwise an exception is raised. :param classname: the partial classname to expand :type classname: str :return: the full classname :rtype: str
[ "Attempts", "to", "complete", "a", "partial", "classname", "like", ".", "J48", "and", "returns", "the", "full", "classname", "if", "a", "single", "match", "was", "found", "otherwise", "an", "exception", "is", "raised", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1708-L1732
fracpete/python-weka-wrapper3
python/weka/core/classes.py
main
def main(): """ Runs a classifier from the command-line. Calls JVM start/stop automatically. Use -h to see all options. """ parser = argparse.ArgumentParser( description='Performs option handling operations from the command-line. Calls JVM start/stop automatically.') parser.add_argument("-j", metavar="classpath", dest="classpath", help="additional classpath, jars/directories") parser.add_argument("-action", metavar="action", dest="action", required=True, help="The action to perform on the options: join=create single string, "\ "split=create array from quoted option, code=generate code from options") parser.add_argument("option", nargs=argparse.REMAINDER, help="The option(s) to process") parsed = parser.parse_args() jars = [] if parsed.classpath is not None: jars = parsed.classpath.split(os.pathsep) jvm.start(jars, packages=True) try: if parsed.action == "join": output = "cmdline = \"" + backquote(join_options(parsed.option)) + "\"" elif parsed.action == "split" and len(parsed.option) == 1: output = "options = [\n" opts = split_options(parsed.option[0]) for idx, opt in enumerate(opts): if idx > 0: output += ",\n" output += " \"" + backquote(opt) + "\"" output += "]" elif parsed.action == "code": options = parsed.option[:] cname = None # classname + options? if options[0].find(".") > -1: cname = options[0] options = options[1:] output = "options = [ \n" for idx, opt in enumerate(options): if idx > 0: output += ",\n" output += " \"" + backquote(opt) + "\"" output += "]\n" if cname is not None: output += 'handler = OptionHandler(JavaObject.new_instance("' + cname + '"))\n' output += 'handler.options = options\n' else: raise Exception("Unsupported action: " + parsed.action) if output is not None: print(output) except Exception as e: print(e) finally: jvm.stop()
python
def main(): """ Runs a classifier from the command-line. Calls JVM start/stop automatically. Use -h to see all options. """ parser = argparse.ArgumentParser( description='Performs option handling operations from the command-line. Calls JVM start/stop automatically.') parser.add_argument("-j", metavar="classpath", dest="classpath", help="additional classpath, jars/directories") parser.add_argument("-action", metavar="action", dest="action", required=True, help="The action to perform on the options: join=create single string, "\ "split=create array from quoted option, code=generate code from options") parser.add_argument("option", nargs=argparse.REMAINDER, help="The option(s) to process") parsed = parser.parse_args() jars = [] if parsed.classpath is not None: jars = parsed.classpath.split(os.pathsep) jvm.start(jars, packages=True) try: if parsed.action == "join": output = "cmdline = \"" + backquote(join_options(parsed.option)) + "\"" elif parsed.action == "split" and len(parsed.option) == 1: output = "options = [\n" opts = split_options(parsed.option[0]) for idx, opt in enumerate(opts): if idx > 0: output += ",\n" output += " \"" + backquote(opt) + "\"" output += "]" elif parsed.action == "code": options = parsed.option[:] cname = None # classname + options? if options[0].find(".") > -1: cname = options[0] options = options[1:] output = "options = [ \n" for idx, opt in enumerate(options): if idx > 0: output += ",\n" output += " \"" + backquote(opt) + "\"" output += "]\n" if cname is not None: output += 'handler = OptionHandler(JavaObject.new_instance("' + cname + '"))\n' output += 'handler.options = options\n' else: raise Exception("Unsupported action: " + parsed.action) if output is not None: print(output) except Exception as e: print(e) finally: jvm.stop()
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Performs option handling operations from the command-line. Calls JVM start/stop automatically.'", ")", "parser", ".", "add_argument", "(", "\"-j\"", ",", "metavar", "=", "\"classpath\"", ",", "dest", "=", "\"classpath\"", ",", "help", "=", "\"additional classpath, jars/directories\"", ")", "parser", ".", "add_argument", "(", "\"-action\"", ",", "metavar", "=", "\"action\"", ",", "dest", "=", "\"action\"", ",", "required", "=", "True", ",", "help", "=", "\"The action to perform on the options: join=create single string, \"", "\"split=create array from quoted option, code=generate code from options\"", ")", "parser", ".", "add_argument", "(", "\"option\"", ",", "nargs", "=", "argparse", ".", "REMAINDER", ",", "help", "=", "\"The option(s) to process\"", ")", "parsed", "=", "parser", ".", "parse_args", "(", ")", "jars", "=", "[", "]", "if", "parsed", ".", "classpath", "is", "not", "None", ":", "jars", "=", "parsed", ".", "classpath", ".", "split", "(", "os", ".", "pathsep", ")", "jvm", ".", "start", "(", "jars", ",", "packages", "=", "True", ")", "try", ":", "if", "parsed", ".", "action", "==", "\"join\"", ":", "output", "=", "\"cmdline = \\\"\"", "+", "backquote", "(", "join_options", "(", "parsed", ".", "option", ")", ")", "+", "\"\\\"\"", "elif", "parsed", ".", "action", "==", "\"split\"", "and", "len", "(", "parsed", ".", "option", ")", "==", "1", ":", "output", "=", "\"options = [\\n\"", "opts", "=", "split_options", "(", "parsed", ".", "option", "[", "0", "]", ")", "for", "idx", ",", "opt", "in", "enumerate", "(", "opts", ")", ":", "if", "idx", ">", "0", ":", "output", "+=", "\",\\n\"", "output", "+=", "\" \\\"\"", "+", "backquote", "(", "opt", ")", "+", "\"\\\"\"", "output", "+=", "\"]\"", "elif", "parsed", ".", "action", "==", "\"code\"", ":", "options", "=", "parsed", ".", "option", "[", ":", "]", "cname", "=", "None", "# classname + options?", "if", "options", "[", "0", "]", ".", "find", "(", "\".\"", ")", ">", "-", "1", ":", "cname", "=", "options", "[", "0", "]", "options", "=", "options", "[", "1", ":", "]", "output", "=", "\"options = [ \\n\"", "for", "idx", ",", "opt", "in", "enumerate", "(", "options", ")", ":", "if", "idx", ">", "0", ":", "output", "+=", "\",\\n\"", "output", "+=", "\" \\\"\"", "+", "backquote", "(", "opt", ")", "+", "\"\\\"\"", "output", "+=", "\"]\\n\"", "if", "cname", "is", "not", "None", ":", "output", "+=", "'handler = OptionHandler(JavaObject.new_instance(\"'", "+", "cname", "+", "'\"))\\n'", "output", "+=", "'handler.options = options\\n'", "else", ":", "raise", "Exception", "(", "\"Unsupported action: \"", "+", "parsed", ".", "action", ")", "if", "output", "is", "not", "None", ":", "print", "(", "output", ")", "except", "Exception", "as", "e", ":", "print", "(", "e", ")", "finally", ":", "jvm", ".", "stop", "(", ")" ]
Runs a classifier from the command-line. Calls JVM start/stop automatically. Use -h to see all options.
[ "Runs", "a", "classifier", "from", "the", "command", "-", "line", ".", "Calls", "JVM", "start", "/", "stop", "automatically", ".", "Use", "-", "h", "to", "see", "all", "options", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L2031-L2084
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JSONObject.to_json
def to_json(self): """ Returns the options as JSON. :return: the object as string :rtype: str """ return json.dumps(self.to_dict(), sort_keys=True, indent=2, separators=(',', ': '))
python
def to_json(self): """ Returns the options as JSON. :return: the object as string :rtype: str """ return json.dumps(self.to_dict(), sort_keys=True, indent=2, separators=(',', ': '))
[ "def", "to_json", "(", "self", ")", ":", "return", "json", ".", "dumps", "(", "self", ".", "to_dict", "(", ")", ",", "sort_keys", "=", "True", ",", "indent", "=", "2", ",", "separators", "=", "(", "','", ",", "': '", ")", ")" ]
Returns the options as JSON. :return: the object as string :rtype: str
[ "Returns", "the", "options", "as", "JSON", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L250-L257
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JSONObject.from_json
def from_json(cls, s): """ Restores the object from the given JSON. :param s: the JSON string to parse :type s: str :return: the """ d = json.loads(s) return get_dict_handler(d["type"])(d)
python
def from_json(cls, s): """ Restores the object from the given JSON. :param s: the JSON string to parse :type s: str :return: the """ d = json.loads(s) return get_dict_handler(d["type"])(d)
[ "def", "from_json", "(", "cls", ",", "s", ")", ":", "d", "=", "json", ".", "loads", "(", "s", ")", "return", "get_dict_handler", "(", "d", "[", "\"type\"", "]", ")", "(", "d", ")" ]
Restores the object from the given JSON. :param s: the JSON string to parse :type s: str :return: the
[ "Restores", "the", "object", "from", "the", "given", "JSON", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L260-L269
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Configurable.to_dict
def to_dict(self): """ Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict """ result = {} result["type"] = "Configurable" result["class"] = get_classname(self) result["config"] = {} for k in self._config: v = self._config[k] if isinstance(v, JSONObject): result["config"][k] = v.to_dict() else: result["config"][k] = v return result
python
def to_dict(self): """ Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict """ result = {} result["type"] = "Configurable" result["class"] = get_classname(self) result["config"] = {} for k in self._config: v = self._config[k] if isinstance(v, JSONObject): result["config"][k] = v.to_dict() else: result["config"][k] = v return result
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "{", "}", "result", "[", "\"type\"", "]", "=", "\"Configurable\"", "result", "[", "\"class\"", "]", "=", "get_classname", "(", "self", ")", "result", "[", "\"config\"", "]", "=", "{", "}", "for", "k", "in", "self", ".", "_config", ":", "v", "=", "self", ".", "_config", "[", "k", "]", "if", "isinstance", "(", "v", ",", "JSONObject", ")", ":", "result", "[", "\"config\"", "]", "[", "k", "]", "=", "v", ".", "to_dict", "(", ")", "else", ":", "result", "[", "\"config\"", "]", "[", "k", "]", "=", "v", "return", "result" ]
Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict
[ "Returns", "a", "dictionary", "that", "represents", "this", "object", "to", "be", "used", "for", "JSONification", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L352-L369
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Configurable.from_dict
def from_dict(cls, d): """ Restores its state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict """ conf = {} for k in d["config"]: v = d["config"][k] if isinstance(v, dict): conf[str(k)] = get_dict_handler(d["config"]["type"])(v) else: conf[str(k)] = v return get_class(str(d["class"]))(config=conf)
python
def from_dict(cls, d): """ Restores its state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict """ conf = {} for k in d["config"]: v = d["config"][k] if isinstance(v, dict): conf[str(k)] = get_dict_handler(d["config"]["type"])(v) else: conf[str(k)] = v return get_class(str(d["class"]))(config=conf)
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "conf", "=", "{", "}", "for", "k", "in", "d", "[", "\"config\"", "]", ":", "v", "=", "d", "[", "\"config\"", "]", "[", "k", "]", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "conf", "[", "str", "(", "k", ")", "]", "=", "get_dict_handler", "(", "d", "[", "\"config\"", "]", "[", "\"type\"", "]", ")", "(", "v", ")", "else", ":", "conf", "[", "str", "(", "k", ")", "]", "=", "v", "return", "get_class", "(", "str", "(", "d", "[", "\"class\"", "]", ")", ")", "(", "config", "=", "conf", ")" ]
Restores its state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict
[ "Restores", "its", "state", "from", "a", "dictionary", "used", "in", "de", "-", "JSONification", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L372-L386
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Configurable.logger
def logger(self): """ Returns the logger object. :return: the logger :rtype: logger """ if self._logger is None: self._logger = self.new_logger() return self._logger
python
def logger(self): """ Returns the logger object. :return: the logger :rtype: logger """ if self._logger is None: self._logger = self.new_logger() return self._logger
[ "def", "logger", "(", "self", ")", ":", "if", "self", ".", "_logger", "is", "None", ":", "self", ".", "_logger", "=", "self", ".", "new_logger", "(", ")", "return", "self", ".", "_logger" ]
Returns the logger object. :return: the logger :rtype: logger
[ "Returns", "the", "logger", "object", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L398-L407
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Configurable.generate_help
def generate_help(self): """ Generates a help string for this actor. :return: the help string :rtype: str """ result = [] result.append(self.__class__.__name__) result.append(re.sub(r'.', '=', self.__class__.__name__)) result.append("") result.append("DESCRIPTION") result.append(self.description()) result.append("") result.append("OPTIONS") opts = sorted(self.config.keys()) for opt in opts: result.append(opt) helpstr = self.help[opt] if helpstr is None: helpstr = "-missing help-" result.append("\t" + helpstr) result.append("") return '\n'.join(result)
python
def generate_help(self): """ Generates a help string for this actor. :return: the help string :rtype: str """ result = [] result.append(self.__class__.__name__) result.append(re.sub(r'.', '=', self.__class__.__name__)) result.append("") result.append("DESCRIPTION") result.append(self.description()) result.append("") result.append("OPTIONS") opts = sorted(self.config.keys()) for opt in opts: result.append(opt) helpstr = self.help[opt] if helpstr is None: helpstr = "-missing help-" result.append("\t" + helpstr) result.append("") return '\n'.join(result)
[ "def", "generate_help", "(", "self", ")", ":", "result", "=", "[", "]", "result", ".", "append", "(", "self", ".", "__class__", ".", "__name__", ")", "result", ".", "append", "(", "re", ".", "sub", "(", "r'.'", ",", "'='", ",", "self", ".", "__class__", ".", "__name__", ")", ")", "result", ".", "append", "(", "\"\"", ")", "result", ".", "append", "(", "\"DESCRIPTION\"", ")", "result", ".", "append", "(", "self", ".", "description", "(", ")", ")", "result", ".", "append", "(", "\"\"", ")", "result", ".", "append", "(", "\"OPTIONS\"", ")", "opts", "=", "sorted", "(", "self", ".", "config", ".", "keys", "(", ")", ")", "for", "opt", "in", "opts", ":", "result", ".", "append", "(", "opt", ")", "helpstr", "=", "self", ".", "help", "[", "opt", "]", "if", "helpstr", "is", "None", ":", "helpstr", "=", "\"-missing help-\"", "result", ".", "append", "(", "\"\\t\"", "+", "helpstr", ")", "result", ".", "append", "(", "\"\"", ")", "return", "'\\n'", ".", "join", "(", "result", ")" ]
Generates a help string for this actor. :return: the help string :rtype: str
[ "Generates", "a", "help", "string", "for", "this", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L419-L442
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JavaObject.classname
def classname(self): """ Returns the Java classname in dot-notation. :return: the Java classname :rtype: str """ cls = javabridge.call(self.jobject, "getClass", "()Ljava/lang/Class;") return javabridge.call(cls, "getName", "()Ljava/lang/String;")
python
def classname(self): """ Returns the Java classname in dot-notation. :return: the Java classname :rtype: str """ cls = javabridge.call(self.jobject, "getClass", "()Ljava/lang/Class;") return javabridge.call(cls, "getName", "()Ljava/lang/String;")
[ "def", "classname", "(", "self", ")", ":", "cls", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getClass\"", ",", "\"()Ljava/lang/Class;\"", ")", "return", "javabridge", ".", "call", "(", "cls", ",", "\"getName\"", ",", "\"()Ljava/lang/String;\"", ")" ]
Returns the Java classname in dot-notation. :return: the Java classname :rtype: str
[ "Returns", "the", "Java", "classname", "in", "dot", "-", "notation", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L494-L502
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JavaObject.set_property
def set_property(self, path, jobject): """ Attempts to set the value (jobject, a Java object) of the provided (bean) property path. :param path: the property path, e.g., "filter" for a setFilter(...)/getFilter() method pair :type path: str :param jobject: the Java object to set; if instance of JavaObject class, the jobject member is automatically used :type jobject: JB_Object """ # unwrap? if isinstance(jobject, JavaObject): jobject = jobject.jobject javabridge.static_call( "Lweka/core/PropertyPath;", "setValue", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V", self.jobject, path, jobject)
python
def set_property(self, path, jobject): """ Attempts to set the value (jobject, a Java object) of the provided (bean) property path. :param path: the property path, e.g., "filter" for a setFilter(...)/getFilter() method pair :type path: str :param jobject: the Java object to set; if instance of JavaObject class, the jobject member is automatically used :type jobject: JB_Object """ # unwrap? if isinstance(jobject, JavaObject): jobject = jobject.jobject javabridge.static_call( "Lweka/core/PropertyPath;", "setValue", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V", self.jobject, path, jobject)
[ "def", "set_property", "(", "self", ",", "path", ",", "jobject", ")", ":", "# unwrap?", "if", "isinstance", "(", "jobject", ",", "JavaObject", ")", ":", "jobject", "=", "jobject", ".", "jobject", "javabridge", ".", "static_call", "(", "\"Lweka/core/PropertyPath;\"", ",", "\"setValue\"", ",", "\"(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V\"", ",", "self", ".", "jobject", ",", "path", ",", "jobject", ")" ]
Attempts to set the value (jobject, a Java object) of the provided (bean) property path. :param path: the property path, e.g., "filter" for a setFilter(...)/getFilter() method pair :type path: str :param jobject: the Java object to set; if instance of JavaObject class, the jobject member is automatically used :type jobject: JB_Object
[ "Attempts", "to", "set", "the", "value", "(", "jobject", "a", "Java", "object", ")", "of", "the", "provided", "(", "bean", ")", "property", "path", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L504-L520
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JavaObject.enforce_type
def enforce_type(cls, jobject, intf_or_class): """ Raises an exception if the object does not implement the specified interface or is not a subclass. :param jobject: the Java object to check :type jobject: JB_Object :param intf_or_class: the classname in Java notation (eg "weka.core.DenseInstance") :type intf_or_class: str """ if not cls.check_type(jobject, intf_or_class): raise TypeError("Object does not implement or subclass " + intf_or_class + ": " + get_classname(jobject))
python
def enforce_type(cls, jobject, intf_or_class): """ Raises an exception if the object does not implement the specified interface or is not a subclass. :param jobject: the Java object to check :type jobject: JB_Object :param intf_or_class: the classname in Java notation (eg "weka.core.DenseInstance") :type intf_or_class: str """ if not cls.check_type(jobject, intf_or_class): raise TypeError("Object does not implement or subclass " + intf_or_class + ": " + get_classname(jobject))
[ "def", "enforce_type", "(", "cls", ",", "jobject", ",", "intf_or_class", ")", ":", "if", "not", "cls", ".", "check_type", "(", "jobject", ",", "intf_or_class", ")", ":", "raise", "TypeError", "(", "\"Object does not implement or subclass \"", "+", "intf_or_class", "+", "\": \"", "+", "get_classname", "(", "jobject", ")", ")" ]
Raises an exception if the object does not implement the specified interface or is not a subclass. :param jobject: the Java object to check :type jobject: JB_Object :param intf_or_class: the classname in Java notation (eg "weka.core.DenseInstance") :type intf_or_class: str
[ "Raises", "an", "exception", "if", "the", "object", "does", "not", "implement", "the", "specified", "interface", "or", "is", "not", "a", "subclass", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L621-L631
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JavaObject.new_instance
def new_instance(cls, classname): """ Creates a new object from the given classname using the default constructor, None in case of error. :param classname: the classname in Java notation (eg "weka.core.DenseInstance") :type classname: str :return: the Java object :rtype: JB_Object """ try: return javabridge.static_call( "Lweka/core/Utils;", "forName", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;", javabridge.class_for_name("java.lang.Object"), classname, []) except JavaException as e: print("Failed to instantiate " + classname + ": " + str(e)) return None
python
def new_instance(cls, classname): """ Creates a new object from the given classname using the default constructor, None in case of error. :param classname: the classname in Java notation (eg "weka.core.DenseInstance") :type classname: str :return: the Java object :rtype: JB_Object """ try: return javabridge.static_call( "Lweka/core/Utils;", "forName", "(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;", javabridge.class_for_name("java.lang.Object"), classname, []) except JavaException as e: print("Failed to instantiate " + classname + ": " + str(e)) return None
[ "def", "new_instance", "(", "cls", ",", "classname", ")", ":", "try", ":", "return", "javabridge", ".", "static_call", "(", "\"Lweka/core/Utils;\"", ",", "\"forName\"", ",", "\"(Ljava/lang/Class;Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Object;\"", ",", "javabridge", ".", "class_for_name", "(", "\"java.lang.Object\"", ")", ",", "classname", ",", "[", "]", ")", "except", "JavaException", "as", "e", ":", "print", "(", "\"Failed to instantiate \"", "+", "classname", "+", "\": \"", "+", "str", "(", "e", ")", ")", "return", "None" ]
Creates a new object from the given classname using the default constructor, None in case of error. :param classname: the classname in Java notation (eg "weka.core.DenseInstance") :type classname: str :return: the Java object :rtype: JB_Object
[ "Creates", "a", "new", "object", "from", "the", "given", "classname", "using", "the", "default", "constructor", "None", "in", "case", "of", "error", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L634-L650
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Environment.add_variable
def add_variable(self, key, value, system_wide=False): """ Adds the environment variable. :param key: the name of the variable :type key: str :param value: the value :type value: str :param system_wide: whether to add the variable system wide :type system_wide: bool """ if system_wide: javabridge.call(self.jobject, "addVariableSystemWide", "(Ljava/lang/String;Ljava/lang/String;)V", key, value) else: javabridge.call(self.jobject, "addVariable", "(Ljava/lang/String;Ljava/lang/String;)V", key, value)
python
def add_variable(self, key, value, system_wide=False): """ Adds the environment variable. :param key: the name of the variable :type key: str :param value: the value :type value: str :param system_wide: whether to add the variable system wide :type system_wide: bool """ if system_wide: javabridge.call(self.jobject, "addVariableSystemWide", "(Ljava/lang/String;Ljava/lang/String;)V", key, value) else: javabridge.call(self.jobject, "addVariable", "(Ljava/lang/String;Ljava/lang/String;)V", key, value)
[ "def", "add_variable", "(", "self", ",", "key", ",", "value", ",", "system_wide", "=", "False", ")", ":", "if", "system_wide", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"addVariableSystemWide\"", ",", "\"(Ljava/lang/String;Ljava/lang/String;)V\"", ",", "key", ",", "value", ")", "else", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"addVariable\"", ",", "\"(Ljava/lang/String;Ljava/lang/String;)V\"", ",", "key", ",", "value", ")" ]
Adds the environment variable. :param key: the name of the variable :type key: str :param value: the value :type value: str :param system_wide: whether to add the variable system wide :type system_wide: bool
[ "Adds", "the", "environment", "variable", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L671-L685
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Environment.variable_names
def variable_names(self): """ Returns the names of all environment variables. :return: the names of the variables :rtype: list """ result = [] names = javabridge.call(self.jobject, "getVariableNames", "()Ljava/util/Set;") for name in javabridge.iterate_collection(names): result.append(javabridge.to_string(name)) return result
python
def variable_names(self): """ Returns the names of all environment variables. :return: the names of the variables :rtype: list """ result = [] names = javabridge.call(self.jobject, "getVariableNames", "()Ljava/util/Set;") for name in javabridge.iterate_collection(names): result.append(javabridge.to_string(name)) return result
[ "def", "variable_names", "(", "self", ")", ":", "result", "=", "[", "]", "names", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getVariableNames\"", ",", "\"()Ljava/util/Set;\"", ")", "for", "name", "in", "javabridge", ".", "iterate_collection", "(", "names", ")", ":", "result", ".", "append", "(", "javabridge", ".", "to_string", "(", "name", ")", ")", "return", "result" ]
Returns the names of all environment variables. :return: the names of the variables :rtype: list
[ "Returns", "the", "names", "of", "all", "environment", "variables", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L707-L718
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JavaArray.component_type
def component_type(self): """ Returns the classname of the elements. :return: the class of the elements :rtype: str """ cls = javabridge.call(self.jobject, "getClass", "()Ljava/lang/Class;") comptype = javabridge.call(cls, "getComponentType", "()Ljava/lang/Class;") return javabridge.call(comptype, "getName", "()Ljava/lang/String;")
python
def component_type(self): """ Returns the classname of the elements. :return: the class of the elements :rtype: str """ cls = javabridge.call(self.jobject, "getClass", "()Ljava/lang/Class;") comptype = javabridge.call(cls, "getComponentType", "()Ljava/lang/Class;") return javabridge.call(comptype, "getName", "()Ljava/lang/String;")
[ "def", "component_type", "(", "self", ")", ":", "cls", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getClass\"", ",", "\"()Ljava/lang/Class;\"", ")", "comptype", "=", "javabridge", ".", "call", "(", "cls", ",", "\"getComponentType\"", ",", "\"()Ljava/lang/Class;\"", ")", "return", "javabridge", ".", "call", "(", "comptype", ",", "\"getName\"", ",", "\"()Ljava/lang/String;\"", ")" ]
Returns the classname of the elements. :return: the class of the elements :rtype: str
[ "Returns", "the", "classname", "of", "the", "elements", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L843-L852
fracpete/python-weka-wrapper3
python/weka/core/classes.py
JavaArray.new_instance
def new_instance(cls, classname, length): """ Creates a new array with the given classname and length; initial values are null. :param classname: the classname in Java notation (eg "weka.core.DenseInstance") :type classname: str :param length: the length of the array :type length: int :return: the Java array :rtype: JB_Object """ return javabridge.static_call( "Ljava/lang/reflect/Array;", "newInstance", "(Ljava/lang/Class;I)Ljava/lang/Object;", get_jclass(classname=classname), length)
python
def new_instance(cls, classname, length): """ Creates a new array with the given classname and length; initial values are null. :param classname: the classname in Java notation (eg "weka.core.DenseInstance") :type classname: str :param length: the length of the array :type length: int :return: the Java array :rtype: JB_Object """ return javabridge.static_call( "Ljava/lang/reflect/Array;", "newInstance", "(Ljava/lang/Class;I)Ljava/lang/Object;", get_jclass(classname=classname), length)
[ "def", "new_instance", "(", "cls", ",", "classname", ",", "length", ")", ":", "return", "javabridge", ".", "static_call", "(", "\"Ljava/lang/reflect/Array;\"", ",", "\"newInstance\"", ",", "\"(Ljava/lang/Class;I)Ljava/lang/Object;\"", ",", "get_jclass", "(", "classname", "=", "classname", ")", ",", "length", ")" ]
Creates a new array with the given classname and length; initial values are null. :param classname: the classname in Java notation (eg "weka.core.DenseInstance") :type classname: str :param length: the length of the array :type length: int :return: the Java array :rtype: JB_Object
[ "Creates", "a", "new", "array", "with", "the", "given", "classname", "and", "length", ";", "initial", "values", "are", "null", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L855-L870
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Enum.values
def values(self): """ Returns list of all enum members. :return: all enum members :rtype: list """ cls = javabridge.call(self.jobject, "getClass", "()Ljava/lang/Class;") clsname = javabridge.call(cls, "getName", "()Ljava/lang/String;") l = javabridge.static_call(clsname.replace(".", "/"), "values", "()[L" + clsname.replace(".", "/") + ";") l = javabridge.get_env().get_object_array_elements(l) result = [] for item in l: result.append(Enum(jobject=item)) return result
python
def values(self): """ Returns list of all enum members. :return: all enum members :rtype: list """ cls = javabridge.call(self.jobject, "getClass", "()Ljava/lang/Class;") clsname = javabridge.call(cls, "getName", "()Ljava/lang/String;") l = javabridge.static_call(clsname.replace(".", "/"), "values", "()[L" + clsname.replace(".", "/") + ";") l = javabridge.get_env().get_object_array_elements(l) result = [] for item in l: result.append(Enum(jobject=item)) return result
[ "def", "values", "(", "self", ")", ":", "cls", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getClass\"", ",", "\"()Ljava/lang/Class;\"", ")", "clsname", "=", "javabridge", ".", "call", "(", "cls", ",", "\"getName\"", ",", "\"()Ljava/lang/String;\"", ")", "l", "=", "javabridge", ".", "static_call", "(", "clsname", ".", "replace", "(", "\".\"", ",", "\"/\"", ")", ",", "\"values\"", ",", "\"()[L\"", "+", "clsname", ".", "replace", "(", "\".\"", ",", "\"/\"", ")", "+", "\";\"", ")", "l", "=", "javabridge", ".", "get_env", "(", ")", ".", "get_object_array_elements", "(", "l", ")", "result", "=", "[", "]", "for", "item", "in", "l", ":", "result", ".", "append", "(", "Enum", "(", "jobject", "=", "item", ")", ")", "return", "result" ]
Returns list of all enum members. :return: all enum members :rtype: list
[ "Returns", "list", "of", "all", "enum", "members", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L918-L932
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Random.next_int
def next_int(self, n=None): """ Next random integer. if n is provided, then between 0 and n-1. :param n: the upper limit (minus 1) for the random integer :type n: int :return: the next random integer :rtype: int """ if n is None: return javabridge.call(self.jobject, "nextInt", "()I") else: return javabridge.call(self.jobject, "nextInt", "(I)I", n)
python
def next_int(self, n=None): """ Next random integer. if n is provided, then between 0 and n-1. :param n: the upper limit (minus 1) for the random integer :type n: int :return: the next random integer :rtype: int """ if n is None: return javabridge.call(self.jobject, "nextInt", "()I") else: return javabridge.call(self.jobject, "nextInt", "(I)I", n)
[ "def", "next_int", "(", "self", ",", "n", "=", "None", ")", ":", "if", "n", "is", "None", ":", "return", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"nextInt\"", ",", "\"()I\"", ")", "else", ":", "return", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"nextInt\"", ",", "\"(I)I\"", ",", "n", ")" ]
Next random integer. if n is provided, then between 0 and n-1. :param n: the upper limit (minus 1) for the random integer :type n: int :return: the next random integer :rtype: int
[ "Next", "random", "integer", ".", "if", "n", "is", "provided", "then", "between", "0", "and", "n", "-", "1", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L949-L961
fracpete/python-weka-wrapper3
python/weka/core/classes.py
OptionHandler.options
def options(self): """ Obtains the currently set options as list. :return: the list of options :rtype: list """ if self.is_optionhandler: return typeconv.string_array_to_list(javabridge.call(self.jobject, "getOptions", "()[Ljava/lang/String;")) else: return []
python
def options(self): """ Obtains the currently set options as list. :return: the list of options :rtype: list """ if self.is_optionhandler: return typeconv.string_array_to_list(javabridge.call(self.jobject, "getOptions", "()[Ljava/lang/String;")) else: return []
[ "def", "options", "(", "self", ")", ":", "if", "self", ".", "is_optionhandler", ":", "return", "typeconv", ".", "string_array_to_list", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getOptions\"", ",", "\"()[Ljava/lang/String;\"", ")", ")", "else", ":", "return", "[", "]" ]
Obtains the currently set options as list. :return: the list of options :rtype: list
[ "Obtains", "the", "currently", "set", "options", "as", "list", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1077-L1087
fracpete/python-weka-wrapper3
python/weka/core/classes.py
OptionHandler.options
def options(self, options): """ Sets the command-line options (as list). :param options: the list of command-line options to set :type options: list """ if self.is_optionhandler: javabridge.call(self.jobject, "setOptions", "([Ljava/lang/String;)V", typeconv.string_list_to_array(options))
python
def options(self, options): """ Sets the command-line options (as list). :param options: the list of command-line options to set :type options: list """ if self.is_optionhandler: javabridge.call(self.jobject, "setOptions", "([Ljava/lang/String;)V", typeconv.string_list_to_array(options))
[ "def", "options", "(", "self", ",", "options", ")", ":", "if", "self", ".", "is_optionhandler", ":", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"setOptions\"", ",", "\"([Ljava/lang/String;)V\"", ",", "typeconv", ".", "string_list_to_array", "(", "options", ")", ")" ]
Sets the command-line options (as list). :param options: the list of command-line options to set :type options: list
[ "Sets", "the", "command", "-", "line", "options", "(", "as", "list", ")", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1090-L1098
fracpete/python-weka-wrapper3
python/weka/core/classes.py
OptionHandler.to_help
def to_help(self): """ Returns a string that contains the 'global_info' text and the options. :return: the generated help string :rtype: str """ result = [] result.append(self.classname) result.append("=" * len(self.classname)) result.append("") result.append("DESCRIPTION") result.append("") result.append(self.global_info()) result.append("") result.append("OPTIONS") result.append("") options = javabridge.call(self.jobject, "listOptions", "()Ljava/util/Enumeration;") enum = javabridge.get_enumeration_wrapper(options) while enum.hasMoreElements(): opt = Option(enum.nextElement()) result.append(opt.synopsis) result.append(opt.description) result.append("") return '\n'.join(result)
python
def to_help(self): """ Returns a string that contains the 'global_info' text and the options. :return: the generated help string :rtype: str """ result = [] result.append(self.classname) result.append("=" * len(self.classname)) result.append("") result.append("DESCRIPTION") result.append("") result.append(self.global_info()) result.append("") result.append("OPTIONS") result.append("") options = javabridge.call(self.jobject, "listOptions", "()Ljava/util/Enumeration;") enum = javabridge.get_enumeration_wrapper(options) while enum.hasMoreElements(): opt = Option(enum.nextElement()) result.append(opt.synopsis) result.append(opt.description) result.append("") return '\n'.join(result)
[ "def", "to_help", "(", "self", ")", ":", "result", "=", "[", "]", "result", ".", "append", "(", "self", ".", "classname", ")", "result", ".", "append", "(", "\"=\"", "*", "len", "(", "self", ".", "classname", ")", ")", "result", ".", "append", "(", "\"\"", ")", "result", ".", "append", "(", "\"DESCRIPTION\"", ")", "result", ".", "append", "(", "\"\"", ")", "result", ".", "append", "(", "self", ".", "global_info", "(", ")", ")", "result", ".", "append", "(", "\"\"", ")", "result", ".", "append", "(", "\"OPTIONS\"", ")", "result", ".", "append", "(", "\"\"", ")", "options", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"listOptions\"", ",", "\"()Ljava/util/Enumeration;\"", ")", "enum", "=", "javabridge", ".", "get_enumeration_wrapper", "(", "options", ")", "while", "enum", ".", "hasMoreElements", "(", ")", ":", "opt", "=", "Option", "(", "enum", ".", "nextElement", "(", ")", ")", "result", ".", "append", "(", "opt", ".", "synopsis", ")", "result", ".", "append", "(", "opt", ".", "description", ")", "result", ".", "append", "(", "\"\"", ")", "return", "'\\n'", ".", "join", "(", "result", ")" ]
Returns a string that contains the 'global_info' text and the options. :return: the generated help string :rtype: str
[ "Returns", "a", "string", "that", "contains", "the", "global_info", "text", "and", "the", "options", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1112-L1136
fracpete/python-weka-wrapper3
python/weka/core/classes.py
OptionHandler.to_dict
def to_dict(self): """ Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict """ result = super(OptionHandler, self).to_dict() result["type"] = "OptionHandler" result["options"] = join_options(self.options) return result
python
def to_dict(self): """ Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict """ result = super(OptionHandler, self).to_dict() result["type"] = "OptionHandler" result["options"] = join_options(self.options) return result
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "super", "(", "OptionHandler", ",", "self", ")", ".", "to_dict", "(", ")", "result", "[", "\"type\"", "]", "=", "\"OptionHandler\"", "result", "[", "\"options\"", "]", "=", "join_options", "(", "self", ".", "options", ")", "return", "result" ]
Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict
[ "Returns", "a", "dictionary", "that", "represents", "this", "object", "to", "be", "used", "for", "JSONification", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1147-L1157
fracpete/python-weka-wrapper3
python/weka/core/classes.py
OptionHandler.from_dict
def from_dict(cls, d): """ Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object """ result = OptionHandler(cls.new_instance(d["class"])) result.options = split_options(d["options"]) return result
python
def from_dict(cls, d): """ Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object """ result = OptionHandler(cls.new_instance(d["class"])) result.options = split_options(d["options"]) return result
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "result", "=", "OptionHandler", "(", "cls", ".", "new_instance", "(", "d", "[", "\"class\"", "]", ")", ")", "result", ".", "options", "=", "split_options", "(", "d", "[", "\"options\"", "]", ")", "return", "result" ]
Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object
[ "Restores", "an", "object", "state", "from", "a", "dictionary", "used", "in", "de", "-", "JSONification", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1160-L1171
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Tags.find
def find(self, name): """ Returns the Tag that matches the name. :param name: the string representation of the tag :type name: str :return: the tag, None if not found :rtype: Tag """ result = None for t in self.array: if str(t) == name: result = Tag(t.jobject) break return result
python
def find(self, name): """ Returns the Tag that matches the name. :param name: the string representation of the tag :type name: str :return: the tag, None if not found :rtype: Tag """ result = None for t in self.array: if str(t) == name: result = Tag(t.jobject) break return result
[ "def", "find", "(", "self", ",", "name", ")", ":", "result", "=", "None", "for", "t", "in", "self", ".", "array", ":", "if", "str", "(", "t", ")", "==", "name", ":", "result", "=", "Tag", "(", "t", ".", "jobject", ")", "break", "return", "result" ]
Returns the Tag that matches the name. :param name: the string representation of the tag :type name: str :return: the tag, None if not found :rtype: Tag
[ "Returns", "the", "Tag", "that", "matches", "the", "name", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1471-L1485
fracpete/python-weka-wrapper3
python/weka/core/classes.py
Tags.get_object_tags
def get_object_tags(cls, javaobject, methodname): """ Instantiates the Tag array obtained from the object using the specified method name. Example: cls = Classifier(classname="weka.classifiers.meta.MultiSearch") tags = Tags.get_object_tags(cls, "getMetricsTags") :param javaobject: the javaobject to obtain the tags from :type javaobject: JavaObject :param methodname: the method name returning the Tag array :type methodname: str :return: the Tags objects :rtype: Tags """ return Tags(jobject=javabridge.call(javaobject.jobject, methodname, "()[Lweka/core/Tag;"))
python
def get_object_tags(cls, javaobject, methodname): """ Instantiates the Tag array obtained from the object using the specified method name. Example: cls = Classifier(classname="weka.classifiers.meta.MultiSearch") tags = Tags.get_object_tags(cls, "getMetricsTags") :param javaobject: the javaobject to obtain the tags from :type javaobject: JavaObject :param methodname: the method name returning the Tag array :type methodname: str :return: the Tags objects :rtype: Tags """ return Tags(jobject=javabridge.call(javaobject.jobject, methodname, "()[Lweka/core/Tag;"))
[ "def", "get_object_tags", "(", "cls", ",", "javaobject", ",", "methodname", ")", ":", "return", "Tags", "(", "jobject", "=", "javabridge", ".", "call", "(", "javaobject", ".", "jobject", ",", "methodname", ",", "\"()[Lweka/core/Tag;\"", ")", ")" ]
Instantiates the Tag array obtained from the object using the specified method name. Example: cls = Classifier(classname="weka.classifiers.meta.MultiSearch") tags = Tags.get_object_tags(cls, "getMetricsTags") :param javaobject: the javaobject to obtain the tags from :type javaobject: JavaObject :param methodname: the method name returning the Tag array :type methodname: str :return: the Tags objects :rtype: Tags
[ "Instantiates", "the", "Tag", "array", "obtained", "from", "the", "object", "using", "the", "specified", "method", "name", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1505-L1520
fracpete/python-weka-wrapper3
python/weka/core/classes.py
SelectedTag.tags
def tags(self): """ Returns the associated tags. :return: the list of Tag objects :rtype: list """ result = [] a = javabridge.call(self.jobject, "getTags", "()Lweka/core/Tag;]") length = javabridge.get_env().get_array_length(a) wrapped = javabridge.get_env().get_object_array_elements(a) for i in range(length): result.append(Tag(javabridge.get_env().get_string(wrapped[i]))) return result
python
def tags(self): """ Returns the associated tags. :return: the list of Tag objects :rtype: list """ result = [] a = javabridge.call(self.jobject, "getTags", "()Lweka/core/Tag;]") length = javabridge.get_env().get_array_length(a) wrapped = javabridge.get_env().get_object_array_elements(a) for i in range(length): result.append(Tag(javabridge.get_env().get_string(wrapped[i]))) return result
[ "def", "tags", "(", "self", ")", ":", "result", "=", "[", "]", "a", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getTags\"", ",", "\"()Lweka/core/Tag;]\"", ")", "length", "=", "javabridge", ".", "get_env", "(", ")", ".", "get_array_length", "(", "a", ")", "wrapped", "=", "javabridge", ".", "get_env", "(", ")", ".", "get_object_array_elements", "(", "a", ")", "for", "i", "in", "range", "(", "length", ")", ":", "result", ".", "append", "(", "Tag", "(", "javabridge", ".", "get_env", "(", ")", ".", "get_string", "(", "wrapped", "[", "i", "]", ")", ")", ")", "return", "result" ]
Returns the associated tags. :return: the list of Tag objects :rtype: list
[ "Returns", "the", "associated", "tags", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1569-L1582
fracpete/python-weka-wrapper3
python/weka/core/classes.py
SetupGenerator.base_object
def base_object(self): """ Returns the base object to apply the setups to. :return: the base object :rtype: JavaObject or OptionHandler """ jobj = javabridge.call(self.jobject, "getBaseObject", "()Ljava/io/Serializable;") if OptionHandler.check_type(jobj, "weka.core.OptionHandler"): return OptionHandler(jobj) else: return JavaObject(jobj)
python
def base_object(self): """ Returns the base object to apply the setups to. :return: the base object :rtype: JavaObject or OptionHandler """ jobj = javabridge.call(self.jobject, "getBaseObject", "()Ljava/io/Serializable;") if OptionHandler.check_type(jobj, "weka.core.OptionHandler"): return OptionHandler(jobj) else: return JavaObject(jobj)
[ "def", "base_object", "(", "self", ")", ":", "jobj", "=", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getBaseObject\"", ",", "\"()Ljava/io/Serializable;\"", ")", "if", "OptionHandler", ".", "check_type", "(", "jobj", ",", "\"weka.core.OptionHandler\"", ")", ":", "return", "OptionHandler", "(", "jobj", ")", "else", ":", "return", "JavaObject", "(", "jobj", ")" ]
Returns the base object to apply the setups to. :return: the base object :rtype: JavaObject or OptionHandler
[ "Returns", "the", "base", "object", "to", "apply", "the", "setups", "to", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1961-L1972
fracpete/python-weka-wrapper3
python/weka/core/classes.py
SetupGenerator.base_object
def base_object(self, obj): """ Sets the base object to apply the setups to. :param obj: the object to use (must be serializable!) :type obj: JavaObject """ if not obj.is_serializable: raise Exception("Base object must be serializable: " + obj.classname) javabridge.call(self.jobject, "setBaseObject", "(Ljava/io/Serializable;)V", obj.jobject)
python
def base_object(self, obj): """ Sets the base object to apply the setups to. :param obj: the object to use (must be serializable!) :type obj: JavaObject """ if not obj.is_serializable: raise Exception("Base object must be serializable: " + obj.classname) javabridge.call(self.jobject, "setBaseObject", "(Ljava/io/Serializable;)V", obj.jobject)
[ "def", "base_object", "(", "self", ",", "obj", ")", ":", "if", "not", "obj", ".", "is_serializable", ":", "raise", "Exception", "(", "\"Base object must be serializable: \"", "+", "obj", ".", "classname", ")", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"setBaseObject\"", ",", "\"(Ljava/io/Serializable;)V\"", ",", "obj", ".", "jobject", ")" ]
Sets the base object to apply the setups to. :param obj: the object to use (must be serializable!) :type obj: JavaObject
[ "Sets", "the", "base", "object", "to", "apply", "the", "setups", "to", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1975-L1984
fracpete/python-weka-wrapper3
python/weka/core/classes.py
SetupGenerator.parameters
def parameters(self): """ Returns the list of currently set search parameters. :return: the list of AbstractSearchParameter objects :rtype: list """ array = JavaArray(javabridge.call(self.jobject, "getParameters", "()[Lweka/core/setupgenerator/AbstractParameter;")) result = [] for item in array: result.append(AbstractParameter(jobject=item.jobject)) return result
python
def parameters(self): """ Returns the list of currently set search parameters. :return: the list of AbstractSearchParameter objects :rtype: list """ array = JavaArray(javabridge.call(self.jobject, "getParameters", "()[Lweka/core/setupgenerator/AbstractParameter;")) result = [] for item in array: result.append(AbstractParameter(jobject=item.jobject)) return result
[ "def", "parameters", "(", "self", ")", ":", "array", "=", "JavaArray", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"getParameters\"", ",", "\"()[Lweka/core/setupgenerator/AbstractParameter;\"", ")", ")", "result", "=", "[", "]", "for", "item", "in", "array", ":", "result", ".", "append", "(", "AbstractParameter", "(", "jobject", "=", "item", ".", "jobject", ")", ")", "return", "result" ]
Returns the list of currently set search parameters. :return: the list of AbstractSearchParameter objects :rtype: list
[ "Returns", "the", "list", "of", "currently", "set", "search", "parameters", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L1987-L1998
fracpete/python-weka-wrapper3
python/weka/core/classes.py
SetupGenerator.parameters
def parameters(self, params): """ Sets the list of search parameters to use. :param params: list of AbstractSearchParameter objects :type params: list """ array = JavaArray(jobject=JavaArray.new_instance("weka.core.setupgenerator.AbstractParameter", len(params))) for idx, obj in enumerate(params): array[idx] = obj.jobject javabridge.call(self.jobject, "setParameters", "([Lweka/core/setupgenerator/AbstractParameter;)V", array.jobject)
python
def parameters(self, params): """ Sets the list of search parameters to use. :param params: list of AbstractSearchParameter objects :type params: list """ array = JavaArray(jobject=JavaArray.new_instance("weka.core.setupgenerator.AbstractParameter", len(params))) for idx, obj in enumerate(params): array[idx] = obj.jobject javabridge.call(self.jobject, "setParameters", "([Lweka/core/setupgenerator/AbstractParameter;)V", array.jobject)
[ "def", "parameters", "(", "self", ",", "params", ")", ":", "array", "=", "JavaArray", "(", "jobject", "=", "JavaArray", ".", "new_instance", "(", "\"weka.core.setupgenerator.AbstractParameter\"", ",", "len", "(", "params", ")", ")", ")", "for", "idx", ",", "obj", "in", "enumerate", "(", "params", ")", ":", "array", "[", "idx", "]", "=", "obj", ".", "jobject", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"setParameters\"", ",", "\"([Lweka/core/setupgenerator/AbstractParameter;)V\"", ",", "array", ".", "jobject", ")" ]
Sets the list of search parameters to use. :param params: list of AbstractSearchParameter objects :type params: list
[ "Sets", "the", "list", "of", "search", "parameters", "to", "use", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L2001-L2011
fracpete/python-weka-wrapper3
python/weka/core/classes.py
SetupGenerator.setups
def setups(self): """ Generates and returns all the setups according to the parameter search space. :return: the list of configured objects (of type JavaObject) :rtype: list """ result = [] has_options = self.base_object.is_optionhandler enm = javabridge.get_enumeration_wrapper(javabridge.call(self.jobject, "setups", "()Ljava/util/Enumeration;")) while enm.hasMoreElements(): if has_options: result.append(OptionHandler(enm.nextElement())) else: result.append(JavaObject(enm.nextElement())) return result
python
def setups(self): """ Generates and returns all the setups according to the parameter search space. :return: the list of configured objects (of type JavaObject) :rtype: list """ result = [] has_options = self.base_object.is_optionhandler enm = javabridge.get_enumeration_wrapper(javabridge.call(self.jobject, "setups", "()Ljava/util/Enumeration;")) while enm.hasMoreElements(): if has_options: result.append(OptionHandler(enm.nextElement())) else: result.append(JavaObject(enm.nextElement())) return result
[ "def", "setups", "(", "self", ")", ":", "result", "=", "[", "]", "has_options", "=", "self", ".", "base_object", ".", "is_optionhandler", "enm", "=", "javabridge", ".", "get_enumeration_wrapper", "(", "javabridge", ".", "call", "(", "self", ".", "jobject", ",", "\"setups\"", ",", "\"()Ljava/util/Enumeration;\"", ")", ")", "while", "enm", ".", "hasMoreElements", "(", ")", ":", "if", "has_options", ":", "result", ".", "append", "(", "OptionHandler", "(", "enm", ".", "nextElement", "(", ")", ")", ")", "else", ":", "result", ".", "append", "(", "JavaObject", "(", "enm", ".", "nextElement", "(", ")", ")", ")", "return", "result" ]
Generates and returns all the setups according to the parameter search space. :return: the list of configured objects (of type JavaObject) :rtype: list
[ "Generates", "and", "returns", "all", "the", "setups", "according", "to", "the", "parameter", "search", "space", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/core/classes.py#L2013-L2028
fracpete/python-weka-wrapper3
python/weka/flow/base.py
to_commandline
def to_commandline(o): """ Turns the object into a commandline string. However, first checks whether a string represents a internal value placeholder (@{...}). :param o: the object to turn into commandline :type o: object :return: the commandline :rtype: str """ if isinstance(o, str) and o.startswith("@{") and o.endswith("}"): return o else: return classes.to_commandline(o)
python
def to_commandline(o): """ Turns the object into a commandline string. However, first checks whether a string represents a internal value placeholder (@{...}). :param o: the object to turn into commandline :type o: object :return: the commandline :rtype: str """ if isinstance(o, str) and o.startswith("@{") and o.endswith("}"): return o else: return classes.to_commandline(o)
[ "def", "to_commandline", "(", "o", ")", ":", "if", "isinstance", "(", "o", ",", "str", ")", "and", "o", ".", "startswith", "(", "\"@{\"", ")", "and", "o", ".", "endswith", "(", "\"}\"", ")", ":", "return", "o", "else", ":", "return", "classes", ".", "to_commandline", "(", "o", ")" ]
Turns the object into a commandline string. However, first checks whether a string represents a internal value placeholder (@{...}). :param o: the object to turn into commandline :type o: object :return: the commandline :rtype: str
[ "Turns", "the", "object", "into", "a", "commandline", "string", ".", "However", "first", "checks", "whether", "a", "string", "represents", "a", "internal", "value", "placeholder", "(", "@", "{", "...", "}", ")", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L662-L675
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.unique_name
def unique_name(self, name): """ Generates a unique name. :param name: the name to check :type name: str :return: the unique name :rtype: str """ result = name if self.parent is not None: index = self.index bname = re.sub(r'-[0-9]+$', '', name) names = [] for idx, actor in enumerate(self.parent.actors): if idx != index: names.append(actor.name) result = bname count = 0 while result in names: count += 1 result = bname + "-" + str(count) return result
python
def unique_name(self, name): """ Generates a unique name. :param name: the name to check :type name: str :return: the unique name :rtype: str """ result = name if self.parent is not None: index = self.index bname = re.sub(r'-[0-9]+$', '', name) names = [] for idx, actor in enumerate(self.parent.actors): if idx != index: names.append(actor.name) result = bname count = 0 while result in names: count += 1 result = bname + "-" + str(count) return result
[ "def", "unique_name", "(", "self", ",", "name", ")", ":", "result", "=", "name", "if", "self", ".", "parent", "is", "not", "None", ":", "index", "=", "self", ".", "index", "bname", "=", "re", ".", "sub", "(", "r'-[0-9]+$'", ",", "''", ",", "name", ")", "names", "=", "[", "]", "for", "idx", ",", "actor", "in", "enumerate", "(", "self", ".", "parent", ".", "actors", ")", ":", "if", "idx", "!=", "index", ":", "names", ".", "append", "(", "actor", ".", "name", ")", "result", "=", "bname", "count", "=", "0", "while", "result", "in", "names", ":", "count", "+=", "1", "result", "=", "bname", "+", "\"-\"", "+", "str", "(", "count", ")", "return", "result" ]
Generates a unique name. :param name: the name to check :type name: str :return: the unique name :rtype: str
[ "Generates", "a", "unique", "name", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L99-L123
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.parent
def parent(self, parent): """ Sets the parent of the actor. :param parent: the parent :type parent: Actor """ self._name = self.unique_name(self._name) self._full_name = None self._logger = None self._parent = parent
python
def parent(self, parent): """ Sets the parent of the actor. :param parent: the parent :type parent: Actor """ self._name = self.unique_name(self._name) self._full_name = None self._logger = None self._parent = parent
[ "def", "parent", "(", "self", ",", "parent", ")", ":", "self", ".", "_name", "=", "self", ".", "unique_name", "(", "self", ".", "_name", ")", "self", ".", "_full_name", "=", "None", "self", ".", "_logger", "=", "None", "self", ".", "_parent", "=", "parent" ]
Sets the parent of the actor. :param parent: the parent :type parent: Actor
[ "Sets", "the", "parent", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L136-L146
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.full_name
def full_name(self): """ Obtains the full name of the actor. :return: the full name :rtype: str """ if self._full_name is None: fn = self.name.replace(".", "\\.") parent = self._parent if parent is not None: fn = parent.full_name + "." + fn self._full_name = fn return self._full_name
python
def full_name(self): """ Obtains the full name of the actor. :return: the full name :rtype: str """ if self._full_name is None: fn = self.name.replace(".", "\\.") parent = self._parent if parent is not None: fn = parent.full_name + "." + fn self._full_name = fn return self._full_name
[ "def", "full_name", "(", "self", ")", ":", "if", "self", ".", "_full_name", "is", "None", ":", "fn", "=", "self", ".", "name", ".", "replace", "(", "\".\"", ",", "\"\\\\.\"", ")", "parent", "=", "self", ".", "_parent", "if", "parent", "is", "not", "None", ":", "fn", "=", "parent", ".", "full_name", "+", "\".\"", "+", "fn", "self", ".", "_full_name", "=", "fn", "return", "self", ".", "_full_name" ]
Obtains the full name of the actor. :return: the full name :rtype: str
[ "Obtains", "the", "full", "name", "of", "the", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L162-L176
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.fix_config
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "annotation" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "The (optional) annotation for this actor (string)." opt = "skip" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to skip (disable) this actor (bool)." return super(Actor, self).fix_config(options)
python
def fix_config(self, options): """ Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict """ opt = "annotation" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "The (optional) annotation for this actor (string)." opt = "skip" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to skip (disable) this actor (bool)." return super(Actor, self).fix_config(options)
[ "def", "fix_config", "(", "self", ",", "options", ")", ":", "opt", "=", "\"annotation\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "None", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"The (optional) annotation for this actor (string).\"", "opt", "=", "\"skip\"", "if", "opt", "not", "in", "options", ":", "options", "[", "opt", "]", "=", "False", "if", "opt", "not", "in", "self", ".", "help", ":", "self", ".", "help", "[", "opt", "]", "=", "\"Whether to skip (disable) this actor (bool).\"", "return", "super", "(", "Actor", ",", "self", ")", ".", "fix_config", "(", "options", ")" ]
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
[ "Fixes", "the", "options", "if", "necessary", ".", "I", ".", "e", ".", "it", "adds", "all", "required", "elements", "to", "the", "dictionary", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L178-L199
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.to_dict
def to_dict(self): """ Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict """ result = super(Actor, self).to_dict() result["type"] = "Actor" result["name"] = self.name return result
python
def to_dict(self): """ Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict """ result = super(Actor, self).to_dict() result["type"] = "Actor" result["name"] = self.name return result
[ "def", "to_dict", "(", "self", ")", ":", "result", "=", "super", "(", "Actor", ",", "self", ")", ".", "to_dict", "(", ")", "result", "[", "\"type\"", "]", "=", "\"Actor\"", "result", "[", "\"name\"", "]", "=", "self", ".", "name", "return", "result" ]
Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict
[ "Returns", "a", "dictionary", "that", "represents", "this", "object", "to", "be", "used", "for", "JSONification", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L201-L211
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.from_dict
def from_dict(cls, d): """ Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object """ conf = {} for k in d["config"]: v = d["config"][k] if isinstance(v, dict): if u"type" in v: typestr = v[u"type"] else: typestr = v["type"] conf[str(k)] = classes.get_dict_handler(typestr)(v) else: conf[str(k)] = v return classes.get_class(d["class"])(name=d["name"], config=conf)
python
def from_dict(cls, d): """ Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object """ conf = {} for k in d["config"]: v = d["config"][k] if isinstance(v, dict): if u"type" in v: typestr = v[u"type"] else: typestr = v["type"] conf[str(k)] = classes.get_dict_handler(typestr)(v) else: conf[str(k)] = v return classes.get_class(d["class"])(name=d["name"], config=conf)
[ "def", "from_dict", "(", "cls", ",", "d", ")", ":", "conf", "=", "{", "}", "for", "k", "in", "d", "[", "\"config\"", "]", ":", "v", "=", "d", "[", "\"config\"", "]", "[", "k", "]", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "if", "u\"type\"", "in", "v", ":", "typestr", "=", "v", "[", "u\"type\"", "]", "else", ":", "typestr", "=", "v", "[", "\"type\"", "]", "conf", "[", "str", "(", "k", ")", "]", "=", "classes", ".", "get_dict_handler", "(", "typestr", ")", "(", "v", ")", "else", ":", "conf", "[", "str", "(", "k", ")", "]", "=", "v", "return", "classes", ".", "get_class", "(", "d", "[", "\"class\"", "]", ")", "(", "name", "=", "d", "[", "\"name\"", "]", ",", "config", "=", "conf", ")" ]
Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object
[ "Restores", "an", "object", "state", "from", "a", "dictionary", "used", "in", "de", "-", "JSONification", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L214-L234
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.resolve_option
def resolve_option(self, name, default=None): """ Resolves the option, i.e., interprets "@{...}" values and retrievs them instead from internal storage. :param name: the name of the option :type name: str :param default: the optional default value :type default: object :return: the resolved value :rtype: object """ value = self.config[name] if value is None: return default elif isinstance(value, str) \ and value.startswith("@{") \ and value.endswith("}") \ and (value.find("@{", 1) == -1): stname = value[2:len(value)-1] if (self.storagehandler is not None) and (stname in self.storagehandler.storage): return self.storagehandler.storage[stname] else: return default else: return value
python
def resolve_option(self, name, default=None): """ Resolves the option, i.e., interprets "@{...}" values and retrievs them instead from internal storage. :param name: the name of the option :type name: str :param default: the optional default value :type default: object :return: the resolved value :rtype: object """ value = self.config[name] if value is None: return default elif isinstance(value, str) \ and value.startswith("@{") \ and value.endswith("}") \ and (value.find("@{", 1) == -1): stname = value[2:len(value)-1] if (self.storagehandler is not None) and (stname in self.storagehandler.storage): return self.storagehandler.storage[stname] else: return default else: return value
[ "def", "resolve_option", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "value", "=", "self", ".", "config", "[", "name", "]", "if", "value", "is", "None", ":", "return", "default", "elif", "isinstance", "(", "value", ",", "str", ")", "and", "value", ".", "startswith", "(", "\"@{\"", ")", "and", "value", ".", "endswith", "(", "\"}\"", ")", "and", "(", "value", ".", "find", "(", "\"@{\"", ",", "1", ")", "==", "-", "1", ")", ":", "stname", "=", "value", "[", "2", ":", "len", "(", "value", ")", "-", "1", "]", "if", "(", "self", ".", "storagehandler", "is", "not", "None", ")", "and", "(", "stname", "in", "self", ".", "storagehandler", ".", "storage", ")", ":", "return", "self", ".", "storagehandler", ".", "storage", "[", "stname", "]", "else", ":", "return", "default", "else", ":", "return", "value" ]
Resolves the option, i.e., interprets "@{...}" values and retrievs them instead from internal storage. :param name: the name of the option :type name: str :param default: the optional default value :type default: object :return: the resolved value :rtype: object
[ "Resolves", "the", "option", "i", ".", "e", ".", "interprets", "@", "{", "...", "}", "values", "and", "retrievs", "them", "instead", "from", "internal", "storage", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L236-L261
fracpete/python-weka-wrapper3
python/weka/flow/base.py
Actor.storagehandler
def storagehandler(self): """ Returns the storage handler available to thise actor. :return: the storage handler, None if not available """ if isinstance(self, StorageHandler): return self elif self.parent is not None: return self.parent.storagehandler else: return None
python
def storagehandler(self): """ Returns the storage handler available to thise actor. :return: the storage handler, None if not available """ if isinstance(self, StorageHandler): return self elif self.parent is not None: return self.parent.storagehandler else: return None
[ "def", "storagehandler", "(", "self", ")", ":", "if", "isinstance", "(", "self", ",", "StorageHandler", ")", ":", "return", "self", "elif", "self", ".", "parent", "is", "not", "None", ":", "return", "self", ".", "parent", ".", "storagehandler", "else", ":", "return", "None" ]
Returns the storage handler available to thise actor. :return: the storage handler, None if not available
[ "Returns", "the", "storage", "handler", "available", "to", "thise", "actor", "." ]
train
https://github.com/fracpete/python-weka-wrapper3/blob/d850ab1bdb25fbd5a8d86e99f34a397975425838/python/weka/flow/base.py#L294-L305