# Changeset 10246:11b418321f79 in orange

Ignore:
Timestamp:
02/15/12 16:46:35 (2 years ago)
Branch:
default
Children:
10255:5f19d86c3d2b, 10264:273260f0e2c5
Message:

Unified argument names in and 2.5 and 3.0; numerous other changes in documentation

Files:
18 edited

Unmodified
Removed

• ## Orange/misc/__init__.py

 r10199 .. class:: CostMatrix .. attribute:: classVar The (class) attribute to which the matrix applies. This can also be None. .. attribute:: class_var The (class) attribute to which the matrix applies. This can also be None. .. attribute:: dimension (read only) .. method:: CostMatrix(dimension[, default cost]) Constructs a matrix of the given size and initializes it with the default cost (1, if not given). All elements of the matrix are assigned the given cost, except for the diagonal that have the default cost of 0. (Diagonal elements represent correct classifications and these usually have no price; you can, however, change this.) Constructs a matrix of the given size and initializes it with the default cost (1, if not given). All elements of the matrix are assigned the given cost, except for the diagonal that have the default cost of 0.  (Diagonal elements represent correct classifications and these usually have no price; you can, however, change this.) .. literalinclude:: code/CostMatrix.py :lines: 5-7 .. method:: setcost(predicted value, correct value, cost) Set the misclassification cost. The matrix above could be constructed by first initializing it with 2s and then changing the prices for virginica's into 1s. .. method:: setcost(predicted, correct, cost) Set the misclassification cost. The matrix above could be constructed by first initializing it with 2s and then changing the prices for virginica's into 1s. .. literalinclude:: code/CostMatrix.py :lines: 15-17 .. method:: getcost(predicted value, correct value) Returns the cost of prediction. Values must be integer indices; if classVar is set, you can also use symbolic values (strings). Note that there's no way to change the size of the matrix. Size is set at construction and does not change. For the final example, we shall compute the profits of knowing attribute values in the dataset lenses with the same cost-matrix as printed above. .. method:: getcost(predicted, correct) Returns the cost of prediction. Values must be integer indices; if class_var is set, you can also use symbolic values (strings). Note that there's no way to change the size of the matrix. Size is set at construction and does not change.  For the final example, we shall compute the profits of knowing attribute values in the dataset lenses with the same cost-matrix as printed above. .. literalinclude:: code/CostMatrix.py ( 4.000,  8.000, 12.000, 16.000)) .. method:: __init__(dim[, default_value]) .. method:: __init__(dim[, value]) Construct a symmetric matrix of the given dimension. :type dim: int :param default_value: default value (0 by default) :type default_value: double .. method:: __init__(instances) Construct a new symmetric matrix containing the given data instances. :param value: default value (0 by default) :type value: double .. method:: __init__(data) Construct a new symmetric matrix containing the given data. These can be given as Python list containing lists or tuples. :param instances: data instances :type instances: list of lists The following example fills a matrix created above with ------------------- Indexing ------------------- .......... For symmetric matrices the order of indices is not important: .. class:: Random(initseed) .. class:: Random(seed) :param initseed: Seed used for initializing the random generator. :type n: int .. method:: reset([initseed]) .. method:: reset([seed]) Reinitialize the random generator with `initseed`. If `initseed`

• ## docs/reference/rst/Orange.classification.logreg.rst

 r9818 .. method:: __call__(examples, weight_id) .. method:: __call__(data, weight_id) Performs the fitting. There can be two different cases: either
