HRLAlgorithms
Wrapper around LearnKit to easy its integration in Swift CocoaPods.
Installation
HRLAlgorithms is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "HRLAlgorithms"
Usage
#import "HRLMatrix.h"
#import "HRLMatrixSplitter.h"
#import "HRLSplittedMatrix.h"
#import "HRLTrainedKNNClassifier.h"
#import "HRLTrainedKNNClassifierFactory.h"
#import "HRLVector.h"
id<HRLMatrix> matrix = ...;
id<HRLMatrixSplitter> splitter = [[HRLMatrixSplitter alloc] init];
HRLSplittedMatrix *splittedMatrix = [splitter splittedMatrixWithMatrix:matrix
trainingBias:0.75f];
id<HRLTrainedKNNClassifierFactory> factory = [[HRLTrainedKNNClassifierFactory alloc] init];
id<HRLTrainedKNNClassifier> classifier = [factory makeTrainedKNNClassifierWithMatrix:splittedMatrix.trainingMatrix
neighborsCount:5];
NSLog(@"Accuracy: %f", [classifier estimatedAccuracyWithMatrix:splittedMatrix.testMatrix]);
id<HRLVector> vector = ...;
NSLog(@"Predicted class: %lu", (unsigned long)[classifier predictedClassForVector:vector]);
License
HRLAlgorithms is available under the MIT license. See the LICENSE file for more info.