@@ -0,0 +1,2195 @@
+%0Aimport numpy as np%0Afrom gala import imio, classify, features, agglo, evaluate as ev%0Agt_train, pr_train, p4_train, ws_train = map(imio.read_h5_stack, %5B'example-data/train-gt.lzf.h5', 'example-data/train-p1.lzf.h5', 'example-data/train-p4.lzf.h5', 'example-data/train-ws.lzf.h5'%5D)%0Agt_test, pr_test, p4_test, ws_test = map(imio.read_h5_stack, %5B'example-data/test-gt.lzf.h5', 'example-data/test-p1.lzf.h5', 'example-data/test-p4.lzf.h5', 'example-data/test-ws.lzf.h5'%5D)%0Afm = features.moments.Manager()%0Afh = features.histogram.Manager()%0Afc = features.base.Composite(children=%5Bfm, fh%5D)%0Ag_train = agglo.Rag(ws_train, pr_train, feature_manager=fc)%0Anp.random.RandomState(0)%0A(X, y, w, merges) = map(np.copy, map(np.ascontiguousarray,%0A                        g_train.learn_agglomerate(gt_train, fc)%5B0%5D))%0Aprint X.shape%0Anp.savez('example-data/train-set.npz', X=X, y=y)%0Ay = y%5B:, 0%5D%0Arf = classify.DefaultRandomForest()%0AX.shape%0Anp.random.RandomState(0)%0Arf = rf.fit(X, y)%0Aclassify.save_classifier(rf, 'example-data/rf1.joblib')%0Alearned_policy = agglo.classifier_probability(fc, rf)%0Ag_test = agglo.Rag(ws_test, pr_test, learned_policy, feature_manager=fc)%0Ag_test.agglomerate(0.5)%0Aseg_test1 = g_test.get_segmentation()%0Aimio.write_h5_stack(seg_test1, 'example-data/test-seg1.lzf.h5', compression='lzf')%0Ag_train4 = agglo.Rag(ws_train, p4_train, feature_manager=fc)%0Anp.random.RandomState(0)%0A(X4, y4, w4, merges4) = map(np.copy, map(np.ascontiguousarray,%0A                            g_train4.learn_agglomerate(gt_train, fc)%5B0%5D))%0Aprint X4.shape%0Anp.savez('example-data/train-set4.npz', X=X4, y=y4)%0Ay4 = y4%5B:, 0%5D%0Arf4 = classify.DefaultRandomForest()%0Anp.random.RandomState(0)%0Arf4 = rf4.fit(X4, y4)%0Aclassify.save_classifier(rf4, 'example-data/rf4.joblib')%0Alearned_policy4 = agglo.classifier_probability(fc, rf4)%0Ag_test4 = agglo.Rag(ws_test, p4_test, learned_policy4, feature_manager=fc)%0Ag_test4.agglomerate(0.5)%0Aseg_test4 = g_test4.get_segmentation()%0Aimio.write_h5_stack(seg_test4, 'example-data/test-seg4.lzf.h5', compression='lzf')%0A%0Aresults = np.vstack((%0A    ev.split_vi(ws_test, gt_test),%0A    ev.split_vi(seg_test1, gt_test),%0A    ev.split_vi(seg_test4, gt_test)%0A    ))%0A%0Anp.save('example-data/vi-results.npy', results)%0A%0A

Add function used to generate test data