public static void Apply(IRandom random, LinearLinkage lle, int index)
        {
            var groups = lle.Select((val, idx) => Tuple.Create(idx, val))
                         .Where(x => x.Item1 == x.Item2)
                         .Select(x => x.Item2).ToList();
            var z = groups.Count;

            if (random.NextDouble() < 0.5)
            {
                lle[index] = index; // divide the cluster into two
            }
            else
            {
                var c = random.Next(z);
                if (groups[c] > index)
                {
                    lle[index] = groups[c]; // combine the portion with another class
                }
                else
                {
                    // combine the other class here
                    lle[groups[c]] = lle[index];
                    lle[index]     = index;
                }
                lle.LinearizeTreeStructures();
            }
        }
Exemplo n.º 2
0
    public static void Apply(IRandom random, LinearLinkage lle, int index) {
      var groups = lle.Select((val, idx) => Tuple.Create(idx, val))
                      .Where(x => x.Item1 == x.Item2)
                      .Select(x => x.Item2).ToList();
      var z = groups.Count;

      if (random.NextDouble() < 0.5)
        lle[index] = index; // divide the cluster into two
      else {
        var c = random.Next(z);
        if (groups[c] > index)
          lle[index] = groups[c]; // combine the portion with another class
        else {
          // combine the other class here
          lle[groups[c]] = lle[index];
          lle[index] = index;
        }
        lle.LinearizeTreeStructures();
      }
    }