Skip to content
This repository has been archived by the owner on May 12, 2019. It is now read-only.

Use countnz instead of nnz #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Use countnz instead of nnz #9

wants to merge 1 commit into from

Conversation

chezou
Copy link
Contributor

@chezou chezou commented Jun 14, 2014

In Base.show function, there is deprecated function nnz.
It is preffered to use countnz instead of nnz.

@johnmyleswhite
Copy link
Member

I think this deprecation was already reversed: JuliaLang/julia@8879b88

@chezou
Copy link
Contributor Author

chezou commented Jun 15, 2014

hmm, I'm using following version of Julia, but still getting some warning.

julia> versioninfo()
Julia Version 0.3.0-prerelease+3551
Commit 547facf* (2014-06-07 20:57 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin12.5.0)
  CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libgfortblas
  LAPACK: liblapack
  LIBM: libopenlibm
julia> model = svm(X[:,train], Y[train])
Fitted linear SVM
WARNING: nnz(A::StridedArray) is deprecated, use countnz(A) instead.
 in show at /Users/mic/.julia/v0.3/SVM/src/SVM.jl:15
 in anonymous at show.jl:1045
 in with_output_limit at show.jl:1022
 in showlimited at show.jl:1044
 in writemime at replutil.jl:2
 in display at REPL.jl:114
 in display at REPL.jl:117
 in display at multimedia.jl:149
 in print_response at REPL.jl:133
 in print_response at REPL.jl:121
 in anonymous at REPL.jl:521
 in anonymous at REPL.jl:687
 in anonymous at LineEdit.jl:1121
 * Non-zero weights: 4
 * Accuracy: 1.000000
 * Iterations: 100
 * Converged: true

@paulanalyst
Copy link

