JuliaStats / RegERMs.jl

DEPRECATED: Regularised Empirical Risk Minimisation Framework (SVMs, LogReg, Linear Regression) in Julia
Other
16 stars 11 forks source link

example not working #14

Closed abieler closed 9 years ago

abieler commented 9 years ago

I just tried running the example from the docs, which did not work.

using RegERMs
# define some toy data (XOR - example)
np = 100
nn = 100
X = [randn(int(np/2),1)+1 randn(int(np/2),1)+1; randn(int(np/2-0.5),1)-1 randn(int(np/2-0.5),1)-1;
     randn(int(nn/2),1)+1 randn(int(nn/2),1)-1; randn(int(nn/2-0.5),1)-1 randn(int(nn/2-0.5),1)+1] # examples with 2 features
y = vec([ones(np,1); -ones(nn,1)])       # binary class values

# choose SVM as learning algorithm
svm = SVM(X, y; kernel=:rbf)

# get solution (regularization parameter is 0.1)
regParam = 0.1
model = optimize(svm, regParam)

# make predictions and compute accuracy
ybar = predict(model, X)
acc = mean(ybar .== y)

Error message says predict is not defined. Any comments? Thanks Andre

BigCrunsh commented 9 years ago

@abieler: Sorry, I forgot to update the readme (which is done now). Should be working now.

abieler commented 9 years ago

Hi Christoph,

the Quick Start example in the docs still does not work for me, using Julia version 0.3.10.

Here is what I ran:

using RegERMs

define some toy data (XOR - example)

np = 100 nn = 100 X = [randn(int(np/2),1)+1 randn(int(np/2),1)+1; randn(int(np/2-0.5),1)-1 randn(int(np/2-0.5),1)-1; randn(int(nn/2),1)+1 randn(int(nn/2),1)-1; randn(int(nn/2-0.5),1)-1 randn(int(nn/2-0.5),1)+1] # examples with 2 features y = int(vec([ones(np,1); -ones(nn,1)])) # binary class values

use rbf kernel by using mercer map

map = MercerMap(X, :rbf) X = RegERMs.apply(map)

choose (linear) SVM as learning algorithm with regularization parameter

0.1 svm = SVM(X, y; λ=0.1)

get a solution

model = optimize(svm)

make predictions and compute accuracy

ybar = predict(model, X) acc = mean(ybar .== y)

and got a complaint about λ.

ERROR: unrecognized keyword argument "λ" in include at ./boot.jl:245 in include_from_node1 at loading.jl:128 in process_options at ./client.jl:285 in _start at ./client.jl:354 while loading /home/abieler/scripts/julia/machineLearning/regErms_example.jl, in expression starting on line 14

(I would include the "using RegERMs" line in the example so people just could copy and paste the example.

Best,

Andre

On Mon, Jul 13, 2015 at 7:00 AM, Christoph Sawade notifications@github.com wrote:

@abieler https://github.com/abieler: Sorry, I forgot to update the readme (which is done now). Should be working now.

— Reply to this email directly or view it on GitHub https://github.com/JuliaStats/RegERMs.jl/issues/14#issuecomment-120890754 .

BigCrunsh commented 9 years ago

Sorry, I have not bumped up the version number yet, so you are probably using RegERMs 0.0.1. I will do it asap. In the meanwhile you can check out the current version by

Pkg.checkout("RegERMs")

FYI: I added your recommended line to the readme.

BigCrunsh commented 9 years ago

Version number is updated. @abieler: the example should work after an update.