cstjean / ScikitLearn.jl

Julia implementation of the scikit-learn API https://cstjean.github.io/ScikitLearn.jl/dev/
Other
547 stars 75 forks source link

a way to do not show the warning(FutureWarning) ? #94

Closed bigdataman2015 closed 3 years ago

bigdataman2015 commented 3 years ago

would not like to see the below warning, how to solve it in Julia ? thanks!

C:\Users\Administrator.julia\conda\3\lib\site-packages\sklearn\utils\validation.py:67: FutureWarning: Pass C=10000.0, kernel=linear as keyword args. From version 0.25 passing these as positional arguments will result in an error warnings.warn("Pass {} as keyword args. From version 0.25 "

cstjean commented 3 years ago

That seems straight-forward to fix. Can you post the code that triggers this? Where does it come from?

bigdataman2015 commented 3 years ago
julia> using Distributions

julia> using ScikitLearn

julia> @sk_import svm: SVC
PyObject <class 'sklearn.svm._classes.SVC'>

julia> using RDatasets

julia> iris = dataset("datasets", "iris")
150×5 DataFrame
│ Row │ SepalLength │ SepalWidth │ PetalLength │ PetalWidth │ Species   │
│     │ Float64     │ Float64    │ Float64     │ Float64    │ Cat…      │
├─────┼─────────────┼────────────┼─────────────┼────────────┼───────────┤
│ 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    │
⋮
│ 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_iris = convert(Array{Float64,2}, iris[:, 1:4])
150×4 Array{Float64,2}:
 5.1  3.5  1.4  0.2
 4.9  3.0  1.4  0.2
 4.7  3.2  1.3  0.2
 4.6  3.1  1.5  0.2
 5.0  3.6  1.4  0.2
 5.4  3.9  1.7  0.4
 ⋮
 6.7  3.0  5.2  2.3
 6.3  2.5  5.0  1.9
 6.5  3.0  5.2  2.0
 6.2  3.4  5.4  2.3
 5.9  3.0  5.1  1.8

julia> y_iris = repeat(1:3, inner = 50)
150-element Array{Int64,1}:
 1
 1
 1
 1
 1
 1
 ⋮
 3
 3
 3
 3
 3

julia> idxShuffle = Distributions.sample(1:size(X_iris)[1], size(X_iris)[1])
150-element Array{Int64,1}:
  79
  22
 116
  60
  14
  21
   ⋮
  24
 150
  92
  23
  80

julia> X_iris = X_iris[idxShuffle, :]
150×4 Array{Float64,2}:
 6.0  2.9  4.5  1.5
 5.1  3.7  1.5  0.4
 6.4  3.2  5.3  2.3
 5.2  2.7  3.9  1.4
 4.3  3.0  1.1  0.1
 5.4  3.4  1.7  0.2
 ⋮
 5.1  3.3  1.7  0.5
 5.9  3.0  5.1  1.8
 6.1  3.0  4.6  1.4
 4.6  3.6  1.0  0.2
 5.7  2.6  3.5  1.0

julia> y_iris = y_iris[idxShuffle]
150-element Array{Int64,1}:
 2
 1
 3
 2
 1
 1
 ⋮
 1
 3
 2
 1
 2

julia> model = SVC(1e4, "linear")
C:\Users\Administrator\.julia\conda\3\lib\site-packages\sklearn\utils\validation.py:67: FutureWarning: Pass C=10000.0, kernel=linear as keyword args. From version 0.25 passing these as positional arguments will result in an error
  warnings.warn("Pass {} as keyword args. From version 0.25 "
PyObject SVC(C=10000.0, kernel='linear')

julia> ScikitLearn.fit!(model, X_iris, y_iris)
PyObject SVC(C=10000.0, kernel='linear')

julia> ScikitLearn.score(model, X_iris, y_iris)
1.0

julia> 
bigdataman2015 commented 3 years ago
julia> using Pkg

julia> Pkg.status()
Status `C:\Users\Administrator\.julia\environments\v1.5\Project.toml`
  [c52e3926] Atom v0.12.24
  [336ed68f] CSV v0.7.7
  [5d742f6a] CSVFiles v1.0.0
  [35d6a980] ColorSchemes v3.10.2
  [f65535da] Convex v0.13.7
  [a93c6f00] DataFrames v0.21.7
  [1313f7d8] DataFramesMeta v0.6.0
  [31c24e10] Distributions v0.23.12
  [f6006082] EvoTrees v0.5.1
  [5789e2e9] FileIO v1.4.5
  [f6369f11] ForwardDiff v0.10.12
  [38e38edf] GLM v1.3.10
  [60bf3e95] GLPK v0.13.0
  [c91e804a] Gadfly v1.3.1
  [82e4d734] ImageIO v0.4.1
  [4076af6c] JuMP v0.21.3
  [e5e0dc1b] Juno v0.8.4
  [1914dd2f] MacroTools v0.5.5
  [429524aa] Optim v1.2.0
  [d96e819e] Parameters v0.12.1
  [b98c9c47] Pipe v1.3.0
  [91a5bcdd] Plots v1.6.10
  [6f49c342] RCall v0.13.9
  [ce6b1742] RDatasets v0.6.10
  [295af30f] Revise v3.1.4
  [c946c3f1] SCS v0.7.0
  [3646fa90] ScikitLearn v0.6.2
  [1277b4bf] ShiftedArrays v1.0.0
  [2913bbd2] StatsBase v0.33.2
  [4c63d2b9] StatsFuns v0.9.5
  [f3b207a7] StatsPlots v0.14.17
  [fd094767] Suppressor v0.2.0
  [40c74d1a] TableView v0.6.1
  [bd369af6] Tables v1.1.0
  [009559a3] XGBoost v1.1.1
  [e88e6eb3] Zygote v0.5.8

julia> 
cstjean commented 3 years ago

Well then, just listen to the warning, no? 🙂

julia> model = SVC(1e4, "linear")
C:\Users\Administrator\.julia\conda\3\lib\site-packages\sklearn\utils\validation.py:67: FutureWarning: Pass C=10000.0, kernel=linear as keyword args. From version 0.25 passing these as positional arguments will result in an error
  warnings.warn("Pass {} as keyword args. From version 0.25 "
PyObject SVC(C=10000.0, kernel='linear')

What happens with model = SVC(C=1e4, kernel="linear") ?

bigdataman2015 commented 3 years ago

So, what do you mean? let it go? It seems that it can be solve only in Pycharm(python)?

cstjean commented 3 years ago

No, I mean that you can solve it (AFAICT) by using keyword arguments, as in model = SVC(C=1e4, kernel="linear")

cstjean commented 3 years ago

If your example comes from the docs, then we should indeed fix the usage there.

bigdataman2015 commented 3 years ago

Thanks! the problem solved!