• ## docs/reference/rst/Orange.classification.rst

 r10227 ################################### All Orange prediction models for classification consist of two parts, a learner and a classifier. A learner is constructed with all parameters that will be used for learning. When learner is called with a data table, a model is fitted to the data and returned in the form of a Classifier, which is then used for predicting the dependent variable(s) of new instances. Induction of models in Orange is implemented through a two-class schema: "learners" are classes that induce models, and classifiers represent trained models. The learner holds the parameters that are used for fitting the model. When learner is called with a data table, it fits a model and returns an instance of classifier. Classifiers can be subsequently used to predict dependent values for new data instances. .. literalinclude:: code/bayes-run.py .. toctree:: :maxdepth: 2 :maxdepth: 1 Orange.classification.bayes Orange.classification.classfromvar Base classes ------------ All learners and classifiers, including regressors, are derived from the following two clases. .. class:: Learner() Base class for all orange learners. .. method:: __call__(data) Fit a model and return it as an instance of :class:`Classifier`. This method is abstract and needs to be implemented on each learner. .. class:: Classifier() Base class for all orange classifiers. .. method:: __call__(instance, return_type=GetValue) Classify a new instance using this model. Results depends upon the second parameter that must be one of the following. :obj:`Orange.classification.Classifier.GetValue` Return value of the target class when performing prediction. :obj:`Orange.classification.Classifier.GetProbabilities` Return probability of each target class when performing prediction. :obj:`Orange.classification.Classifier.GetBoth` Return a tuple of target class value and probabilities for each class. This method is abstract and needs to be implemented on each classifier. :param instance: data instance to be classified. :type instance: :class:`~Orange.data.Instance` :param return_type: what needs to be predicted :type return_type: :obj:`GetBoth`, :obj:`GetValue`, :obj:`GetProbabilities` :rtype: :class:`~Orange.data.Value`, :class:`~Orange.statistics.distribution.Distribution` or a tuple with both Constant Classifier ------------------- The classification module also contains a classifier that always predicts constant values regardless of given data instances. It is usually not used The classification module also contains a classifier that always predicts a constant value regardless of given data instances. It is usually not used directly but through other other learners and methods, such as :obj:`~Orange.classification.majority.MajorityLearner`. :type dstribution: :obj:`Orange.statistics.distribution.Distribution` .. method:: __call__(instances, return_type) .. method:: __call__(data, return_type) ConstantClassifier always returns the same prediction Writing custom Classifiers -------------------------- When developing new prediction models, one should extend :obj:`Learner` and :obj:`Classifier`\. Code that infers the model from the data should be placed in learner's :obj:`~Learner.__call__` method. This method should return a :obj:`Classifier`. Classifiers' :obj:`~Classifier.__call__` method should  return the prediction; :class:`~Orange.data.Value`, :class:`~Orange.statistics.distribution.Distribution` or a tuple with both based on the value of the parameter :obj:`return_type`. .. class:: Learner() Base class for all orange learners. .. method:: __call__(instances) Fit a model and return it as an instance of :class:`Classifier`. This method is abstract and needs to be implemented on each learner. .. class:: Classifier() Base class for all orange classifiers. .. attribute:: GetValue Return value of the target class when performing prediction. .. attribute:: GetProbabilities Return probability of each target class when performing prediction. .. attribute:: GetBoth Return a tuple of target class value and probabilities for each class. .. method:: __call__(instance, return_type) Classify a new instance using this model. This method is abstract and needs to be implemented on each classifier. :param instance: data instance to be classified. :type instance: :class:`~Orange.data.Instance` :param return_type: what needs to be predicted :type return_type: :obj:`GetBoth`, :obj:`GetValue`, :obj:`GetProbabilities` :rtype: :class:`~Orange.data.Value`, :class:`~Orange.statistics.distribution.Distribution` or a tuple with both
• ## docs/reference/rst/Orange.data.domain.rst

 r10086 :type class_vars: list .. method:: __init__(features, class_variable[, class_vars=]) .. method:: __init__(features, class_var[, class_vars=]) Construct a domain with the given list of features and the
• ## docs/reference/rst/Orange.data.filter.rst

 r10165 return either ``True`` or ``False``. .. method:: __call__(table) .. method:: __call__(data) Return a new data table containing the instances that match
• ## docs/reference/rst/Orange.data.instance.rst

 r9958 :type key_type: `type`` .. method:: has_meta(meta_attr) .. method:: has_meta(attr) Return ``True`` if the data instance has the specified meta attribute. :param meta_attr: meta attribute :type meta_attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` .. method:: remove_meta(meta_attr) :param attr: meta attribute :type attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` .. method:: remove_meta(attr) Remove the specified meta attribute. :param meta_attr: meta attribute :type meta_attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` .. method:: get_weight(meta_attr) :param attr: meta attribute :type attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` .. method:: get_weight(attr) Return the value of the specified meta attribute. The attribute's value must be continuous and is returned as ``float``. :param meta_attr: meta attribute :type meta_attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` .. method:: set_weight(meta_attr, weight=1) :param attr: meta attribute :type attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` .. method:: set_weight(attr, weight=1) Set the value of the specified meta attribute to ``weight``. :param meta_attr: meta attribute :type meta_attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` :param attr: meta attribute :type attr: :obj:`id`, ``str`` or :obj:`~Orange.feature.Descriptor` :param weight: weight of instance :type weight: ``float``
• ## docs/reference/rst/Orange.data.sample.rst

 r10073 .. method:: __call__(data) Return a list of indices. The argument can be either the desired length of the list or a set of instances, given as :obj:`Orange.data.Table` or as plain Python list. In the former case, sampling cannot be stratified. Return a list of indices for the given data table. If data has a discrete class, sampling can be stratified. .. method:: __call__(n) Return a list of ``n`` indices. Sampling cannot be stratified. .. class:: SubsetIndices2
