def train(train_dataa, train_dataa_size, cluster_size, iteration_size,
          dimension_size, m, gama):
    """ remove class column"""
    train_data = train_dataa.T[:len(train_dataa.T) - 1].T

    centers, memberShip_train = FCM.fcm(train_data, train_dataa_size,
                                        cluster_size, iteration_size,
                                        dimension_size, m)
    """ to find out what G and W are see project definition"""
    G = cal_G(train_data, centers, memberShip_train, gama, train_dataa_size)
    W = cal_w(G, train_dataa, cluster_size, len(train_dataa))

    return W, centers
Exemplo n.º 2
0
    arr1[:, 2] = arr[:, max1]
    #print(arr1)
    c1 = []
    c1.append(c[min1])
    c1.append(c[mid])
    c1.append(c[max1])
    return arr1, c1


dicid, dicnum, dicpingid = makeGroup()
arr = []
cdic = {}
for i in dicid:
    if len(set(dicnum[i])) > 4:
        #print(i)
        arr1, c = FCM.fcm(dicnum[i])
        #使数据按照大中小剂量排列
        #print(arr1)
        arr2, d = sortbydic(arr1, c)
        for j in range(len(arr2)):
            li = []
            li.append(i)
            li.append(dicid[i][j])
            li.append(dicpingid[i][j])
            li.append(dicnum[i][j])
            li.append(list(arr2[j]))
            arr.append(li)
        cdic[i] = d
for i in cdic:
    print(i, cdic[i])
csv_pd = pd.DataFrame(arr)