Skip to content
This repository was archived by the owner on May 12, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,19 @@ The demo below shows how SVMs work:

```julia
# To show how SVMs work, we'll use Fisher's iris data set
using SVM
# Temporally, following order is required
using RDatasets
using SVM

# We'll learn to separate setosa from other species
iris = data("datasets", "iris")
iris = dataset("datasets", "iris")

# SVM format expects observations in columns and features in rows
X = array(iris[:, 1:4])'
p, n = size(X)

# SVM format expects positive and negative examples to +1/-1
Y = [species == "setosa" ? 1.0 : -1.0 for species in iris[:, "Species"]]
Y = [species == :setosa ? 1.0 : -1.0 for species in iris[:, "Species"]]

# Select a subset of the data for training, test on the rest.
train = randbool(n)
Expand All @@ -40,7 +41,7 @@ train = randbool(n)
model = svm(X[:,train], Y[train])

# And now evaluate that model on the testset
accuracy = nnz(predict(model, X[:,~train]) .== Y[~train])/nnz(~train)
accuracy = countnz(predict(model, X[:,~train]) .== Y[~train])/countnz(~train)
```

You may specify non-default values for the various parameters:
Expand Down