kevincoble / aitoolbox Goto Github PK
View Code? Open in Web Editor NEWA toolbox of AI modules written in Swift: Graphs/Trees, Support Vector Machines, Neural Networks, PCA, K-Means, Genetic Algorithms
License: Apache License 2.0
A toolbox of AI modules written in Swift: Graphs/Trees, Support Vector Machines, Neural Networks, PCA, K-Means, Genetic Algorithms
License: Apache License 2.0
Hi @KevinCoble,
I got a thing to ask about incremental learning which i guess you have already known. So i dont know if this library support that idea or not?
If yes, how can i use it? and which Algorithm is capable of doing so? As far as i know, this issue is really complicated so i am not too sure, however there is SVM with linear kernel that can do this thing.
If no, Do you intend to make that as a feature in the future? Cause it seems relearn every time is not a really good way to do.
Btw, if i want to check for the Precision, F-score, Recall and Accuracy and Validation how can i do that? I looked at the Test for Validation but it only showed the example for Regression so i dont know for sure.
Thank for your help again @KevinCoble
SoftMax output gives me all +inf's as results...
Looking at the source (Recur...swift), it looks like the "sum" calculation is happening for activation function sigmoidWithCrossEntropy instead of softMax?
Otherwise, "sum" just gets tossed away, while softMax is always dividing by 0.
Line 808+:
// Run through the non-linearity
var sum = 0.0
for node in 0..<numNodes {
switch (activation) {
case .none:
h[node] = z[node]
break
case .hyperbolicTangent:
h[node] = tanh(z[node])
break
case .sigmoidWithCrossEntropy:
h[node] = 1.0 / (1.0 + exp(-z[node]))
sum += h[node] // ** <-- THIS... **
break
case .sigmoid:
h[node] = 1.0 / (1.0 + exp(-z[node]))
break
case .rectifiedLinear:
h[node] = z[node]
if (z[node] < 0) { h[node] = 0.0 }
break
case .softSign:
h[node] = z[node] / (1.0 + abs(z[node]))
break
case .softMax:
h[node] = exp(z[node])
sum += h[node] // ** <-- ..SHOULD BE HERE? **
break
}
}
if (activation == .softMax) {
var scale = 1.0 / sum // Do division once for efficiency ** ~~BOOM~~ **
.
.
.
When creating a One-Class SVM classifier (e.g. for the following data)
do {
try trainData.addDataPoint(input: [0.2, 0.9], dataClass:1)
try trainData.addDataPoint(input: [0.8, 0.3], dataClass:1)
try trainData.addDataPoint(input: [0.5, 0.6], dataClass:1)
} //catch etc.
let svm = SVMModel(problemType: .oneClassSVM, kernelSettings:
KernelParameters(type: .radialBasisFunction, degree: 0, gamma: 0.5, coef0: 0.0))
svm.train(trainData)
Throws Index out of range error in SVM.swift in two places:
Line 1531 and Line 1197
Hey!
I came across this project and was wondering if you guys could build a checklist of TODOs etc for potential contributors.
Something like
Would it be possible to add in an example/manual section for Deep Convolutional Neural Networks? I haven't seen any documentation for this, except for having to look through the source code itself, to understand how this works.
Is there support for decision trees in terms of training and inference? If not, any advice on how it might be done with objective-C or Swift?
Hello
Is there a deconvoltuion network (Transpose Network) support plan?
thanks.
I haven't tested yet but i would like to ask if the input can be discrete value like 'Hot' 'Cold' 'Windy' instead of 1 2 3 or can say continuous value?
Thanks a lot for your help
The function classify in the classifier extension of the SVM model by default always throws an error. This is due to a simple logical error in line 128. For type checking, rather than a logical OR, I believe it should be a logical AND.
i) Your library is great.
ii) In the function "getReducedBasisVectorSet(_ data: MLDataSet)",
at the end when you create the basisVectors matrice, should it not be
basisVectors[(vector * initialDimension) + column] = vTranspose[vector + (column * initialDimension)]
instead of
basisVectors[(vector * reducedDimension) + column] = vTranspose[vector + (column * initialDimension)]
?
New issue dear Kevin,
Last week, i put the lib in successfully, But now it imported fine, but whenever i install the project by Xcode it always stuck here and said that abort with payload, which i dont get the reason why. At first i thought some of my project aren't working right. So i deleted and commented code and some thing like that. But everything still got this issue. Until i delete this subproject out of my project the code runs fine.
Here is the error, i dont know what is this, and dont even now this is error or not.
Thanks for your help
Firstly, This is amazing!. Thank you very much for this beautiful library.
I've only just started exploring it for the last 6 hours so apologies if this is obvious but I wanted to check it was / wasn't possible to set regularisation strength for LogisticRegression? Or perhaps I'm just invoking it incorrectly: https://gist.github.com/AJamesPhillips/07471da4b4be0190d8e34bf357c3c431
There are two tests with similar data (1 st input dimension uniform random distribution, 2 nd input dimension linear trend from 0 to 99, output dimension 0 if 2nd input dimension < 50 else 1).
On the first small data test, the classifier usually predicts an output value of 1.
On the second larger similar data set the tests fail randomly (I assume this is just overfitting).
Many thanks! (and apologies if this is a stupid question, I'm new to this area in general, both swift and classifiers etc).
i ran the code which is svm.trainClassifier(...) however they always say that there is an error so i use the catch and print out what type of error is
do {
// try svm.train(trainData)
try svm.trainClassifier(trainData)
}
catch let error as Error {
print("SVM Training error is: \(error)")
}
that and the result is 'invalidModelType' even though i set the type is
let svm = SVMModel(problemType: .c_SVM_Classification, kernelSettings: KernelParameters(type: .linear, degree: 0, gamma: 0.5, coef0: 0.0))
according to the instruction.
Thanks for your help
Do you have any documentation or examples of how to use nonlinear regression and logistic regression?
Can i ask which one is better and the difference between these two?
By the way, regarding SVM, can we choose between different kernels like Linear or something?
Thanks @KevinCoble
It would be great if there would be a package/version/branch which we can use with Open Swift projects. For example a server with vapor and the AIToolbox could be a great project. Any thoughts on this?
While implementing your fabulous SVM class (as a regressor), I always fall upon an error while running predictOne().
The error happens here :
"var sum = 0.0
for k in 0..<supportVectorCount[0] {
sum += coefficients[0][coeffStart[0]+k] * kernelValue[coeffStart[0]+k]
}
for k in 0..<supportVectorCount[1] {
sum += coefficients[0][coeffStart[1]+k] * kernelValue[coeffStart[1]+k]
}"
the vectorSupport exist, the totalSupportVector is >0. Yet the supportVectorCount is nil.
Is it because I am in the regressor mode and not the classification mode ? I did not look at the classification cases yet.
So, basically, the two "for in" instructions cited above will always fail.
I came around this by creating a mock function like this :
open func predictOneJY (_ inputs: [Double]) -> Double {
var sum = 0.0
for i in 0..<totalSupportVectors {
let kernelValue = Kernel.calcKernelValue(kernelParams, x: inputs, y: supportVector[i])
sum += coefficients[0][i] * kernelValue
}
sum -= ฯ[0]
return sum
}
It returns the correct ouput AFAIK.
But I wonder if there is something that I miss, and it is, in fact, my implementation that is faulty, or if the code of predictOne() could indeed be "streamlined" or "corrected" for the regressor cases.
And thanks again for your magnificent and very useful project.
I'm working with MacOSx XCode 8.3.2
I noticed when AIToolbox was built, the framworks are in /Users/brianbabiak/Library/Developer/Xcode/DerivedData/AIToolbox-duqowxslltlzkpbbwvhorgzsgvwf/Build/Products/Debug
I add the framework in another project, but import AIToolbox doesn't work. All instructions followed. Any ideas?
When creating SVM init by function
public init?(loadFrom path: String)
svm is nil. because file model is not plist
how to create svm model by other model file (attach file)?
model.zip
Thanks!
I implemented a simple correlation function borrowing heavily from Numpy's implementation (here and here). If this is something you'd like to see in the library would you like me to submit a pull request? I'm not yet sure where the best place for this is within the library.
https://gist.github.com/AJamesPhillips/7ea56a3a217be300a5705a8109c73a5b
Thanks
Sorry, this is not a bug. I just want to ask a question regarding Linear Regression Model.
I need to solve a linear equation Ax=B, with no bias. But I need to restrict x to be all positive. Is this possible with LinearRegressionModel
? Or maybe using LAPACK directly?
Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.