Skip to content
This repository has been archived by the owner on Feb 21, 2023. It is now read-only.

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yconst committed Feb 9, 2016
1 parent b986d37 commit 6558d54
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 29 deletions.
2 changes: 0 additions & 2 deletions YCML Tests (Swift)/YCML_Tests__Swift_.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
//

import XCTest
import YCML
import YCMatrix

class YCML_Tests__Swift_: XCTestCase {

Expand Down
8 changes: 8 additions & 0 deletions YCML.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
CB02F7CD1AAF720500EF1E02 /* housing.csv in Resources */ = {isa = PBXBuildFile; fileRef = CB9695911AAEECA8003BAE48 /* housing.csv */; };
CB0B6D361C5923F4002A76E2 /* YCRBFKernel.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0B6D341C5923F4002A76E2 /* YCRBFKernel.h */; settings = {ATTRIBUTES = (Public, ); }; };
CB0B6D371C5923F4002A76E2 /* YCRBFKernel.m in Sources */ = {isa = PBXBuildFile; fileRef = CB0B6D351C5923F4002A76E2 /* YCRBFKernel.m */; settings = {ASSET_TAGS = (); }; };
CB0B6D3C1C5B6377002A76E2 /* YCSMOCache.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0B6D3A1C5B6377002A76E2 /* YCSMOCache.h */; settings = {ASSET_TAGS = (); }; };
CB0B6D3D1C5B6377002A76E2 /* YCSMOCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CB0B6D3B1C5B6377002A76E2 /* YCSMOCache.m */; settings = {ASSET_TAGS = (); }; };
CB17B67B1C289F6100F36E0F /* halton_sampler.h in Headers */ = {isa = PBXBuildFile; fileRef = CB17B6771C289F6100F36E0F /* halton_sampler.h */; settings = {ASSET_TAGS = (); }; };
CB17B67C1C289F6100F36E0F /* HaltonInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = CB17B6781C289F6100F36E0F /* HaltonInterface.h */; settings = {ASSET_TAGS = (); }; };
CB17B67D1C289F6100F36E0F /* HaltonInterface.mm in Sources */ = {isa = PBXBuildFile; fileRef = CB17B6791C289F6100F36E0F /* HaltonInterface.mm */; settings = {ASSET_TAGS = (); }; };
Expand Down Expand Up @@ -158,6 +160,8 @@
CB02F7C41AAF653C00EF1E02 /* YCML_Tests__Swift_.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = YCML_Tests__Swift_.swift; sourceTree = "<group>"; };
CB0B6D341C5923F4002A76E2 /* YCRBFKernel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YCRBFKernel.h; path = Kernels/YCRBFKernel.h; sourceTree = "<group>"; };
CB0B6D351C5923F4002A76E2 /* YCRBFKernel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = YCRBFKernel.m; path = Kernels/YCRBFKernel.m; sourceTree = "<group>"; };
CB0B6D3A1C5B6377002A76E2 /* YCSMOCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = YCSMOCache.h; path = SVR/YCSMOCache.h; sourceTree = "<group>"; };
CB0B6D3B1C5B6377002A76E2 /* YCSMOCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = YCSMOCache.m; path = SVR/YCSMOCache.m; sourceTree = "<group>"; };
CB17B6771C289F6100F36E0F /* halton_sampler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = halton_sampler.h; sourceTree = "<group>"; };
CB17B6781C289F6100F36E0F /* HaltonInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HaltonInterface.h; sourceTree = "<group>"; };
CB17B6791C289F6100F36E0F /* HaltonInterface.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HaltonInterface.mm; sourceTree = "<group>"; };
Expand Down Expand Up @@ -602,6 +606,8 @@
CBACE2411C1ACB61008B0FB1 /* YCSVR.m */,
CBACE2441C1DA05F008B0FB1 /* YCSMORegressionTrainer.h */,
CBACE2451C1DA05F008B0FB1 /* YCSMORegressionTrainer.m */,
CB0B6D3A1C5B6377002A76E2 /* YCSMOCache.h */,
CB0B6D3B1C5B6377002A76E2 /* YCSMOCache.m */,
);
name = SVR;
sourceTree = "<group>";
Expand Down Expand Up @@ -734,6 +740,7 @@
CB504D391BD54DF000272855 /* YCValidation.h in Headers */,
CBC7A4F71ABA36AD00464DD2 /* YCGradientDescent.h in Headers */,
CB6494B51B972EF000BA3FE2 /* OrderedDictionary.h in Headers */,
CB0B6D3C1C5B6377002A76E2 /* YCSMOCache.h in Headers */,
CB72CD551BCAE40F00A4A772 /* YCTanhLayer.h in Headers */,
CB92068C1C43F00600F93E3A /* YCModelKernel.h in Headers */,
CB52160E1B415B4900A4AF01 /* YCPopulationBasedOptimizer.h in Headers */,
Expand Down Expand Up @@ -934,6 +941,7 @@
CB1802CC1ABE19DF00A2927B /* YCRpropTrainer.m in Sources */,
CB52161B1B43FEEF00A4AF01 /* NSIndexSet+Sampling.m in Sources */,
CB52160F1B415B4900A4AF01 /* YCPopulationBasedOptimizer.m in Sources */,
CB0B6D3D1C5B6377002A76E2 /* YCSMOCache.m in Sources */,
CBD606831B0FC48300DCA6AD /* YCOLSPRESSTrainer.m in Sources */,
CB72CD4E1BCADDAF00A4A772 /* YCFullyConnectedLayer.m in Sources */,
CB72CD4A1BCAB64800A4A772 /* YCModelLayer.m in Sources */,
Expand Down
2 changes: 2 additions & 0 deletions YCML/Data Frame/YCDataframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ typedef enum AttributeType : int16_t {

- (NSDictionary *)outlierIndexesWithFenceMultiplier:(double)multiplier;

- (YCDataframe *)uniques;

/**
Returns an NSArray of NSDictionaries, each corresponding to a sample.
*/
Expand Down
5 changes: 5 additions & 0 deletions YCML/Data Frame/YCDataframe.m
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ - (NSDictionary *)outlierIndexesWithFenceMultiplier:(double)multiplier
return indexSets;
}

