clustering factory: optional parameter handling

parent af0ce3e6
package de.monticore.lang.monticar.generator.middleware.clustering.algorithms;
import smile.clustering.SpectralClustering;
public class SpectralClusteringBuilder {
private double[][] data;
private Integer k;
private Integer l;
private Double sigma;
public SpectralClusteringBuilder(double[][] data, int k) {
this.data = data;
this.k = k;
}
public SpectralClusteringBuilder setData(double[][] data) {
this.data = data;
return this;
}
public SpectralClusteringBuilder setK(int k) {
this.k = k;
return this;
}
public SpectralClusteringBuilder setL(int l) {
this.l = l;
return this;
}
public SpectralClusteringBuilder setSigma(double sigma) {
this.sigma = sigma;
return this;
}
public SpectralClustering build() {
SpectralClustering sc;
if (this.l != null && this.sigma != null) sc = new SpectralClustering(data, k, l, sigma); else
if (this.sigma != null) sc = new SpectralClustering(data, k, sigma); else
sc = new SpectralClustering(data, k);
return sc;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment