_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3 values | text stringlengths 31 13.1k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q1600 | MultiFilter.filters | train | def filters(self):
"""
Returns the list of base filters.
:return: the filter list
:rtype: list
"""
objects = javabridge.get_env().get_object_array_elements(
| python | {
"resource": ""
} |
q1601 | MultiFilter.filters | train | def filters(self, filters):
"""
Sets the base filters.
:param filters: the list of base filters to use
:type filters: list
"""
obj = []
for fltr in filters: | python | {
"resource": ""
} |
q1602 | Container.generate_help | train | def generate_help(self):
"""
Generates a help string for this container.
:return: the help string
:rtype: str
"""
result = []
result.append(self.__class__.__name__)
result.append(re.sub(r'.', '=', self.__class__.__name__))
| python | {
"resource": ""
} |
q1603 | plot_dot_graph | train | 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: | python | {
"resource": ""
} |
q1604 | Stemmer.stem | train | def stem(self, s):
"""
Performs stemming on the string.
:param s: the string to stem
:type s: str
:return: the stemmed string
:rtype: str
"""
| python | {
"resource": ""
} |
q1605 | Instances.attribute_by_name | train | 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
"""
| python | {
"resource": ""
} |
q1606 | Instances.add_instance | train | 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
| python | {
"resource": ""
} |
q1607 | Instances.set_instance | train | 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 | python | {
"resource": ""
} |
q1608 | Instances.delete | train | 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 | python | {
"resource": ""
} |
q1609 | Instances.insert_attribute | train | 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 | python | {
"resource": ""
} |
q1610 | Instances.train_cv | train | 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(
| python | {
"resource": ""
} |
q1611 | Instances.copy_instances | train | 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:
| python | {
"resource": ""
} |
q1612 | Instances.template_instances | train | 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
| python | {
"resource": ""
} |
q1613 | Instances.create_instances | train | 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:
| python | {
"resource": ""
} |
q1614 | Instance.dataset | train | def dataset(self):
"""
Returns the dataset that this instance belongs to.
:return: the dataset or None if no dataset set
:rtype: Instances
"""
| python | {
"resource": ""
} |
q1615 | Instance.create_sparse_instance | train | 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: | python | {
"resource": ""
} |
q1616 | Attribute.type_str | train | 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) | python | {
"resource": ""
} |
q1617 | Attribute.copy | train | 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:
| python | {
"resource": ""
} |
q1618 | Attribute.create_nominal | train | 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
"""
| python | {
"resource": ""
} |
q1619 | Attribute.create_relational | train | 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 | python | {
"resource": ""
} |
q1620 | add_bundled_jars | train | 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 | python | {
"resource": ""
} |
q1621 | add_system_classpath | train | def add_system_classpath():
"""
Adds the system's classpath to the JVM's classpath.
"""
if 'CLASSPATH' in os.environ:
| python | {
"resource": ""
} |
q1622 | get_class | train | 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 | python | {
"resource": ""
} |
q1623 | get_jclass | train | 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( | python | {
"resource": ""
} |
q1624 | get_static_field | train | 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: | python | {
"resource": ""
} |
q1625 | get_classname | train | 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;")
| python | {
"resource": ""
} |
q1626 | is_instance_of | train | 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(
| python | {
"resource": ""
} |
q1627 | from_commandline | train | 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:]
| python | {
"resource": ""
} |
q1628 | complete_classname | train | 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 | python | {
"resource": ""
} |
q1629 | JSONObject.to_json | train | def to_json(self):
"""
Returns the options as JSON.
:return: the object as string
:rtype: str
| python | {
"resource": ""
} |
q1630 | JSONObject.from_json | train | def from_json(cls, s):
"""
Restores the object from the given JSON.
:param s: the JSON | python | {
"resource": ""
} |
q1631 | Configurable.from_dict | train | def from_dict(cls, d):
"""
Restores its state from a dictionary, used in de-JSONification.
:param d: the object dictionary
:type d: dict
"""
conf = {}
| python | {
"resource": ""
} |
q1632 | Configurable.logger | train | def logger(self):
"""
Returns the logger object.
:return: the logger
| python | {
"resource": ""
} |
q1633 | Configurable.generate_help | train | 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("")
| python | {
"resource": ""
} |
q1634 | JavaObject.classname | train | def classname(self):
"""
Returns the Java classname in dot-notation.
:return: the Java classname
| python | {
"resource": ""
} |
q1635 | JavaObject.enforce_type | train | 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
| python | {
"resource": ""
} |
q1636 | JavaObject.new_instance | train | 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",
| python | {
"resource": ""
} |
q1637 | Environment.add_variable | train | 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
"""
| python | {
"resource": ""
} |
q1638 | Environment.variable_names | train | 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;")
| python | {
"resource": ""
} |
q1639 | JavaArray.component_type | train | 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;")
| python | {
"resource": ""
} |
q1640 | JavaArray.new_instance | train | 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
| python | {
"resource": ""
} |
q1641 | Enum.values | train | 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" | python | {
"resource": ""
} |
q1642 | Random.next_int | train | 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
| python | {
"resource": ""
} |
q1643 | OptionHandler.to_help | train | 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")
| python | {
"resource": ""
} |
q1644 | Tags.find | train | 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
"""
| python | {
"resource": ""
} |
q1645 | Tags.get_object_tags | train | 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
| python | {
"resource": ""
} |
q1646 | SelectedTag.tags | train | 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)
| python | {
"resource": ""
} |
q1647 | SetupGenerator.base_object | train | 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", | python | {
"resource": ""
} |
q1648 | SetupGenerator.base_object | train | 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 | python | {
"resource": ""
} |
q1649 | SetupGenerator.parameters | train | 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", | python | {
"resource": ""
} |
q1650 | SetupGenerator.parameters | train | 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):
| python | {
"resource": ""
} |
q1651 | SetupGenerator.setups | train | 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;"))
| python | {
"resource": ""
} |
q1652 | Actor.unique_name | train | 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:
| python | {
"resource": ""
} |
q1653 | Actor.parent | train | def parent(self, parent):
"""
Sets the parent of the actor.
:param parent: the parent
:type parent: Actor
"""
| python | {
"resource": ""
} |
q1654 | Actor.full_name | train | 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
| python | {
"resource": ""
} |
q1655 | Actor.storagehandler | train | 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 | python | {
"resource": ""
} |
q1656 | Actor.execute | train | def execute(self):
"""
Executes the actor.
:return: None if successful, otherwise error message
:rtype: str
"""
if self.skip:
return None
result = self.pre_execute()
if result is None:
try:
result = self.do_execute()
except Exception as e:
| python | {
"resource": ""
} |
q1657 | ActorHandler.actors | train | def actors(self, actors):
"""
Sets the sub-actors of the actor.
:param actors: the sub-actors
:type actors: list
"""
if actors is None:
| python | {
"resource": ""
} |
q1658 | ActorHandler.active | train | def active(self):
"""
Returns the count of non-skipped actors.
:return: the count
:rtype: int
"""
result = 0
| python | {
"resource": ""
} |
q1659 | ActorHandler.first_active | train | def first_active(self):
"""
Returns the first non-skipped actor.
:return: the first active actor, None if not available
:rtype: Actor
"""
result = None
| python | {
"resource": ""
} |
q1660 | ActorHandler.last_active | train | def last_active(self):
"""
Returns the last non-skipped actor.
:return: the last active actor, None if not available
:rtype: Actor
"""
result = None
| python | {
"resource": ""
} |
q1661 | ActorHandler.index_of | train | def index_of(self, name):
"""
Returns the index of the actor with the given name.
:param name: the name of the Actor to find
:type name: str
:return: the index, -1 if not found
:rtype: int
"""
| python | {
"resource": ""
} |
q1662 | ActorHandler.setup | train | def setup(self):
"""
Configures the actor before execution.
:return: None if successful, otherwise error message
:rtype: str
"""
result = super(ActorHandler, self).setup()
if result is None:
self.update_parent()
try:
self.check_actors(self.actors)
except Exception as e:
| python | {
"resource": ""
} |
q1663 | ActorHandler.cleanup | train | def cleanup(self):
"""
Destructive finishing up after execution stopped.
"""
for actor in self.actors:
if actor.skip:
| python | {
"resource": ""
} |
q1664 | Flow.load | train | def load(cls, fname):
"""
Loads the flow from a JSON file.
:param fname: the file to load
:type fname: str
:return: the flow
:rtype: Flow
"""
| python | {
"resource": ""
} |
q1665 | Sequence.new_director | train | def new_director(self):
"""
Creates the director to use for handling the sub-actors.
:return: the director instance
| python | {
"resource": ""
} |
q1666 | CommandlineToAny.check_input | train | def check_input(self, obj):
"""
Performs checks on the input object. Raises an exception if unsupported.
:param obj: the object to check
:type obj: object
"""
if isinstance(obj, str):
| python | {
"resource": ""
} |
q1667 | CommandlineToAny.convert | train | def convert(self):
"""
Performs the actual conversion.
:return: None if successful, otherwise errors message
:rtype: str
"""
cname = str(self.config["wrapper"])
| python | {
"resource": ""
} |
q1668 | plot_experiment | train | def plot_experiment(mat, title="Experiment", axes_swapped=False, measure="Statistic", show_stdev=False,
key_loc="lower right", outfile=None, wait=True):
"""
Plots the results from an experiment.
:param mat: the result matrix to plot
:type mat: ResultMatrix
:param title: the title for the experiment
:type title: str
:param axes_swapped: whether the axes whether swapped ("sets x cls" or "cls x sets")
:type axes_swapped: bool
:param measure: the measure that is being displayed
:type measure: str
:param show_stdev: whether to show the standard deviation as error bar
:type show_stdev: bool
:param key_loc: the location string for the key
:type key_loc: str
:param outfile: the output file, ignored if None
:type outfile: str
:param wait: whether to wait for the user to close the plot
:type wait: bool
"""
if not plot.matplotlib_available:
logger.error("Matplotlib is not installed, plotting unavailable!")
return
if not isinstance(mat, ResultMatrix):
logger.error("Need to supply a result matrix!")
return
fig, ax = plt.subplots()
if axes_swapped:
ax.set_xlabel(measure)
ax.set_ylabel("Classifiers")
else:
ax.set_xlabel("Classifiers")
ax.set_ylabel(measure)
ax.set_title(title)
fig.canvas.set_window_title(title)
ax.grid(True)
ticksx = []
ticks = []
inc = 1.0 / float(mat.columns)
for i | python | {
"resource": ""
} |
q1669 | predictions_to_instances | train | def predictions_to_instances(data, preds):
"""
Turns the predictions turned into an Instances object.
:param data: the original dataset format
:type data: Instances
:param preds: the predictions to convert
:type preds: list
:return: the predictions, None if no predictions present
:rtype: Instances
"""
if len(preds) == 0:
return None
is_numeric = isinstance(preds[0], NumericPrediction)
# create header
atts = []
if is_numeric:
atts.append(Attribute.create_numeric("index"))
atts.append(Attribute.create_numeric("weight"))
atts.append(Attribute.create_numeric("actual"))
atts.append(Attribute.create_numeric("predicted"))
atts.append(Attribute.create_numeric("error"))
else:
atts.append(Attribute.create_numeric("index"))
atts.append(Attribute.create_numeric("weight"))
atts.append(data.class_attribute.copy(name="actual"))
atts.append(data.class_attribute.copy(name="predicted"))
atts.append(Attribute.create_nominal("error", ["no", "yes"]))
atts.append(Attribute.create_numeric("classification"))
for i in range(data.class_attribute.num_values):
atts.append(Attribute.create_numeric("distribution-" + | python | {
"resource": ""
} |
q1670 | Classifier.batch_size | train | def batch_size(self, size):
"""
Sets the batch size, in case this classifier is a batch predictor.
:param size: the | python | {
"resource": ""
} |
q1671 | Classifier.to_source | train | def to_source(self, classname):
"""
Returns the model as Java source code if the classifier implements weka.classifiers.Sourcable.
:param classname: the classname for the generated Java code
:type classname: str
:return: the model as source code string
:rtype: str | python | {
"resource": ""
} |
q1672 | GridSearch.evaluation | train | def evaluation(self, evl):
"""
Sets the statistic to use for evaluation.
:param evl: the statistic
:type evl: SelectedTag, Tag or str
"""
if isinstance(evl, str):
evl = self.tags_evaluation.find(evl)
if isinstance(evl, Tag):
| python | {
"resource": ""
} |
q1673 | MultipleClassifiersCombiner.classifiers | train | def classifiers(self):
"""
Returns the list of base classifiers.
:return: the classifier list
:rtype: list
"""
objects = javabridge.get_env().get_object_array_elements(
| python | {
"resource": ""
} |
q1674 | MultipleClassifiersCombiner.classifiers | train | def classifiers(self, classifiers):
"""
Sets the base classifiers.
:param classifiers: the list of base classifiers to use
:type classifiers: list
"""
obj = []
for classifier in classifiers:
| python | {
"resource": ""
} |
q1675 | Kernel.eval | train | def eval(self, id1, id2, inst1):
"""
Computes the result of the kernel function for two instances. If id1 == -1, eval use inst1 instead of an
instance in the dataset.
:param id1: the index of the first instance in the dataset
:type id1: int
:param id2: the index of the second instance in the dataset
:type id2: int
| python | {
"resource": ""
} |
q1676 | KernelClassifier.kernel | train | def kernel(self):
"""
Returns the current kernel.
:return: the kernel or None if none found
:rtype: Kernel
"""
result = javabridge.static_call(
"weka/classifiers/KernelHelper", "getKernel",
| python | {
"resource": ""
} |
q1677 | KernelClassifier.kernel | train | def kernel(self, kernel):
"""
Sets the kernel.
:param kernel: the kernel to set
:type kernel: Kernel
"""
result = javabridge.static_call(
"weka/classifiers/KernelHelper", "setKernel",
| python | {
"resource": ""
} |
q1678 | CostMatrix.apply_cost_matrix | train | def apply_cost_matrix(self, data, rnd):
"""
Applies the cost matrix to the data.
:param data: the data to apply to
:type data: Instances
:param rnd: the random number generator | python | {
"resource": ""
} |
q1679 | CostMatrix.expected_costs | train | def expected_costs(self, class_probs, inst=None):
"""
Calculates the expected misclassification cost for each possible class value, given class probability
estimates.
:param class_probs: the class probabilities
:type class_probs: ndarray
:return: the calculated costs
:rtype: ndarray
"""
if inst is None:
costs = javabridge.call(
self.jobject, "expectedCosts", "([D)[D", javabridge.get_env().make_double_array(class_probs))
return javabridge.get_env().get_double_array_elements(costs)
else:
| python | {
"resource": ""
} |
q1680 | CostMatrix.get_cell | train | def get_cell(self, row, col):
"""
Returns the JB_Object at the specified location.
:param row: the 0-based index of the row
:type row: int
:param col: the 0-based index of the column
:type col: int
:return: the | python | {
"resource": ""
} |
q1681 | CostMatrix.set_cell | train | def set_cell(self, row, col, obj):
"""
Sets the JB_Object at the specified location. Automatically unwraps JavaObject.
:param row: the 0-based index of the row
:type row: int
:param col: the 0-based | python | {
"resource": ""
} |
q1682 | CostMatrix.get_element | train | def get_element(self, row, col, inst=None):
"""
Returns the value at the specified location.
:param row: the 0-based index of the row
:type row: int
:param col: the 0-based index of the column
:type col: int
:param inst: the Instace
:type inst: Instance
:return: the value in that cell
:rtype: float
"""
if inst is None:
return javabridge.call( | python | {
"resource": ""
} |
q1683 | CostMatrix.set_element | train | def set_element(self, row, col, value):
"""
Sets the float value at the specified location.
:param row: the 0-based index of the row
:type row: int
:param col: the 0-based index of the column
:type col: int
| python | {
"resource": ""
} |
q1684 | CostMatrix.get_max_cost | train | def get_max_cost(self, class_value, inst=None):
"""
Gets the maximum cost for a particular class value.
:param class_value: the class value to get the maximum cost for
:type class_value: int
:param inst: the Instance
:type inst: Instance
:return: the cost
:rtype: float
"""
if inst is None:
return javabridge.call(
| python | {
"resource": ""
} |
q1685 | Evaluation.crossvalidate_model | train | def crossvalidate_model(self, classifier, data, num_folds, rnd, output=None):
"""
Crossvalidates the model using the specified data, number of folds and random number generator wrapper.
:param classifier: the classifier to cross-validate
:type classifier: Classifier
:param data: the data to evaluate on
:type data: Instances
:param num_folds: the number of folds
:type num_folds: int
:param rnd: the random number generator to use
:type rnd: Random
:param output: the output generator to use
:type output: PredictionOutput
| python | {
"resource": ""
} |
q1686 | Evaluation.summary | train | def summary(self, title=None, complexity=False):
"""
Generates a summary.
:param title: optional title
:type title: str
:param complexity: whether to print the complexity information as well
:type complexity: bool
:return: the summary
:rtype: str
"""
if title is None:
return javabridge.call(
| python | {
"resource": ""
} |
q1687 | Evaluation.class_details | train | def class_details(self, title=None):
"""
Generates the class details.
:param title: optional title
:type title: str
:return: the details
:rtype: str
"""
if title is None:
return javabridge.call(
| python | {
"resource": ""
} |
q1688 | Evaluation.matrix | train | def matrix(self, title=None):
"""
Generates the confusion matrix.
:param title: optional title
:type title: str
:return: the matrix
:rtype: str
"""
if title is None:
return | python | {
"resource": ""
} |
q1689 | Evaluation.predictions | train | def predictions(self):
"""
Returns the predictions.
:return: the predictions. None if not available
:rtype: list
"""
preds = javabridge.get_collection_wrapper(
javabridge.call(self.jobject, "predictions", "()Ljava/util/ArrayList;"))
if self.discard_predictions:
result = None
else:
result = []
for pred in preds:
if is_instance_of(pred, | python | {
"resource": ""
} |
q1690 | PredictionOutput.print_all | train | def print_all(self, cls, data):
"""
Prints the header, classifications and footer to the buffer.
:param cls: the classifier
:type cls: Classifier
:param data: the test data
:type data: Instances
"""
| python | {
"resource": ""
} |
q1691 | PredictionOutput.print_classifications | train | def print_classifications(self, cls, data):
"""
Prints the classifications to the buffer.
:param cls: the classifier
:type cls: Classifier
:param data: the test data
:type data: Instances
"""
| python | {
"resource": ""
} |
q1692 | PredictionOutput.print_classification | train | def print_classification(self, cls, inst, index):
"""
Prints the classification to the buffer.
:param cls: the classifier
:type cls: Classifier
:param inst: the test instance
:type inst: Instance
:param index: the 0-based index of the test instance
| python | {
"resource": ""
} |
q1693 | Tokenizer.tokenize | train | def tokenize(self, s):
"""
Tokenizes the string.
:param s: the string to tokenize
:type s: str
:return: the iterator
:rtype: TokenIterator
"""
| python | {
"resource": ""
} |
q1694 | DataGenerator.define_data_format | train | def define_data_format(self):
"""
Returns the data format.
:return: the data format
:rtype: Instances
"""
data | python | {
"resource": ""
} |
q1695 | DataGenerator.dataset_format | train | def dataset_format(self):
"""
Returns the dataset format.
:return: the format
:rtype: Instances
| python | {
"resource": ""
} |
q1696 | DataGenerator.generate_example | train | def generate_example(self):
"""
Returns a single Instance.
:return: the next example
:rtype: Instance
"""
data | python | {
"resource": ""
} |
q1697 | DataGenerator.generate_examples | train | def generate_examples(self):
"""
Returns complete dataset.
:return: the generated dataset
:rtype: Instances
"""
data | python | {
"resource": ""
} |
q1698 | DataGenerator.make_copy | train | def make_copy(cls, generator):
"""
Creates a copy of the generator.
:param generator: the generator to copy
:type generator: DataGenerator
:return: the copy of the generator
:rtype: DataGenerator
"""
| python | {
"resource": ""
} |
q1699 | DataGenerator.to_config | train | def to_config(self, k, v):
"""
Hook method that allows conversion of individual options.
:param k: the key of the option
:type k: str
:param v: the value
:type v: object
:return: the potentially processed value
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.