• ## docs/reference/rst/Orange.data.table.rst

 r10069 same for all matching instances from both tables. .. method:: append(inst) .. method:: append(instance) Append the given instance to the end of the table. :param inst: instance to be appended :type inst: :obj:`Orange.data.Instance` or a list :param instance: instance to be appended :type instance: :obj:`Orange.data.Instance` or a list .. literalinclude:: code/datatable1.py .. method:: select(filter[, idx, negate=False]) .. method:: select(folds[, select, negate=False]) Return a subset of instances as a new :obj:`Table`. The first list. If the second argument is given, it must be an integer; select will then return the data instances for which the corresponding `filter`'s elements match `idx`. The third argument, `negate`, can only be given as a keyword. Its effect is to negate the selection. If the second argument is given, it must be an integer; method ``select`` will then return the data instances for which the corresponding ``fold``'s elements match the value of the argument ``select``. The third argument, `negate` inverts the selection. It can only be given as a keyword. Note: This method should be used when the selected data instances are going to be modified. In all other cases, method :obj:`select_ref` is preferred. :param filt: filter list :type filt: list of integers :param idx: selects which instances to pick :type idx: int :param negate: negates the selection instances are going to be modified later on. In all other cases, method :obj:`select_ref` is preferred. :param folds: list of fold indices corresponding to data instances :type folds: list :param select: select which instances to pick :type select: int :param negate: inverts the selection :type negate: bool :rtype: :obj:`Orange.data.Table` [9.000000] .. method:: select_ref(filt[, idx, negate=False]) .. method:: select_ref(folds[, select, negate=False]) Same as :obj:`select`, except that the resulting table since it consumes less memory. :param filt: filter list :type filt: list of integers :param idx: selects which instances to pick :type idx: int :param negate: negates the selection :param folds: list of fold indices corresponding to data instances :type folds: list :param select: select which instances to pick :type select: int :param negate: inverts the selection :type negate: bool :rtype: :obj:`Orange.data.Table` .. method:: select_list(filt[, idx, negate=False]) Same as :obj:`select`, except that it returns a Python list with data instances. :param filt: filter list :type filt: list of integers :param idx: selects which instances to pick :type idx: int :param negate: negates the selection :type negate: bool :rtype: list .. method:: get_items(indices) Same as the above two, except that they return a table with references to instances instead of their copies. .. method:: filter_list(conditions), filter_list(filter) As above, except that it returns a pure Python list with data instances. .. method:: filter_bool(conditions), filter_bool(filter) :rtype: :obj:`Orange.data.Table` .. method:: translate(features[, keep_metas]) .. method:: translate(variables[, keep_metas]) Similar to above, except that the domain is given by a original domain. :param features: features for the new data :type domain: list :param variables: variables for the new data :type variables: list :rtype: :obj:`Orange.data.Table` :rtype: None .. method:: sort([features]) Sort the data by attribute values. The argument gives the features ordered by importance. If omitted, the order from the domain is used. Note that the values of discrete .. method:: sort([variables]) Sort the data table. The argument gives the values ordered by importance. If omitted, the order from the domain is used. Values of discrete features are not ordered alphabetically but according to the :obj:`Orange.feature.Discrete.values`. Randomly shuffle the data instances. .. method:: add_meta_attribute(id[, value=1]) .. method:: add_meta_attribute(attr[, value=1]) Add a meta value to all data instances. The first argument of a meta attribute registered in the domain. .. method:: remove_meta_attribute(id) .. method:: remove_meta_attribute(attr) Remove a meta attribute from all data instances.
• ## docs/reference/rst/Orange.distance.rst

 r9821 .. class:: DistanceConstructor .. method:: __call__([instances, weightID][, distributions][, basic_var_stat]) .. method:: __call__([data, weightID][, distributions][, basic_stat]) Constructs an :obj:`Distance`. Not all arguments are required. Most measures can be constructed from basic_var_stat; if it is Most measures can be constructed from basic_stat; if it is not given, instances or distributions can be used.
• ## docs/reference/rst/Orange.feature.descriptor.rst

 r10169 :rtype: :class:`Orange.data.Value` .. method:: compute_value(inst) .. method:: compute_value(instance) Compute the value of the variable given the instance by there is no base value. .. method:: __init__(name) Construct a descriptor for variable with the given name. .. method:: add_value(s) The range used for :obj:`randomvalue`. .. method:: __init__(name) Construct a descriptor for variable with the given name. String variables string, enclose the string in double quotes; these are removed when the string is loaded. .. method:: __init__(name) Construct a descriptor for variable with the given name. Python objects as variables
• ## docs/reference/rst/Orange.feature.discretization.rst

 r10137 .. class:: Discretization .. method:: __call__(feature, data[, weightID]) Given a continuous ``feature``, ``data`` and, optionally id of attribute with example weight, this function returns a discretized feature. Argument ``feature`` can be a descriptor, index or name of the attribute. .. method:: __call__(variable, data[, weightID]) Given a continuous ``variable``, ``data`` and, optionally id of attribute with example weight, this function returns a discretized feature. Argument ``variable`` can be a :obj:`~Orange.feature.Descriptor`, index or name of the variable within ``data.domain``. attribute from an existing one. .. method:: construct_variable(feature) Constructs a descriptor for a new feature. The new feature's name is equal to ``feature.name`` prefixed by "D\_". Its symbolic values are discretizer specific. .. method:: construct_variable(variable) Constructs a descriptor for a new variable. The new variable's name is equal to ``variable.name`` prefixed by "D\_". Its symbolic values are specific to discretizer. .. class:: IntervalDiscretizer