当前位置: 首页>>代码示例>>Java>>正文


Java LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS属性代码示例

本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS属性的具体用法?Java LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS怎么用?Java LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.math3.exception.util.LocalizedFormats的用法示例。


在下文中一共展示了LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPointFromLargestVarianceCluster

/**
 * Get a random point from the {@link Cluster} with the largest distance variance.
 *
 * @param clusters the {@link Cluster}s to search
 * @return a random point from the selected cluster
 * @throws ConvergenceException if clusters are all empty
 */
private T getPointFromLargestVarianceCluster(final Collection<CentroidCluster<T>> clusters)
        throws ConvergenceException {

    double maxVariance = Double.NEGATIVE_INFINITY;
    Cluster<T> selected = null;
    for (final CentroidCluster<T> cluster : clusters) {
        if (!cluster.getPoints().isEmpty()) {

            // compute the distance variance of the current cluster
            final Clusterable center = cluster.getCenter();
            final Variance stat = new Variance();
            for (final T point : cluster.getPoints()) {
                stat.increment(distance(point, center));
            }
            final double variance = stat.getResult();

            // select the cluster with the largest variance
            if (variance > maxVariance) {
                maxVariance = variance;
                selected = cluster;
            }

        }
    }

    // did we find at least one non-empty cluster ?
    if (selected == null) {
        throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
    }

    // extract a random point from the cluster
    final List<T> selectedPoints = selected.getPoints();
    return selectedPoints.remove(random.nextInt(selectedPoints.size()));

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:42,代码来源:KMeansPlusPlusClusterer.java

示例2: getPointFromLargestNumberCluster

/**
 * Get a random point from the {@link Cluster} with the largest number of points
 *
 * @param clusters the {@link Cluster}s to search
 * @return a random point from the selected cluster
 * @throws ConvergenceException if clusters are all empty
 */
private T getPointFromLargestNumberCluster(final Collection<? extends Cluster<T>> clusters)
        throws ConvergenceException {

    int maxNumber = 0;
    Cluster<T> selected = null;
    for (final Cluster<T> cluster : clusters) {

        // get the number of points of the current cluster
        final int number = cluster.getPoints().size();

        // select the cluster with the largest number of points
        if (number > maxNumber) {
            maxNumber = number;
            selected = cluster;
        }

    }

    // did we find at least one non-empty cluster ?
    if (selected == null) {
        throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
    }

    // extract a random point from the cluster
    final List<T> selectedPoints = selected.getPoints();
    return selectedPoints.remove(random.nextInt(selectedPoints.size()));

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:35,代码来源:KMeansPlusPlusClusterer.java

示例3: getFarthestPoint

/**
 * Get the point farthest to its cluster center
 *
 * @param clusters the {@link Cluster}s to search
 * @return point farthest to its cluster center
 * @throws ConvergenceException if clusters are all empty
 */
private T getFarthestPoint(final Collection<CentroidCluster<T>> clusters) throws ConvergenceException {

    double maxDistance = Double.NEGATIVE_INFINITY;
    Cluster<T> selectedCluster = null;
    int selectedPoint = -1;
    for (final CentroidCluster<T> cluster : clusters) {

        // get the farthest point
        final Clusterable center = cluster.getCenter();
        final List<T> points = cluster.getPoints();
        for (int i = 0; i < points.size(); ++i) {
            final double distance = distance(points.get(i), center);
            if (distance > maxDistance) {
                maxDistance     = distance;
                selectedCluster = cluster;
                selectedPoint   = i;
            }
        }

    }

    // did we find at least one non-empty cluster ?
    if (selectedCluster == null) {
        throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
    }

    return selectedCluster.getPoints().remove(selectedPoint);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:36,代码来源:KMeansPlusPlusClusterer.java

示例4: getPointFromLargestVarianceCluster

/**
 * Get a random point from the {@link Cluster} with the largest distance variance.
 *
 * @param clusters the {@link Cluster}s to search
 * @return a random point from the selected cluster
 * @throws ConvergenceException if clusters are all empty
 */
private T getPointFromLargestVarianceCluster(final Collection<Cluster<T>> clusters)
throws ConvergenceException {

    double maxVariance = Double.NEGATIVE_INFINITY;
    Cluster<T> selected = null;
    for (final Cluster<T> cluster : clusters) {
        if (!cluster.getPoints().isEmpty()) {

            // compute the distance variance of the current cluster
            final T center = cluster.getCenter();
            final Variance stat = new Variance();
            for (final T point : cluster.getPoints()) {
                stat.increment(point.distanceFrom(center));
            }
            final double variance = stat.getResult();

            // select the cluster with the largest variance
            if (variance > maxVariance) {
                maxVariance = variance;
                selected = cluster;
            }

        }
    }

    // did we find at least one non-empty cluster ?
    if (selected == null) {
        throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
    }

    // extract a random point from the cluster
    final List<T> selectedPoints = selected.getPoints();
    return selectedPoints.remove(random.nextInt(selectedPoints.size()));

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:42,代码来源:KMeansPlusPlusClusterer.java

示例5: getPointFromLargestNumberCluster

/**
 * Get a random point from the {@link Cluster} with the largest number of points
 *
 * @param clusters the {@link Cluster}s to search
 * @return a random point from the selected cluster
 * @throws ConvergenceException if clusters are all empty
 */
private T getPointFromLargestNumberCluster(final Collection<Cluster<T>> clusters) throws ConvergenceException {

    int maxNumber = 0;
    Cluster<T> selected = null;
    for (final Cluster<T> cluster : clusters) {

        // get the number of points of the current cluster
        final int number = cluster.getPoints().size();

        // select the cluster with the largest number of points
        if (number > maxNumber) {
            maxNumber = number;
            selected = cluster;
        }

    }

    // did we find at least one non-empty cluster ?
    if (selected == null) {
        throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
    }

    // extract a random point from the cluster
    final List<T> selectedPoints = selected.getPoints();
    return selectedPoints.remove(random.nextInt(selectedPoints.size()));

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:34,代码来源:KMeansPlusPlusClusterer.java

示例6: getFarthestPoint

/**
 * Get the point farthest to its cluster center
 *
 * @param clusters the {@link Cluster}s to search
 * @return point farthest to its cluster center
 * @throws ConvergenceException if clusters are all empty
 */
private T getFarthestPoint(final Collection<Cluster<T>> clusters) throws ConvergenceException {

    double maxDistance = Double.NEGATIVE_INFINITY;
    Cluster<T> selectedCluster = null;
    int selectedPoint = -1;
    for (final Cluster<T> cluster : clusters) {

        // get the farthest point
        final T center = cluster.getCenter();
        final List<T> points = cluster.getPoints();
        for (int i = 0; i < points.size(); ++i) {
            final double distance = points.get(i).distanceFrom(center);
            if (distance > maxDistance) {
                maxDistance     = distance;
                selectedCluster = cluster;
                selectedPoint   = i;
            }
        }

    }

    // did we find at least one non-empty cluster ?
    if (selectedCluster == null) {
        throw new ConvergenceException(LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS);
    }

    return selectedCluster.getPoints().remove(selectedPoint);

}
 
开发者ID:biocompibens,项目名称:SME,代码行数:36,代码来源:KMeansPlusPlusClusterer.java


注:本文中的org.apache.commons.math3.exception.util.LocalizedFormats.EMPTY_CLUSTER_IN_K_MEANS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。