小编Shi*_*rma的帖子

在KMeans聚类之后找到聚类的长度(与聚类关联的点数)(scikit学习)

我已经使用sklearn使用Kmeans完成了聚类。尽管它有一种打印质心的方法,但我发现scikit-learn没有找到簇长的方法(或者到目前为止我还没有看到它)真是太奇怪了。是否有一种巧妙的方法来获取每个群集的群集长度或与群集关联的许多点?我现在有这个相当笨拙的代码,在我发现长度为一的簇的情况下,并且需要通过测量点之间的欧几里得距离来向该簇添加其他点,并且必须更新标签

import numpy as np
from clustering.clusternew import Kmeans_clu
from evolution.generate import reproduction
from mapping.somnew import mapping, no_of_neurons, neuron_weights_init
from population_creation.population import pop_create
from New_SOL import newsol


data = genfromtxt('iris.csv', delimiter=',', skip_header=0, usecols=range(0, 4)) ##Read the input data
actual_label = genfromtxt('iris.csv', delimiter=',', dtype=str,skip_header=0, usecols=(4))
chromosome = int(input("Enter the number of chromosomes: "))  #Input the population size
max_gen = int(input("Enter the maximum number of generation: "))  #Input the maximum number of generation

for i in range(0, chromosome):
    cluster = 3#random.randint(2, max_cluster) …
Run Code Online (Sandbox Code Playgroud)

python machine-learning k-means unsupervised-learning scikit-learn

3
推荐指数
1
解决办法
3279
查看次数

如何存储字符串的不同字符

public class NoDuplicate { 
    static final int NO_OF_CHARS = 256; 
       
    /* Print duplicates present in the passed string */
    static void printDistinct(String str) 
    { 
        // Create an array of size 256 and count of 
        // every character in it 
        int[] count = new int[NO_OF_CHARS]; 
       
        /* Count array with frequency of characters */
        int i; 
        for (i = 0; i < str.length(); i++) 
            if(str.charAt(i)!=' ') 
                count[(int)str.charAt(i)]++; 
        int n = i; 
       
        // Print characters having count more than 0 
        for (i = …
Run Code Online (Sandbox Code Playgroud)

java string

3
推荐指数
1
解决办法
3549
查看次数