//- (YCDataframe *)uniques
//{
//
//}

#pragma mark Property Accessors

- (NSArray *)allSamples
Expand Down
5 changes: 5 additions & 0 deletions YCML/Optimization/RProp/YCRProp.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ - (NSArray *)bestObjectives
return @[self.state[@"best"]];
}

- (NSArray *)bestConstraints
{
return @[@0];
}

@end
2 changes: 2 additions & 0 deletions YCML/Optimization/YCOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,6 @@

@property (readonly) NSArray *bestObjectives;

@property (readonly) NSArray *bestConstraints;

@end
6 changes: 6 additions & 0 deletions YCML/Optimization/YCOptimizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ - (NSArray *)bestObjectives
@"You must override %@ in subclass %@", NSStringFromSelector(_cmd), [self class]];
}

- (NSArray *)bestConstraints
{
@throw [NSInternalInconsistencyException initWithFormat:
@"You must override %@ in subclass %@", NSStringFromSelector(_cmd), [self class]];
}

#pragma mark NSCopying implementation

- (instancetype)copyWithZone:(NSZone *)zone
Expand Down
22 changes: 14 additions & 8 deletions YCML/Optimization/YCPopulationBasedOptimizer.m
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ - (void)evaluateIndividuals:(NSArray *)individuals
YCIndividual *individual = obj;
Matrix *result = [results column:(int)idx];

NSRange constraintRange = NSMakeRange(0, constraintCount);
individual.constraintValues = [result matrixWithRowsInRange:constraintRange];

NSRange objectiveRange = NSMakeRange(constraintCount, objectiveCount);
NSRange objectiveRange = NSMakeRange(0, objectiveCount);
individual.objectiveFunctionValues = [result matrixWithRowsInRange:objectiveRange];

NSRange constraintRange = NSMakeRange(objectiveCount, constraintCount);
individual.constraintValues = [result matrixWithRowsInRange:constraintRange];

