-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from JuliaAI/dev
For a 0.2.4 release
- Loading branch information
Showing
6 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
name = "MLJTestInterface" | ||
uuid = "72560011-54dd-4dc2-94f3-c5de45b75ecd" | ||
authors = ["Anthony D. Blaom <[email protected]>"] | ||
version = "0.2.3" | ||
version = "0.2.4" | ||
|
||
[deps] | ||
MLJBase = "a7f614a8-145f-11e9-1d2a-a57a1082229d" | ||
|
@@ -10,4 +10,5 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | |
|
||
[compat] | ||
MLJBase = "0.20, 0.21, 1" | ||
Test = "<0.0.1, 1" | ||
julia = "1.6" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,59 @@ | ||
""" | ||
make_binary() | ||
make_binary(; row_table=false) | ||
Return data `(X, y)` for the crabs dataset, restricted to the two features `:FL`, | ||
`:RW`. Target is `Multiclass{2}`. | ||
The table `X` is a named tuple of vectors. For a vector of named tuples, set | ||
`row_table=true`. | ||
""" | ||
function make_binary() | ||
function make_binary(; row_table=false) | ||
data = MLJBase.load_crabs() | ||
y_, X = unpack(data, ==(:sp), col->col in [:FL, :RW]) | ||
y = coerce(y_, MLJBase.OrderedFactor) | ||
return X, y | ||
row_table ? (MLJBase.Tables.rowtable(X), y) : (X, y) | ||
end | ||
|
||
""" | ||
make_multiclass() | ||
make_multiclass(; row_table=false) | ||
Return data `(X, y)` for the unshuffled iris dataset. Target is `Multiclass{3}`. | ||
""" | ||
make_multiclass() = MLJBase.@load_iris | ||
function make_multiclass(; row_table=false) | ||
X, y = MLJBase.@load_iris | ||
row_table ? (MLJBase.Tables.rowtable(X), y) : (X, y) | ||
end | ||
|
||
""" | ||
make_regression() | ||
make_regression(; row_table=false) | ||
Return data `(X, y)` for the Boston dataset, restricted to the two features `:LStat`, | ||
`:Rm`. Target is `Continuous`. | ||
The table `X` is a named tuple of vectors. For a vector of named tuples, set | ||
`row_table=true`. | ||
""" | ||
function make_regression() | ||
function make_regression(; row_table=false) | ||
data = MLJBase.load_boston() | ||
y, X = unpack(data, ==(:MedV), col->col in [:LStat, :Rm]) | ||
return X, y | ||
row_table ? (MLJBase.Tables.rowtable(X), y) : (X, y) | ||
end | ||
|
||
""" | ||
make_count() | ||
make_count(; row_table=false) | ||
Return data `(X, y)` for the Boston dataset, restricted to the two features `:LStat`, | ||
`:Rm`, with the `Continuous` target converted to `Count` (integer). | ||
The table `X` is a named tuple of vectors. For a vector of named tuples, set | ||
`row_table=true`. | ||
""" | ||
function make_count() | ||
function make_count(; row_table=false) | ||
X, y_ = make_regression() | ||
y = map(η -> round(Int, η), y_) | ||
return X, y | ||
row_table ? (MLJBase.Tables.rowtable(X), y) : (X, y) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
@testset "loading of datasets" begin | ||
X, y = MTI.make_binary() | ||
@test X isa NamedTuple | ||
@test first(X) isa AbstractVector{Float64} | ||
@test MLJBase.scitype(y) == AbstractVector{MLJBase.OrderedFactor{2}} | ||
Xr, yr = MTI.make_binary(row_table=true) | ||
@test Xr isa AbstractVector | ||
@test MLJBase.Tables.rowtable(X) == Xr | ||
@test yr == y | ||
|
||
X, y = MTI.make_multiclass() | ||
@test X isa NamedTuple | ||
@test first(X) isa AbstractVector{Float64} | ||
@test MLJBase.scitype(y) == AbstractVector{MLJBase.Multiclass{3}} | ||
Xr, yr = MTI.make_multiclass(row_table=true) | ||
@test Xr isa AbstractVector | ||
@test MLJBase.Tables.rowtable(X) == Xr | ||
@test yr == y | ||
|
||
X, y = MTI.make_regression() | ||
@test X isa NamedTuple | ||
@test first(X) isa AbstractVector{Float64} | ||
@test MLJBase.scitype(y) == AbstractVector{MLJBase.Continuous} | ||
Xr, yr = MTI.make_regression(row_table=true) | ||
@test Xr isa AbstractVector | ||
@test MLJBase.Tables.rowtable(X) == Xr | ||
@test yr == y | ||
|
||
X, y = MTI.make_count() | ||
@test X isa NamedTuple | ||
@test first(X) isa AbstractVector{Float64} | ||
@test MLJBase.scitype(y) == AbstractVector{MLJBase.Count} | ||
Xr, yr = MTI.make_count(row_table=true) | ||
@test Xr isa AbstractVector | ||
@test MLJBase.Tables.rowtable(X) == Xr | ||
@test yr == y | ||
end | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters