KRFuzzyCMeans 1.4

KRFuzzyCMeans 1.4

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最后发布2016年1月

Kalvar Lin维护。



io

KRFuzzyCMeans 已实现模糊C均值(FCM)聚类/分类算法,该算法在机器学习领域中使用。它可用于数据挖掘和图像压缩。如果您想了解如何使用它的详细信息,可以通过电子邮件与我联系。

Podfile

platform :ios, '7.0'
pod "KRFuzzyCMeans", "~> 1.4"

如何使用

导入

#import "KRFuzzyCMeans.h"
距离方法
KRFuzzyCMeansDistanceFormulaEuclidean
KRFuzzyCMeansDistanceFormulaCosine
KRFuzzyCMeansDistanceFormulaRBF

训练

KRFuzzyCMeans *_krFcm   = [KRFuzzyCMeans sharedFCM];
_krFcm.doneThenSave     = YES;
_krFcm.m                = 3;
_krFcm.convergenceError = 0.001f;
_krFcm.distanceFormula  = KRFuzzyCMeansDistanceFormulaEuclidean; //KRFuzzyCMeansDistanceFormulaCosine
[_krFcm addCenters:@[@5.0f, @5.0f]];     //The center 1, cluster 1 start in here
[_krFcm addCenters:@[@10.0f, @10.0f]];   //The center 2, cluster 2 start in here
[_krFcm addCenters:@[@12.0f, @14.0f]];   //The center 3, cluster 3 start in here
[_krFcm addPatterns:@[@[@2, @12], @[@4, @9], @[@7, @13], @[@11, @5], @[@12, @7], @[@14, @4]]];

[_krFcm clusterWithCompletion:^(BOOL success, NSArray *clusters, NSArray *centrals, NSInteger totalTimes)
{
    NSLog(@"\n\n===============================================\n\n");
    NSLog(@"totalTimes : %li", totalTimes);
    NSLog(@"results : %@", clusters);
    NSLog(@"centrals : %@", centrals);
    NSLog(@"\n\n===============================================\n\n");

    //Directly verify and classify others pattern without continually training the centers, you could use :
    [_krFcm directClusterPatterns:@[@[@2, @3], @[@3, @3], @[@5, @9]]];
    [_krFcm printResults];

    //If you have one or more patterns need to do standard classification, use this to renew all groups and re-adjust the central groups :
    [_krFcm addPatterns:@[@[@2, @3], @[@3, @3], @[@5, @9]]];
    [_krFcm clusterWithCompletion:^(BOOL success, NSArray *clusters, NSArray *centrals, NSInteger totalTimes)
    {
        [_krFcm printResults];
        //... Do your next step.
    }];

} perIteration:^(NSInteger times, NSArray *clusters, NSArray *centrals)
{
    NSLog(@"times : %li", times);
    NSLog(@"clusters : %@", clusters);
    NSLog(@"centrals : %@", centrals);
}];

回忆训练中心

// Recalling tranined centers that last saved.
[_krFcm recallCenters];
// Then, start to train or directly cluster the patterns.
[_krFcm directClusterPatterns:@[@[@1, @5], @[@4, @2], @[@7, @3]]];

版本

V1.4}

许可

MIT.