1. Miha Stajdohar
  2. orange-modelmaps

Source

orange-modelmaps / archive / build_astra_map.py

import Orange
import orngVizRank as vr

from tools import *
from build_model_map import save_models, models2matrix, build_projection_model

FOLDS = 10
MODEL_LIMIT = 3000

#data_c = getData(ROOT + "tab/zoo-c.tab")
data_d = getData(ROOT + "tab/639_500FPRDK.tab")

indices = Orange.core.MakeRandomIndicesCV(data_d, FOLDS, randseed=0, stratified=Orange.core.MakeRandomIndices.StratifiedIfPossible)
##
#attributes  = getRandomAttributeSubsets(data_d.domain, MODEL_LIMIT)
#attributes += [[var.name for var in data_d.domain if var != data_d.domain.classVar]]
##
##attributes = [ex['attributes'].value for ex in orange.ExampleTable(ROOT + 'new\\zoo-420.tab') if ex['model'].value != 'SCATTERPLOT']
##attributes = set(attributes)
##attributes = [attr.split(', ') for attr in attributes]
##
##
models = []
scatterplot_attributes = []
for i in range(len(data_d.domain.attributes)):
    for j in range(i):
        scatterplot_attributes.append([data_d.domain.attributes[i].name, data_d.domain.attributes[j].name])

print "attributes:", len(data_d.domain.attributes)
print "attribute combinations:", len(scatterplot_attributes)
random.shuffle(scatterplot_attributes)
models.extend([build_projection_model(data_d, attrs, indices, vr.SCATTERPLOT) for attrs in scatterplot_attributes[:MODEL_LIMIT]])

#for projection_type in [vr.LINEAR_PROJECTION, vr.RADVIZ, vr.POLYVIZ]:
#    models.extend([build_projection_model(data_d, attrs, indices, projection_type) for attrs in attributes])

models = [model for model in models if model is not None]
smx_rank = models2matrix(models)

save_models(models, smx_rank, '%s-%d' % (OUT_FILE, len(smx_rank)))