Ver Fonte

refactor: extract clustering methods into JSON

jmacura há 4 anos atrás
pai
commit
2ef29db7fc
2 ficheiros alterados com 79 adições e 77 exclusões
  1. 7 77
      src/adjuster/adjuster.service.ts
  2. 72 0
      src/data/clustering_methods.json

+ 7 - 77
src/adjuster/adjuster.service.ts

@@ -5,6 +5,7 @@ import {HsDialogContainerService} from 'hslayers-ng/components/layout/dialogs/di
 import {HsUtilsService} from 'hslayers-ng/components/utils/utils.service';
 
 // import attractivity from '../Attractivity.json';
+import clusteringMethods from '../data/clustering_methods.json';
 import {AdjusterEventService} from './adjuster-event.service';
 import {AdjusterLoaderComponent} from './adjuster-loader.component';
 import {nuts} from '../nuts';
@@ -17,83 +18,11 @@ export class AdjusterService {
   clusters = [];
   numberOfClusters = 12;
   method: string;
-  methods = [
-    {
-      codename: 'km25.cluster',
-      name: 'k-means (25 random sets, Hartigan-Wong method)',
-      type: 'non-hierarchical',
-    },
-    {
-      codename: 'km50hw.cluster',
-      name: 'k-means (50 random sets, Hartigan-Wong method)',
-      type: 'non-hierarchical',
-    },
-    {
-      codename: 'km50l.cluster',
-      name: 'k-means (50 random sets, Lloyd method)',
-      type: 'non-hierarchical',
-    },
-    {
-      codename: 'km50m.cluster',
-      name: 'k-means (50 random sets, MacQueen method)',
-      type: 'non-hierarchical',
-    },
-    {
-      codename: 'kme_eu.cluster',
-      name: 'partitioning (Euclidean distance matrix)',
-      type: 'non-hierarchical',
-    },
-    {
-      codename: 'kme_mn.cluster',
-      name: 'partitioning (Manhattan distance matrix)',
-      type: 'non-hierarchical',
-    },
-    {
-      codename: 'haclust',
-      name: 'complete linkage (Euclidean distance matrix)',
-      type: 'hierarchical',
-    },
-    {
-      codename: 'haclustmin',
-      name: 'complete linkage (Minkowski distance matrix)',
-      type: 'hierarchical',
-    },
-    {
-      codename: 'haclustbin',
-      name: 'complete linkage (asymmetric binary distance matrix)',
-      type: 'hierarchical',
-    },
-    {
-      codename: 'haclustman',
-      name: 'complete linkage (Manhattan distance matrix)',
-      type: 'hierarchical',
-    },
-    {
-      codename: 'haclustmax',
-      name: 'complete linkage ("Supremum norm" distance matrix)',
-      type: 'hierarchical',
-    },
-    {
-      codename: 'haclustcan',
-      name: 'complete linkage (Canberra distance matrix)',
-      type: 'hierarchical',
-    },
-    /*{
-      codename: 'haclustcom',
-      name: 'complete linkage (Euclidean distance matrix)',
-      type: 'hierarchical',
-    },*/
-    {codename: 'haclustwd2', name: 'Ward2', type: 'hierarchical'},
-    {codename: 'haclustsin', name: 'single linkage', type: 'hierarchical'},
-    {codename: 'haclustcen', name: 'centroid (UPGMC)', type: 'hierarchical'},
-    {codename: 'haclustmed', name: 'median (WPGMC)', type: 'hierarchical'},
-    {codename: 'haclustmcq', name: 'McQuitty (WPGMA)', type: 'hierarchical'},
-    {
-      codename: 'hdclust',
-      name: 'DIANA (DIvisive ANAlysis)',
-      type: 'hierarchical',
-    },
-  ];
+  methods: Array<{
+    codename: string;
+    name: string;
+    type: string;
+  }>;
   private _clusteringInProcess: boolean;
 
   constructor(
@@ -106,6 +35,7 @@ export class AdjusterService {
       window.location.hostname === 'localhost'
         ? 'https://jmacura.ml/ws/' // 'http://localhost:3000/'
         : 'https://publish.lesprojekt.cz/nodejs/';
+    this.methods = clusteringMethods;
     this.method = 'haclustwd2';
   }
 

+ 72 - 0
src/data/clustering_methods.json

@@ -0,0 +1,72 @@
+[
+  {
+    "codename": "km25.cluster",
+    "name": "k-means (25 random sets, Hartigan-Wong method)",
+    "type": "non-hierarchical"
+  },
+  {
+    "codename": "km50hw.cluster",
+    "name": "k-means (50 random sets, Hartigan-Wong method)",
+    "type": "non-hierarchical"
+  },
+  {
+    "codename": "km50l.cluster",
+    "name": "k-means (50 random sets, Lloyd method)",
+    "type": "non-hierarchical"
+  },
+  {
+    "codename": "km50m.cluster",
+    "name": "k-means (50 random sets, MacQueen method)",
+    "type": "non-hierarchical"
+  },
+  {
+    "codename": "kme_eu.cluster",
+    "name": "partitioning (Euclidean distance matrix)",
+    "type": "non-hierarchical"
+  },
+  {
+    "codename": "kme_mn.cluster",
+    "name": "partitioning (Manhattan distance matrix)",
+    "type": "non-hierarchical"
+  },
+  {
+    "codename": "haclust",
+    "name": "complete linkage (Euclidean distance matrix)",
+    "type": "hierarchical"
+  },
+  {
+    "codename": "haclustmin",
+    "name": "complete linkage (Minkowski distance matrix)",
+    "type": "hierarchical"
+  },
+  {
+    "codename": "haclustbin",
+    "name": "complete linkage (asymmetric binary distance matrix)",
+    "type": "hierarchical"
+  },
+  {
+    "codename": "haclustman",
+    "name": "complete linkage (Manhattan distance matrix)",
+    "type": "hierarchical"
+  },
+  {
+    "codename": "haclustmax",
+    "name": "complete linkage (\"Supremum norm\" distance matrix)",
+    "type": "hierarchical"
+  },
+  {
+    "codename": "haclustcan",
+    "name": "complete linkage (Canberra distance matrix)",
+    "type": "hierarchical"
+  },
+  {"codename": "haclustwd2", "name": "Ward2", "type": "hierarchical"},
+  {"codename": "haclustsin", "name": "single linkage", "type": "hierarchical"},
+  {"codename": "haclustcen", "name": "centroid (UPGMC)", "type": "hierarchical"},
+  {"codename": "haclustmed", "name": "median (WPGMC)", "type": "hierarchical"},
+  {"codename": "haclustmcq", "name": "McQuitty (WPGMA)", "type": "hierarchical"},
+  {
+    "codename": "hdclust",
+    "name": "DIANA (DIvisive ANAlysis)",
+    "type": "hierarchical"
+  }
+]