Latest 1.6.0
Homepage https://github.com/Kalvar/ios-KRDelta
License MIT
Platforms ios 8.0, requires ARC
Frameworks Foundation
Authors

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.

Latest podspec

{
    "name": "KRDelta",
    "version": "1.6.0",
    "summary": "KRDelta is a supervised learning which Delta rule of Machine Learning.",
    "description": "It still works in recommendation system and real-time user behavior analysis on mobile apps.",
    "homepage": "https://github.com/Kalvar/ios-KRDelta",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Kalvar Lin": "[email protected]"
    },
    "social_media_url": "https://twitter.com/ilovekalvar",
    "source": {
        "git": "https://github.com/Kalvar/ios-KRDelta.git",
        "tag": "1.6.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "public_header_files": "ML/**/*.h",
    "source_files": "ML/**/*.{h,m}",
    "frameworks": "Foundation"
}

Pin It on Pinterest

Share This