-
Notifications
You must be signed in to change notification settings - Fork 22
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 #250 from Evovest/shuffling
Shuffling
- Loading branch information
Showing
10 changed files
with
202 additions
and
54 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 = "EvoTrees" | ||
uuid = "f6006082-12f8-11e9-0c9c-0d5d367ab1e5" | ||
authors = ["jeremiedb <[email protected]>"] | ||
version = "0.15.2" | ||
version = "0.16.0" | ||
|
||
[deps] | ||
BSON = "fbb218c0-5317-5bc6-957e-2ee96dd4b1f0" | ||
|
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 |
---|---|---|
@@ -0,0 +1,144 @@ | ||
using DataFrames | ||
using Distributions | ||
using EvoTrees | ||
using LinearAlgebra | ||
using GLM | ||
using Random | ||
|
||
δ = 1.0e-6 | ||
b = fill(1.0 - δ, 3, 3) + δ * I | ||
z = zeros(3, 3) | ||
y = fill(0.5, 3) | ||
dist = MvNormal([ | ||
b z z 0.8*y | ||
z b z y | ||
z z b 1.2*y | ||
0.8*y' y' 1.2*y' 1.0]) | ||
Random.seed!(1) | ||
mat = rand(dist, 10_000); | ||
df = DataFrame(transpose(mat), [string.("x", 1:9); "y"]); | ||
target_name = "y" | ||
|
||
################################# | ||
# Tables API | ||
################################# | ||
config = EvoTreeRegressor(seed=123) | ||
m1 = fit_evotree(config, | ||
df; | ||
target_name="y", | ||
verbosity=0); | ||
EvoTrees.importance(m1) | ||
|
||
config = EvoTreeRegressor(seed=124) | ||
m2 = fit_evotree(config, | ||
df; | ||
target_name="y", | ||
verbosity=0); | ||
EvoTrees.importance(m2) | ||
|
||
# permuted tables doesn't return the same result - numerical rounding error? | ||
df2 = df[!, 10:-1:1] | ||
config = EvoTreeRegressor() | ||
m3 = fit_evotree(config, | ||
df2; | ||
target_name="y", | ||
verbosity=0); | ||
EvoTrees.importance(m3) | ||
|
||
# manual check on col permutations | ||
config = EvoTreeRegressor(max_depth=4) | ||
m1, cache1 = EvoTrees.init(config, df; target_name); | ||
EvoTrees.grow_evotree!(m1, cache1, config, EvoTrees.CPU) | ||
EvoTrees.importance(m1) | ||
|
||
df2 = df[!, 10:-1:1]; | ||
config = EvoTreeRegressor(max_depth=4) | ||
m2, cache2 = EvoTrees.init(config, df2; target_name); | ||
EvoTrees.grow_evotree!(m2, cache2, config, EvoTrees.CPU) | ||
EvoTrees.importance(m2) | ||
|
||
all(cache1.x_bin .== cache2.x_bin[:, 9:-1:1]) | ||
all(cache1.edges .== cache2.edges[9:-1:1]) | ||
m1.trees[2] | ||
m2.trees[2] | ||
|
||
m1.trees[2].feat | ||
m2.trees[2].feat | ||
|
||
Int.(m1.trees[2].cond_bin) | ||
Int.(m2.trees[2].cond_bin) | ||
|
||
|
||
config = EvoTreeRegressor(nrounds=100, eta=0.05, colsample=1.0) | ||
m3 = fit_evotree(config, | ||
df; | ||
target_name="y", | ||
verbosity=0); | ||
EvoTrees.importance(m3) | ||
|
||
################################# | ||
# Tables API | ||
################################# | ||
config = EvoTreeRegressor(colsample=0.5) | ||
m1 = fit_evotree(config, | ||
df; | ||
target_name="y", | ||
verbosity=0); | ||
EvoTrees.importance(m1) | ||
|
||
m2 = fit_evotree(config, | ||
df; | ||
target_name="y", | ||
verbosity=0); | ||
EvoTrees.importance(m2) | ||
|
||
################################# | ||
# Matrix API | ||
################################# | ||
x_train = Matrix(mat[1:9, :]') | ||
y_train = mat[10, :] | ||
|
||
config = EvoTreeRegressor() | ||
m1 = fit_evotree(config; | ||
x_train, | ||
y_train, | ||
verbosity=0); | ||
EvoTrees.importance(m1) | ||
|
||
m2 = fit_evotree(config; | ||
x_train, | ||
y_train, | ||
verbosity=0); | ||
EvoTrees.importance(m2) | ||
|
||
using GLM | ||
x_train = Matrix(mat[1:9, :]') | ||
y_train = mat[10, :] | ||
lm(x_train, y_train) | ||
|
||
################################# | ||
# Matrix debug API | ||
################################# | ||
x_train = Matrix(mat[1:9, :]') | ||
y_train = mat[10, :] | ||
|
||
config = EvoTreeRegressor() | ||
m1, cache1 = EvoTrees.init(config, x_train, y_train); | ||
EvoTrees.grow_evotree!(m1, cache1, config, EvoTrees.CPU) | ||
EvoTrees.importance(m1) | ||
|
||
m2, cache2 = EvoTrees.init(config, x_train, y_train); | ||
EvoTrees.grow_evotree!(m2, cache2, config, EvoTrees.CPU) | ||
EvoTrees.importance(m2) | ||
|
||
using MLJ | ||
using EvoTrees | ||
using MLJLinearModels | ||
X, y = make_regression() | ||
model = Stack( | ||
metalearner=LinearRegressor(), | ||
resampling=CV(nfolds=2), | ||
tree=EvoTreeRegressor() | ||
) | ||
mach = machine(model, X, y) | ||
fit!(mach) |
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
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
Oops, something went wrong.
46e9caa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register()
46e9caa
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/89502
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: