Skip to content

Commit

Permalink
bug fixes to support README examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalmes committed Jun 24, 2022
1 parent b3cb58c commit 297f19c
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 60 deletions.
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ version = "0.4.0"

[deps]
AMLPipelineBase = "e3c3008a-8869-4d53-9f34-c96f99c8a2b6"
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
Expand All @@ -14,7 +13,6 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
AMLPipelineBase = "0.1"
Conda = "1.0, 1.1, 1.2, 1.3, 1.4, 1.5"
CondaPkg = "0.2"
DataFrames = "0.17, 0.18, 0.19, 0.20, 0.21, 0.22, 1.0, 1.1"
PythonCall = "0.9"
Expand Down
48 changes: 0 additions & 48 deletions deps/build.jl

This file was deleted.

8 changes: 7 additions & 1 deletion src/skcrossvalidator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,16 @@ and the following metrics for regression:
"""
function crossvalidate(pl::Machine,X::DataFrame,Y::Vector,
sfunc::String; nfolds=10,verbose::Bool=true)

YC=Y
if !(eltype(YC) <: Real)
YC = Y |> Vector{String}
end

checkfun(sfunc)
pfunc = metric_dict[sfunc]
metric(a,b) = pfunc(a,b) |> (x -> PYC.pyconvert(Float64,x))
crossvalidate(pl,X,Y,metric,nfolds,verbose)
crossvalidate(pl,X,YC,metric,nfolds,verbose)
end

function crossvalidate(pl::Machine,X::DataFrame,Y::Vector,sfunc::String,nfolds::Int)
Expand Down
17 changes: 9 additions & 8 deletions src/sklearners.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,16 @@ function sklearners()
println("Note: Consult Scikitlearn's online help for more details about the learner's arguments.")
end

function fit!(skl::SKLearner, xx::DataFrame, y::Vector)::Nothing
function fit!(skl::SKLearner, xx::DataFrame, yy::Vector)::Nothing
# normalize inputs
x = xx |> Array
y = yy
skl.model[:predtype] = :numeric
if !(eltype(yy) <: Real)
y = yy |> Vector{String}
skl.model[:predtype] = :alpha
end

impl_args = copy(skl.model[:impl_args])
learner = skl.model[:learner]
py_learner = getproperty(learner_dict[learner],learner)
Expand All @@ -171,13 +179,6 @@ function fit!(skl::SKLearner, xx::DataFrame, y::Vector)::Nothing
end
end

if eltype(y) <: Real
skl.model[:predtype] = :numeric
else
skl.model[:predtype] = :alpha
end


# Train
modelobj = py_learner(;impl_args...)
modelobj.fit(x,y)
Expand Down
7 changes: 6 additions & 1 deletion src/skpreprocessor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,13 @@ function skpreprocessors()
println("Note: Please consult Scikitlearn's online help for more details about the preprocessor's arguments.")
end

function fit!(skp::SKPreprocessor, x::DataFrame, y::Vector=[])::Nothing
function fit!(skp::SKPreprocessor, x::DataFrame, yc::Vector=[])::Nothing
features = x |> Array
y = yc
if !(eltype(yc) <: Real)
y = yc |> Vector{String}
end

impl_args = copy(skp.model[:impl_args])
autocomp = skp.model[:autocomponent]
if autocomp == true
Expand Down

0 comments on commit 297f19c

Please sign in to comment.