Miran Levar avatar Miran Levar committed 3c0c4b6

Fixes to documentations and setup.py

Comments (0)

Files changed (9)

_multitarget/__init__.py

 
 """
 
+from __future__ import absolute_import
 import Orange
-
+from pkg_resources import resource_filename
 # Other algorithms which also work with multitarget data
 from Orange.regression import pls
 from Orange.regression import earth
-from pkg_resources import resource_filename
 
+# Multi-target algorithms
 import tree
 import chain
 import binary

docs/rst/Orange.regression.earth.rst

+.. automodule:: Orange.regression.earth

docs/rst/Orange.regression.pls.rst

+.. automodule:: Orange.regression.pls

docs/rst/code/generate_multitarget.py

+import random
+import Orange
+
+def generate_data_set(n, sigma=0.1, seed=42):
+    """
+    Generate a toy multi-target data set.
+
+    :param n: Number of instances
+    :type n: :obj:`int`
+    :param noise: The standard deviation for gaussian noise: N(0, sigma).
+    :type noise: :obj:`float`
+    :param seed: Seed for the random number generator.
+
+    """
+    vars = [Orange.feature.Continuous('X%i' % i) for i in range(1, 4)]
+    cvars = [Orange.feature.Continuous('Y%i' % i) for i in range(1, 5)]
+    domain = Orange.data.Domain(vars, False, class_vars=cvars)
+    data = Orange.data.Table(domain)
+    err = lambda: random.gauss(0, sigma)
+    random.seed(seed)
+    for i in range(n):
+        f1, f2 = random.random(), random.random()
+        x1 = f1 + err()
+        x2 = f2 + err()
+        x3 = f1 + f2 + err()
+        y1 = f1 + err()
+        y2 = 2 * f1 - 3 * f2 + err()
+        y3 = 2 * y2 - f1 + err()
+        y4 = random.random()
+        instance = Orange.data.Instance(domain, [x1, x2, x3])
+        instance.set_classes([y1, y2, y3, y4])
+        data.append(instance)
+    return data
+

docs/rst/code/multitarget.py

+import Orange
+data = Orange.data.Table('multitarget-synthetic')
+print 'Features:', data.domain.features
+print 'Classes:', data.domain.class_vars
+print 'First instance:', data[0]
+print 'Actual classes:', data[0].get_classes()
+
+majority = Orange.classification.majority.MajorityLearner()
+mt_majority = Orange.multitarget.MultitargetLearner(majority)
+c_majority = mt_majority(data)
+print 'Majority predictions:\n', c_majority(data[0])
+
+pls = Orange.multitarget.pls.PLSRegressionLearner()
+c_pls = pls(data)
+print 'PLS predictions:\n', c_pls(data[0])
+
+mt_tree = Orange.multitarget.tree.MultiTreeLearner(max_depth=3)
+c_tree = mt_tree(data)
+print 'Multi-target Tree predictions:\n', c_tree(data[0])

docs/rst/code/reliability-basic.py

-# Description: Reliability estimation - basic & fast
-# Category:    evaluation
-# Uses:        housing
-# Referenced:  Orange.evaluation.reliability
-# Classes:     Orange.evaluation.reliability.Mahalanobis, Orange.evaluation.reliability.LocalCrossValidation, Orange.evaluation.reliability.Learner
-
-import Orange
-
-housing = Orange.data.Table("housing.tab")
-
-knn = Orange.classification.knn.kNNLearner()
-
-estimators = [Orange.evaluation.reliability.Mahalanobis(k=3),
-              Orange.evaluation.reliability.LocalCrossValidation(k = 10)]
-
-reliability = Orange.evaluation.reliability.Learner(knn, estimators = estimators)
-
-restimator = reliability(housing)
-instance = housing[0]
-
-value, probability = restimator(instance, result_type=Orange.classification.Classifier.GetBoth)
-
-for estimate in probability.reliability_estimate:
-    print estimate.method_name, estimate.estimate

docs/rst/code/reliability-long.py

-# Description: Reliability estimation
-# Category:    evaluation
-# Uses:        prostate
-# Referenced:  Orange.evaluation.reliability
-# Classes:     Orange.evaluation.reliability.Learner
-
-import Orange
-Orange.evaluation.reliability.select_with_repeat.random_generator = None
-Orange.evaluation.reliability.select_with_repeat.randseed = 42
-
-import Orange
-prostate = Orange.data.Table("prostate.tab")
-
-knn = Orange.classification.knn.kNNLearner()
-reliability = Orange.evaluation.reliability.Learner(knn)
-
-res = Orange.evaluation.testing.cross_validation([reliability], prostate)
-
-reliability_res = Orange.evaluation.reliability.get_pearson_r(res)
-
-print
-print "Estimate               r       p"
-for estimate in reliability_res:
-    print "%-20s %7.3f %7.3f" % (Orange.evaluation.reliability.METHOD_NAME[estimate[3]],
-                                 estimate[0], estimate[1])
-
-reliability = Orange.evaluation.reliability.Learner(knn, estimators=[Orange.evaluation.reliability.SensitivityAnalysis()])
-
-res = Orange.evaluation.testing.cross_validation([reliability], prostate)
-
-reliability_res = Orange.evaluation.reliability.get_pearson_r(res)
-
-print
-print "Estimate               r       p"
-for estimate in reliability_res:
-    print "%-20s %7.3f %7.3f" % (Orange.evaluation.reliability.METHOD_NAME[estimate[3]],
-                                 estimate[0], estimate[1])
-
-indices = Orange.data.sample.SubsetIndices2(prostate, p0=0.7)
-train = prostate.select(indices, 0)
-test = prostate.select(indices, 1)
-
-reliability = Orange.evaluation.reliability.Learner(knn, icv=True)
-res = Orange.evaluation.testing.learn_and_test_on_test_data([reliability], train, test)
-
-print
-print "Method used in internal cross-validation: ", Orange.evaluation.reliability.METHOD_NAME[res.results[0].probabilities[0].reliability_estimate[0].method]
-
-top5 = sorted((abs(result.probabilities[0].reliability_estimate[0].estimate), id) for id, result in enumerate(res.results))[:5]
-for estimate, id in top5:
-    print "%7.3f %i" % (estimate, id)

docs/rst/code/reliability-run.py

-# Description: Reliability estimation with cross-validation
-# Category:    evaluation
-# Uses:        housing
-# Referenced:  Orange.evaluation.reliability
-# Classes:     Orange.evaluation.reliability.Learner
-
-import Orange
-Orange.evaluation.reliability.select_with_repeat.random_generator = None
-Orange.evaluation.reliability.select_with_repeat.randseed = 42
-
-import Orange
-housing = Orange.data.Table("housing.tab")
-
-knn = Orange.classification.knn.kNNLearner()
-reliability = Orange.evaluation.reliability.Learner(knn)
-
-results = Orange.evaluation.testing.cross_validation([reliability], housing)
-
-for i, instance in enumerate(results.results[:10]):
-    print "Instance", i
-    for estimate in instance.probabilities[0].reliability_estimate:
-        print "  ", estimate.method_name, estimate.estimate
 
 NAME = 'Orange-Multitarget'
 DOCUMENTATION_NAME = 'Orange Multitarget'
-
-VERSION = '0.1'
+VERSION = '0.2'
 
 DESCRIPTION = 'Orange Multitarget add-on for Orange data mining software package.'
 LONG_DESCRIPTION = open(os.path.join(os.path.dirname(__file__), 'README.rst')).read()
 AUTHOR = 'Bioinformatics Laboratory, FRI UL'
 AUTHOR_EMAIL = 'contact@orange.biolab.si'
 URL = 'http://orange.biolab.si/addons/'
-DOWNLOAD_URL = 'https://bitbucket.org/biolab/orange-multitarget/downloads'
+DOWNLOAD_URL = 'https://bitbucket.org/mlevar/orange-multitarget/downloads'
 LICENSE = 'GPLv3'
 
 KEYWORDS = (
     'machine learning',
     'artificial intelligence',
     'multitarget',
+	'multi-target',
     'orange',
     'orange add-on',
 )
     'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
     'Operating System :: OS Independent',
     'Topic :: Scientific/Engineering :: Artificial Intelligence',
-    'Topic :: Scientific/Engineering :: Visualization',
     'Topic :: Scientific/Engineering :: Bio-Informatics',
     'Topic :: Software Development :: Libraries :: Python Modules',
     'Intended Audience :: Education',
     'orange.addons': (
         'multitarget = _multitarget',
     ),
-    #'orange.widgets': (
-    #    'Evaluate = _reliability.widgets',
-        # This should be unneeded, because module given should load (register)
-        # all wanted widgets and prototypes should just have a flag, but for now ...
-        # 'Prototypes = _reliability.widgets.prototypes',
-    #),
-	#TODO: datasets
-	#'orange.data.io.search_paths': ('multitask = _multitask:datasets',)},
-	'orange.data.io.search_paths': ('multitarget = _multitarget:datasets',),
+	'orange.data.io.search_paths': (
+	'multitarget = _multitarget:datasets',
+	),
 }
 
 if __name__ == '__main__':
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.