From c049464395def83e567375fc9d09da15ceaad008 Mon Sep 17 00:00:00 2001 From: Michiaki Ariga Date: Sun, 15 Jun 2014 09:17:50 +0900 Subject: [PATCH] Fix readme - Change way to read RDatasets - Fix `using` order - Use `countnz` instead of `nnz` --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e98e063..3ff2e65 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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: