Commits

Miha Stajdohar committed 8879fe3

Docs update.

  • Participants
  • Parent commits aedc4a7

Comments (0)

Files changed (1)

orangecontrib/modelmaps/modelmap.py

 .. autofunction:: save
 .. autofunction:: get_models_table
 .. autofunction:: get_feature_subsets
+.. autofunction:: model_network
 
 """
 import bz2, collections, itertools, math, random, os.path, time
 
 
 def model_network(smx, table=None, knn=1):
-    """Build network from model distance matrix."""
+    """Build network from model distance matrix.
+
+    :param smx: model distance matrix
+    :type smx: :obj:`Orange.misc.SymMatrix`
+    :param table: model meta data
+    :type table: :obj:`Orange.data.Table`
+    :param knn: connect each model with knn neighbours
+    :type knn: int
+
+    """
     graph = network.Graph()
     graph.add_nodes_from(range(smx.dim))
     graph.set_items(table)
                      np.array(instance_predictions),
                      np.array(instance_classes))
 
-    def build_projection_model(self, attributes, visualizationMethod):
-        """Build a projection meta-model."""
+    def build_projection_model(self, attributes, viz_method):
+        """Build a projection meta-model.
+
+        :param attributes: attributes for projection
+        :type attributes: list of strings
+        :param viz_method: visualization method
+        :type viz_method: enum
+
+        """
         method = "?"
-        if visualizationMethod == vr.SCATTERPLOT:
+        if viz_method == vr.SCATTERPLOT:
             graph = data.preprocess.scaling.ScaleScatterPlotData()
             method = "SCATTERPLOT"
-        elif visualizationMethod == vr.RADVIZ:
+        elif viz_method == vr.RADVIZ:
             graph = data.preprocess.scaling.ScaleLinProjData()
             graph.normalizeExamples = 1
             method = "RADVIZ"
-        elif visualizationMethod in [vr.LINEAR_PROJECTION, vr.KNN_IN_ORIGINAL_SPACE]:
+        elif viz_method in [vr.LINEAR_PROJECTION, vr.KNN_IN_ORIGINAL_SPACE]:
             graph = data.preprocess.scaling.ScaleLinProjData()
             graph.normalizeExamples = 0
             method = "SPCA"
-        elif visualizationMethod == vr.POLYVIZ:
+        elif viz_method == vr.POLYVIZ:
             graph = data.preprocess.scaling.ScalePolyvizData()
             graph.normalizeExamples = 1
             method = "POLYVIZ"
         classListFull = graph.original_data[graph.dataClassIndex]
         table = None
 
-        if visualizationMethod == vr.LINEAR_PROJECTION:
+        if viz_method == vr.LINEAR_PROJECTION:
             freeviz = projection.linear.FreeViz(graph)
             projections = freeviz.find_projection(vr.PROJOPT_SPCA, attrIndices, set_anchors=0, percent_data_used=100)
             if projections != None:
                 table = graph.create_projection_as_example_table(newIndices, XAnchors=XAnchors, YAnchors=YAnchors)
             else:
                 print 'a null projection found'
-        elif visualizationMethod == vr.SCATTERPLOT:
+        elif viz_method == vr.SCATTERPLOT:
             XAnchors = YAnchors = None
             table = graph.create_projection_as_example_table(attrIndices)
         else:
 
 
     def select_representatives(self, models, dist=distance_euclidean):
+        """Contruct a network, detect communities and return representatives.
+
+        :param models: select representatives from this models
+        :type models: list of :obj:`modelmaps.Model`
+        :param dist: distance function
+        :type dist: func
+
+        """
         print models[0].type
         smx = self.build_model_matrix(models, distance_euclidean)
         nc, knn = 2, 1
             cmedian = min(cdsts)[1]
             representatives.append(models[cmedian])
 
-        return representatives
+        return representatives