MaetDol / k-means-js

K-means for javascript
Apache License 2.0
5 stars 0 forks source link

Labeled data #1

Open MaetDol opened 4 years ago

MaetDol commented 4 years ago

Can we use labeled data like:

[
  {
    label: 'MaetDol',
    data: [15.3, 12, 6],
  },
  {
    label: 'Unkown',
    data: [6, 42, 3],
  },
  {
    label: 'javascript',
    data: [13, 15, 4],
  },
  {
    label: 'C',
    data: [21, 34, 12],
  },
]

Then result like be:

[
  {
    centroid: [12.3333, 21.21, 6.33],
    label: 'centroid1',
    cluster: [
      {
        label: 'MaetDol',
        data: [15.3, 12, 6],
      },
      {
        label: 'Unkown',
        data: [6, 42, 3],
      },
      {
        label: 'javascript',
        data: [13, 15, 4],
      },
      {
        label: 'C',
        data: [21, 34, 12],
      },
      // and so on
    ]
  },
  {
    centroid: [16.3333, 8.21, 9.33],
    label: 'centroid2',
    cluster: [
      // same like above
    ]
  },
  // and so on
]
MaetDol commented 4 years ago

If can use custom calculation, be implemented easy calculation methods may:

except sub method the form of the return value should be the same as the first