コード例 #1
0
ファイル: fcm_2d.py プロジェクト: zhangjingcode/fuzzy-c-means
def example():
    X = np.array([[1, 1], [1, 2], [2, 2], [9, 10], [10, 10], [10, 9], [9, 9],
                  [20, 20]])
    fcm = FCM(n_clusters=3)
    fcm.set_logger(tostdout=True, level=logging.DEBUG)
    fcm.fit(X, [0, 0, 0, 1, 1, 1, 1, 2])
    # fcm.fit(X)
    testing_data = np.array([[0, 1.9], [5, 3], [4, 4], [8, 9], [9.5, 6.5],
                             [5, 5], [15, 15], [12, 12], [14, 14], [19, 10]])
    predicted_membership = fcm.predict(testing_data)
    print "\n\ntesting data"
    print testing_data
    print "predicted membership"
    print predicted_membership
    print "\n\n"
    draw_model_2d(fcm, data=testing_data, membership=predicted_membership)
コード例 #2
0
def test_logger():
    fcm = FCM()
    fcm.get_logger()
    fcm.set_logger(tostdout=True, logfilename="output.html")