Machine Learning algorithm named Delta learning method.
Objective-C Ruby
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
KRDelta.xcodeproj
KRDelta
ML
.gitignore
KRDelta.podspec
LICENSE
README.md

README.md

About

KRDelta is a supervised learning which Delta rule of Machine Learning, it still works in recommendation system and real-time user behavior analysis on mobile apps.

Podfile

platform :ios, '8.0'
pod 'KRDelta', '~> 1.6.0'

How To Get Started

Import

#import "KRDelta.h"

Normal Case

KRDelta *delta         	  = [KRDelta sharedDelta];
delta.activeFunction   	  = KRDeltaActivationTanh;
delta.optimization.method = KRDeltaOptimizationFixedInertia;
delta.batchSize           = 1; // kKRDeltaFullBatch or 0 is full-batch, 1 is standard SGD, > 1 is mini-batch.
delta.learningRate     	  = 0.8f;
delta.convergenceValue 	  = 0.001f;
delta.maxIteration     	  = 100;
[delta addPatterns:@[@1.0f, @-2.0f, @0.0f, @-1.0f] target:-1.0f];
[delta addPatterns:@[@0.0f, @1.5f, @-0.5f, @-1.0f] target:1.0f];
[delta addPatterns:@[@1.0f, @1.0f, @1.5f, @0.5f] target:1.0f];
[delta addPatterns:@[@2.0f, @0.5f, @-1.5f, @-0.5f] target:1.0f];
[delta addPatterns:@[@-0.5f, @-1.5f, @0.5f, @1.0f] target:-1.0f];
[delta setupRandomMin:-0.5f max:0.5f];
[delta randomWeights];
[delta trainingWithIteration:^(NSInteger iteration, NSArray *weights) {
    NSLog(@"Doing %li iteration : %@", iteration, weights);
} completion:^(BOOL success, NSArray *weights, NSInteger totalIteration) {
    NSLog(@"Done %li iteration : %@", totalIteration, weights);
}];

Saving & Fetching Trained Neuron

If neuron has finished training that we could save it through KRDeltaFetcher in completion block or anywhere.

// Saving
[delta trainingWithCompletion:^(BOOL success, NSArray *weights, NSInteger totalIteration) {
	[[KRDeltaFetcher sharedFetcher] save:delta forKey:@"A1"];    
}];
// Fetching
KRDelta *trainedDelta = [[KRDeltaFetcher sharedFetcher] objectForKey:@"A1"];

Setting Weights by Yourself

[delta setupWeights:@[@1.0f, @-1.0f, @0.0f, @0.5f]];

Version

V1.6.0

LICENSE

MIT.