I have the same ,
and
iris = dataset("datasets", "iris") or iris = data("datasets", "iris") id corectly ?
_
_ _ ()_ | A fresh approach to technical computing
() | () () | Documentation: http://docs.julialang.org
_ _ | | __ _ | Type "help()" to list help topics
| | | | | | |/ ` | |
| | |
| | | | (
| | | Version 0.3.0-prerelease+3687 (2014-06-16 00:19 UTC)
/ |_'|||__'| | Commit 9381e34 (1 day old master)
|__/ | x86_64-w64-mingw32

julia> Pkg.update()
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove

julia> using SVM

julia> using RDatasets

julia> iris = data("datasets", "iris")
ERROR: no method data(ASCIIString, ASCIIString)

julia> iris = datasets("datasets", "iris")
ERROR: datasets not defined

julia> iris = dataset("datasets", "iris")
150x5 DataFrame
|-------|-------------|------------|-------------|------------|-------------|
| Row # | SepalLength | SepalWidth | PetalLength | PetalWidth | Species |
| 1 | 5.1 | 3.5 | 1.4 | 0.2 | "setosa" |
| 2 | 4.9 | 3.0 | 1.4 | 0.2 | "setosa" |
| 3 | 4.7 | 3.2 | 1.3 | 0.2 | "setosa" |
| 4 | 4.6 | 3.1 | 1.5 | 0.2 | "setosa" |
| 5 | 5.0 | 3.6 | 1.4 | 0.2 | "setosa" |
| 6 | 5.4 | 3.9 | 1.7 | 0.4 | "setosa" |
| 7 | 4.6 | 3.4 | 1.4 | 0.3 | "setosa" |
| 8 | 5.0 | 3.4 | 1.5 | 0.2 | "setosa" |
| 9 | 4.4 | 2.9 | 1.4 | 0.2 | "setosa" |
?
| 141 | 6.7 | 3.1 | 5.6 | 2.4 | "virginica" |
| 142 | 6.9 | 3.1 | 5.1 | 2.3 | "virginica" |
| 143 | 5.8 | 2.7 | 5.1 | 1.9 | "virginica" |
| 144 | 6.8 | 3.2 | 5.9 | 2.3 | "virginica" |
| 145 | 6.7 | 3.3 | 5.7 | 2.5 | "virginica" |
| 146 | 6.7 | 3.0 | 5.2 | 2.3 | "virginica" |
| 147 | 6.3 | 2.5 | 5.0 | 1.9 | "virginica" |
| 148 | 6.5 | 3.0 | 5.2 | 2.0 | "virginica" |
| 149 | 6.2 | 3.4 | 5.4 | 2.3 | "virginica" |
| 150 | 5.9 | 3.0 | 5.1 | 1.8 | "virginica" |

julia> X = array(iris[:, 1:4])'
4x150 Array{Float64,2}:
5.1 4.9 4.7 4.6 5.0 5.4 4.6 5.0 6.8 6.7 6.7 6.3 6.5 6.2 5.9
3.5 3.0 3.2 3.1 3.6 3.9 3.4 3.4 3.2 3.3 3.0 2.5 3.0 3.4 3.0
1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 5.9 5.7 5.2 5.0 5.2 5.4 5.1
0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 2.3 2.5 2.3 1.9 2.0 2.3 1.8

julia> p, n = size(X)
(4,150)

julia> Y = [species == "setosa" ? 1.0 : -1.0 for species in iris[:, "Species"]]
WARNING: indexing DataFrames with strings is deprecated; use symbols instead
in getindex at C:\Users\SAMSUNG2.julia\v0.3\DataFrames\src\deprecated.jl:180
in anonymous at no file
150-element Array{Float64,1}:
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
?
-1.0
-1.0
-1.0
-1.0
-1.0
-1.0
-1.0
-1.0
-1.0
-1.0

julia> train = randbool(n)
150-element BitArray{1}:
true
true
false
false
false
true
false
false
true
true
?
false
false
true
true
true
false
false
true
false
false

julia> model = svm(X[:,train], Y[train])
Fitted linear SVM
WARNING: nnz(A::StridedArray) is deprecated, use countnz(A) instead.
in show at C:\Users\SAMSUNG2.julia\v0.3\SVM\src\SVM.jl:15

  • Non-zero weights: 4
  • Accuracy: 1.000000
  • Iterations: 100
  • Converged: true

julia> accuracy = nnz(predict(model, X[:,~train]) .== Y[~train])/nnz(~train)
ERROR: no method predict(SVMFit, Array{Float64,2})

julia> model = svm(X, Y, k = 150)
Fitted linear SVM
WARNING: nnz(A::StridedArray) is deprecated, use countnz(A) instead.
in show at C:\Users\SAMSUNG2.julia\v0.3\SVM\src\SVM.jl:15

  • Non-zero weights: 4
  • Accuracy: 1.000000
  • Iterations: 100
  • Converged: true

julia> model = svm(X, Y, lambda = 0.1)
Fitted linear SVM
WARNING: nnz(A::StridedArray) is deprecated, use countnz(A) instead.
in show at C:\Users\SAMSUNG2.julia\v0.3\SVM\src\SVM.jl:15
in anonymous at show.jl:1067
in stream_wait at stream.jl:255
in with_output_limit at show.jl:1044
in stream_wait at stream.jl:252

  • Non-zero weights: 4
  • Accuracy: 1.000000
  • Iterations: 100
  • Converged: true

julia> model = svm(X, Y, T = 1000)
Fitted linear SVM
WARNING: nnz(A::StridedArray) is deprecated, use countnz(A) instead.
in show at C:\Users\SAMSUNG2.julia\v0.3\SVM\src\SVM.jl:15
in anonymous at show.jl:1067
in stream_wait at stream.jl:255
in with_output_limit at show.jl:1044
in stream_wait at stream.jl:252

  • Non-zero weights: 4
  • Accuracy: 1.000000
  • Iterations: 1000
  • Converged: true

julia>

Paul

@chezou
Copy link
Contributor Author

chezou commented Jun 17, 2014

@paulanalyst I've pull requested about Readme's example. see also #10

@chezou
Copy link
Contributor Author

chezou commented Jun 17, 2014

I reproduce same warning on following version.

julia> versioninfo()
Julia Version 0.3.0-prerelease+3687
Commit 9381e34* (2014-06-16 00:19 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin13.2.0)
  CPU: Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT NO_AFFINITY)
  LAPACK: libopenblas
  LIBM: libopenlibm
julia> model = svm(X[:,train], Y[train])
Fitted linear SVM
WARNING: nnz(A::StridedArray) is deprecated, use countnz(A) instead.
 in show at /Users/mic/.julia/v0.3/SVM/src/SVM.jl:15
 in anonymous at show.jl:1067
 in showlimited at show.jl:1066
 in writemime at replutil.jl:2
 in display at REPL.jl:117
 in display at REPL.jl:120
 in display at multimedia.jl:149
 in print_response at REPL.jl:139
 in print_response at REPL.jl:124
 in anonymous at REPL.jl:541
 * Non-zero weights: 4
 * Accuracy: 1.000000
 * Iterations: 100
 * Converged: true

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants