All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.chen0040.art.clustering.FuzzyARTClustering Maven / Gradle / Ivy

Go to download

Java implementation of Adaptive Resonance Theory (ART) algorithms such as ART, ARTMAP, FuzzyART

The newest version!
package com.github.chen0040.art.clustering;


import com.github.chen0040.art.core.FuzzyART;
import com.github.chen0040.data.frame.DataFrame;
import com.github.chen0040.data.frame.DataRow;
import com.github.chen0040.data.utils.transforms.ComplementaryCoding;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;

import java.util.HashSet;
import java.util.Set;


/**
 * Created by xschen on 21/8/15.
 */
@Getter
@Setter
public class FuzzyARTClustering {

    @Setter(AccessLevel.NONE)
    private FuzzyART net;

    @Setter(AccessLevel.NONE)
    @Getter(AccessLevel.NONE)
    private int initialNodeCount = 1;
    @Setter(AccessLevel.NONE)
    @Getter(AccessLevel.NONE)
    private boolean allowNewNodeInPrediction = false;

    @Setter(AccessLevel.NONE)
    private ComplementaryCoding inputNormalization;

    private int maxClusterCount = -1;

    private double alpha = 0.1;
    private double beta = 0.2;
    private double rho = 0.7;

    private Set clusterIds = new HashSet<>();

    public FuzzyARTClustering(){

    }


    public int transform(DataRow tuple) {
        return simulate(tuple, allowNewNodeInPrediction);
    }

    public void transform(DataFrame dataFrame) {
        for(int i=0; i  0 && !clusterIds.contains(clusterId) && clusterIds.size() >= maxClusterCount-1){
                create_node = false;
            }

            clusterIds.add(clusterId);
        }
    }

    public int simulate(DataRow tuple, boolean can_create_node){
        double[] x = tuple.toArray();
        x = inputNormalization.normalize(x);
        return net.simulate(x, can_create_node);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy