com.davidbracewell.apollo.ml.clustering.Clusterer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of apollo Show documentation
Show all versions of apollo Show documentation
A machine learning library for Java.
The newest version!
package com.davidbracewell.apollo.ml.clustering;
import com.davidbracewell.apollo.linear.NDArray;
import com.davidbracewell.apollo.ml.Instance;
import com.davidbracewell.apollo.ml.Learner;
import com.davidbracewell.apollo.ml.data.Dataset;
import com.davidbracewell.apollo.ml.encoder.EncoderPair;
import com.davidbracewell.conversion.Cast;
import com.davidbracewell.stream.MStream;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
/**
* Base class for clusterer learners.
*
* @param the clustering type parameter
* @author David B. Bracewell
*/
public abstract class Clusterer extends Learner {
private static final long serialVersionUID = 1L;
@Getter
@Setter
private EncoderPair encoderPair;
/**
* Clusters a stream of vectors.
*
* @param instances the instances
* @return the clustering model
*/
public abstract T cluster(MStream instances);
@Override
public void resetLearnerParameters() {
this.encoderPair = null;
}
@Override
public Clusterer setParameter(String name, Object value) {
return Cast.as(super.setParameter(name, value));
}
@Override
public Clusterer setParameters(Map parameters) {
return Cast.as(super.setParameters(parameters));
}
@Override
public T train(Dataset dataset) {
return Cast.as(super.train(dataset));
}
protected T trainImpl(Dataset dataset) {
this.encoderPair = dataset.getEncoderPair();
return cluster(dataset.asVectors());
}
}// END OF Clusterer
© 2015 - 2025 Weber Informatics LLC | Privacy Policy