individual.evaluated = YES;
}];
}
Expand All @@ -127,12 +127,12 @@ - (void)evaluateIndividuals:(NSArray *)individuals
{
[self.problem evaluate:result parameters:individual.decisionVariableValues];

NSRange constraintRange = NSMakeRange(0, constraintCount);
individual.constraintValues = [result matrixWithRowsInRange:constraintRange];

NSRange objectiveRange = NSMakeRange(constraintCount, objectiveCount);
NSRange objectiveRange = NSMakeRange(0, objectiveCount);
individual.objectiveFunctionValues = [result matrixWithRowsInRange:objectiveRange];

NSRange constraintRange = NSMakeRange(objectiveCount, constraintCount);
individual.constraintValues = [result matrixWithRowsInRange:constraintRange];

individual.evaluated = YES;
}
}
Expand All @@ -156,6 +156,12 @@ - (NSArray *)bestObjectives
return [self.population valueForKey:@"objectiveFunctionValues"];
}

- (NSArray *)bestConstraints
{
if (!self.population) [self initializePopulation];
return [self.population valueForKey:@"constraintValues"];
}

#pragma mark NSCopying implementation

- (instancetype)copyWithZone:(NSZone *)zone
Expand Down
25 changes: 25 additions & 0 deletions YCML/SVR/YCSMOCache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// YCSMOCache.h
// YCML
//
// Created by Ioannis Chatzikonstantinou on 29/1/16.
// Copyright © 2016 Yannis Chatzikonstantinou. All rights reserved.
//

#import <Foundation/Foundation.h>

typedef enum cacheStatus { notInCache, allocated, present } cacheStatus;

@interface YCSMOCache : NSObject

- (instancetype)initWithSize:(int)size;

- (cacheStatus)queryI:(int)i j:(int)j;

- (void)pingI:(int)i j:(int)j;

- (double)getI:(int)i j:(int)j;

- (double)setI:(int)i j:(int)j value:(double)value;

@end
13 changes: 13 additions & 0 deletions YCML/SVR/YCSMOCache.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// YCSMOCache.m
// YCML
//
// Created by Ioannis Chatzikonstantinou on 29/1/16.
// Copyright © 2016 Yannis Chatzikonstantinou. All rights reserved.
//

#import "YCSMOCache.h"

@implementation YCSMOCache

@end
5 changes: 5 additions & 0 deletions YCML/YCGenericModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
*/
@interface YCGenericModel : NSObject <NSCopying, NSCoding>

//- (void)PMMLEncodeWithRootElement:(NSXMLElement *)root;

/**
Allocates and initializes a new instance of the receiver class.
Expand Down Expand Up @@ -56,4 +58,7 @@
*/
@property (readonly) NSString *textDescription;


@property (readonly) NSString *PMMLString;

@end
15 changes: 15 additions & 0 deletions YCML/YCGenericModel.m
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,19 @@ - (NSString *)textDescription
return description;
}

//- (void)PMMLEncodeWithRootElement:(NSXMLElement *)root
//{
//
//}

//- (NSString *)PMMLString
//{
// NSXMLElement *root = (NSXMLElement *)[NSXMLNode elementWithName:@"addresses"];
// [self PMMLEncodeWithRootElement:root];
// NSXMLDocument *xmlDoc = [[NSXMLDocument alloc] initWithRootElement:root];
// [xmlDoc setVersion:@"1.0"];
// [xmlDoc setCharacterEncoding:@"UTF-8"];
// return [xmlDoc stringValue];
//}

@end
31 changes: 12 additions & 19 deletions YCMLTests/YCMLDataframeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,26 @@
//

#import <XCTest/XCTest.h>
@import YCML;

@interface YCMLDataframeTests : XCTestCase

@end

@implementation YCMLDataframeTests

- (void)setUp {
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
- (void)testReplaceRow
{
// YCDataframe *df = [self randomDataframeColumns:5 rows:10];
// NSDictionary *newRow = @{@1.0, @1.0, @1.0, @1.0, @1.0};
// [df replaceSampleAtIndex:2 withData:newRow];
// NSDictionary *retrievedRow = [df sampleAtIndex:2];
// NSAssertEqual(newRow, retrievedRow, @"Result not equal");
}

- (void)tearDown {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
}

- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}

- (void)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
}
//- (YCDataframe *)randomDataframeColumns:(int)columns rows:(int)rows
//{
//
//}

@end

0 comments on commit 6558d54

Please sign in to comment.