Commits

Miha Stajdohar committed 1ba95b0

Build 5 different RF maps.

  • Participants
  • Parent commits 2290960

Comments (0)

Files changed (1)

File examples/ensemble/build_rf.py

+__author__ = '"Miha Stajdohar" <miha.stajdohar@gmail.com>'
+
+import matplotlib
+matplotlib.use('Agg')
+
+import os.path, sys
+import numpy as np
+import _modelmaps as mm
+#import cPickle as pickle
+
+from Orange import data, utils
+
+ROOT = "/home/miha/work/res/modelmaps"
+ROOT = "C:\\Users\\Miha\\work\\res\\modelmaps"
+#ROOT = "/Network/Servers/xgridcontroller.private/lab/mihas/modelmaps"
+
+def build_rd_map(DATASET):
+    fname = os.path.join(utils.environ.dataset_install_dir, "%s%s" % (DATASET, ".tab"))
+
+    if not (os.path.exists(fname) and os.path.isfile(fname)):
+        fname = os.path.join(ROOT, "tab", "%s%s" % (DATASET, ".tab"))
+
+        if not (os.path.exists(fname) and os.path.isfile(fname)):
+            raise IOError("File %s not found." % fname)
+
+    build_map = mm.BuildModelMap(fname)
+
+    trees = 300
+    depth = 1000
+
+    print "build models..."
+    models, rf_classifier = build_map.build_rf_models(trees=trees, max_depth=depth)
+
+    print "build model data..."
+    table = build_map.build_model_data(models)
+
+    print "build matrix..."
+    smx = build_map.build_model_matrix(models)
+    mm.save(os.path.join(ROOT, "_ensemble_", "rf_%s_%d_depth_None_%s" % (DATASET, trees, sys.platform)), smx, table, build_map.data())
+
+build_rd_map("zoo")
+build_rd_map("marketing")
+build_rd_map("vehicle")
+build_rd_map("iris")
+build_rd_map("voting")