public BipartiteSparseRepresentations runSimClusters()

in src/main/java/com/twitter/sbf/core/SimClustersInMemory.java [584:629]


  public BipartiteSparseRepresentations runSimClusters() {
    //Perform steps one and two to get right representations
    SparseRealMatrix representationsForRight = this.getRepresentationsForRight();

    //Perform step three to get the representation vectors for the left vertices using the
    //representationsForRight matrix. This will be an m X k' matrix.
    SparseRealMatrix representationsForLeft =
        this.getRepresentationsForLeft(representationsForRight);
    //If rows have to normalized in the left matrix, do that
    if (this.normalizeRowsLeft) {
      System.out.println("Normalizing left embeddings");
      representationsForLeft.normalizeToUnitColumn();
    }
    //If applyLogTransform is true, then apply the log10(1+x) transform
    if (this.applyLogTransform) {
      System.out.println("Applying coordinate-wise log10(1+x) transform");
      representationsForLeft.applyCoordinateWiseLogTransform();
    }
    //If fourth step needs to performed
    if (this.applyStepFour) {
      System.out.println("Applying Step Four");
      double sparsityBeforeStepFour = representationsForRight.getAverageNNZ();
      System.out.println(
        String.format(
            "Average NNZ per row in right representation matrix before step 4: %f",
            sparsityBeforeStepFour
        )
      );
      representationsForRight = this.updateRepresentationsForRight(representationsForLeft);
      double sparsityAfterStepFour = representationsForRight.getAverageNNZ();
      System.out.println(
        String.format(
            "Average NNZ per row in right representation matrix after step 4: %f",
            sparsityAfterStepFour
        )
      );
    }
    //We now return a BipartiteSparseRepresentation object that contains the representations for the
    //left and right vertices.
    BipartiteSparseRepresentations newRepresentation =
        new BipartiteSparseRepresentations(
            representationsForLeft,
            representationsForRight
        );
    return newRepresentation;
  }