Source

orange-modelmaps / archive / addModel.py

Full commit
import pickle

from tools import *

mergedFile = ROOT + "dst/breast-allmodels-468"
modelFile = ROOT + "dst/breast-svms-510"
model_ratio = 0.0
model_knn = 4

merged_res = pickle.load(open("%s.res" % mergedFile, 'rb'))
merged_smx, merged_labels, merged_data = OWDistanceFile.readMatrix("%s.dst" % mergedFile)
merged_smx.items = orange.ExampleTable("%s.tab" % mergedFile)

model_res = pickle.load(open("%s.res" % modelFile, 'rb'))
model_smx, model_labels, model_data = OWDistanceFile.readMatrix("%s.dst" % modelFile)
model_smx.items = orange.ExampleTable("%s.tab" % modelFile)
model_net = matrix2network(model_smx, model_ratio, model_knn)
model_net.items = merged_smx.items

median_matrix, medians, csizes, bests = cluster2matrix(model_net, model_smx)

for j, m in enumerate(medians):
    #vizrs[i][m][5]['Method'] = methods[i]
    #models.append(methods[i])
    
    ex = orange.Example(merged_smx.items.domain)
    ex["uuid"] = nets[i].items[m]["uuid"].value
    ex["number of attributes"] = nets[i].items[m]["number of attributes"].value
    ex["CA"] = nets[i].items[m]["CA"].value
    ex["AUC"] = nets[i].items[m]["AUC"].value
    ex["cluster CA"] = best_indices[i][j]
    ex["attributes"] = nets[i].items[m]["attributes"].value
    ex["model"] = nets[i].items[m]["model"].value
    ex["cluster size"] = median_csizes[i][j]
    merged_smx.items.append(ex)
    
merged_vizr_res.extend([vizrs[i][m] for m in medians])
merged_proj_points.extend([projs_points[i][m] for m in medians])
results.extend([vizrs[i][m][5].get("Results").results for m in medians])