Miha Stajdohar avatar Miha Stajdohar committed c6b442c

All kind of changes. Mostly bugs, tried out some new ideas...

Comments (0)

Files changed (5)

_modelmaps/modelmap.py

             return 0
 
     max_features = len(domain.features) if max_features is None else min(max_features, len(domain.features))
-    min_features = 2 if max_features is None else max(min(min_features, max_features), 2)
+    min_features = 2 if min_features is None else max(min(min_features, max_features), 2)
 
     attrs = [var.name for var in domain.features]
     nattrs = len(attrs)

_modelmaps/widgets/OWModelMap.py

 from OWNxHist import *
 from OWDistributions import OWDistributionGraph
 
+from PyQt4 import QtCore
+
 dir = utils.environ.widget_install_dir
 
 ICON_PATHS = [("TREE", "Classify/icons/ClassificationTree"),
         if y is not None:
             self.set_y(y)
 
+    def paint(self, painter, option, widget):
+        orangeqt.ModelItem.paint(self, painter, option, widget)
+
+        lbl = self.text()
+
+        if lbl == "":
+            return
+
+        metrics = painter.fontMetrics()
+        th = metrics.height()
+
+        pen = painter.pen()
+        pen.setColor(QtCore.Qt.black)
+        painter.setPen(pen)
+
+        for i, l in enumerate(lbl.split(", ")):
+            tw = metrics.width(l)
+            r = QtCore.QRectF(-tw / 2., self.size() / 2. + 5 + i * th, tw, th);
+            painter.drawText(r, QtCore.Qt.AlignCenter, l);
+
 class ModelCurve(NetworkCurve):
     def __init__(self, parent=None, pen=QPen(Qt.black), xData=None, yData=None):
         NetworkCurve.__init__(self, parent, pen=QPen(Qt.black), xData=None, yData=None)
         self.set_node_styles()
         self.set_node_colors()
 
+        self.networkCanvas.set_node_labels(["attributes"])
+
         labels = self.matrix.originalData.domain.classVar.values.native()
         self.predGraph.numberOfBars = len(labels)
         self.predGraph.barSize = 200 / (self.predGraph.numberOfBars + 1)

examples/projections/distance_metric_comparisson.py

 #ROOT = "/Network/Servers/xgridcontroller.private/lab/mihas/modelmaps"
 #ROOT = "C:\\Users\\Miha\\work\\res\\modelmaps"
 
-def build_map_for_metric_comparisson(DATASET, N):
+def build_map_for_metric_comparisson(DATASET, N, max_features=None):
     print "DATA SET: %s" % DATASET
 
     fname = os.path.join(utils.environ.dataset_install_dir, "%s%s" % (DATASET, ".tab"))
     build_map = mm.BuildModelMap(fname)
 
     nfeatures = len(build_map.data_d.domain.features)
-    features = mm.get_feature_subsets(build_map.data_d.domain, N, min_features=3, max_features=8)
+    features = mm.get_feature_subsets(build_map.data_d.domain, N, min_features=3, max_features=max_features)
 
     max_nfeatures_scatterplot = (nfeatures ** 2 - nfeatures) / 2
     features_scatterplot = mm.get_feature_subsets_scatterplot(build_map.data_d.domain, max_nfeatures_scatterplot)
 
+    print  "N:", len(features), " N scatterplot:", len(features_scatterplot)
+
     models = []
     models.extend([build_map.build_projection_model(f, vr.LINEAR_PROJECTION) for f in features])
     models.extend([build_map.build_projection_model(f, vr.RADVIZ) for f in features])
         print keys[i], "  ",
         print "  ".join(["%s: %e" % (keys[j], res[keys[i]][keys[j]]["rank p"]) for j in range(i)])
 
-#smxs = build_map_for_metric_comparisson("zoo", N=1000)
-#smxs, table, data = mm.load(os.path.join(ROOT, "_projections_", "proj_alldist_4_zoo_1000"))
+
+#smxs = build_map_for_metric_comparisson("breast-cancer-wisconsin", None)
 #matrix_correlation(smxs)
 
-#smxs = build_map_for_metric_comparisson("breast-cancer-wisconsin", N=501)
-#matrix_correlation(smxs)
+smxs = build_map_for_metric_comparisson("dermatology", N=1000, max_features=8)
+matrix_correlation(smxs)
 
-#smxs = build_map_for_metric_comparisson("voting", N=1000)
-#matrix_correlation(smxs)
+smxs = build_map_for_metric_comparisson("iris", None)
+matrix_correlation(smxs)
 
-#smxs = build_map_for_metric_comparisson("iris", N=10)
-#matrix_correlation(smxs)
+smxs = build_map_for_metric_comparisson("voting", N=1000, max_features=8)
+matrix_correlation(smxs)
 
-smxs = build_map_for_metric_comparisson("dermatology", N=1000)
-matrix_correlation(smxs)
+smxs = build_map_for_metric_comparisson("zoo", N=1000, max_features=8)
+#smxs, table, data = mm.load(os.path.join(ROOT, "_projections_", "proj_alldist_4_zoo_1000"))
+matrix_correlation(smxs)

examples/projections/radviz.py

         class_list = graph.original_data[graph.data_class_index]
 
         validData = graph.getValidList(attr_indices)
-        transProjData = graph.createProjectionAsNumericArray(attr_indices, validData=validData, normalize=graph.normalizeExamples, jitterSize=-1, useAnchorData=1, removeMissingData=0)
+        transProjData = graph.createProjectionAsNumericArray(attr_indices, validData=validData, normalize=graph.normalizeExamples, jitterSize=0.1, useAnchorData=1, removeMissingData=0)
         projData = transProjData.T
 
         ax = fig.add_subplot(3, 2, i)
 
 
         ax.set_axis_off()
-        ax.set_xlim(-1.1, 1.1)
-        ax.set_ylim(-1.1, 1.1)
+        ax.set_xlim(-1.2, 1.2)
+        ax.set_ylim(-1.2, 1.2)
 
         ax.set_title(r"$\overline{P}=%.2f$" % (model_instance["P"].value * 100), weight='bold', size='medium', position=(0.5,   1.01),
                         horizontalalignment='center', verticalalignment='center')

examples/projections/scatterplot.py

 
     def add_subplot(fig, score, attrs, i=1):
         graph = data.preprocess.scaling.ScaleScatterPlotData()
+        graph.jitter_continuous = True
+
         graph.setData(original_data, graph.rawSubsetData)
+        graph.rescaleData()
+
         attr_indices = [graph.attribute_name_index[attr] for attr in attrs]
         selected_data = np.take(graph.scaled_data, attr_indices, axis=0)
         class_list = graph.original_data[graph.data_class_index]
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.