-
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 #202 from Evovest/split-fix
Split fix
- Loading branch information
Showing
14 changed files
with
156 additions
and
44 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.14.2" | ||
version = "0.14.3" | ||
|
||
[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,126 @@ | ||
using Revise | ||
using Statistics | ||
using StatsBase: sample | ||
using EvoTrees | ||
using BenchmarkTools | ||
|
||
using CSV, DataFrames, MLJBase, EvoTrees | ||
using StableRNGs | ||
|
||
data = CSV.read(joinpath(@__DIR__, "..", "data", "debug", "pb_data.csv"), DataFrame) | ||
y = categorical(data.target) | ||
X = data[!, Not(:target)] | ||
|
||
train, test = MLJBase.train_test_pairs(Holdout(), 1:size(X, 1), X, y)[1] | ||
rng = StableRNG(6) | ||
model = EvoTreeClassifier(nrounds = 5, lambda = 1e-5, max_depth = 7, rng = rng) | ||
Xtrain, ytrain = MLJBase.reformat(model, selectrows(X, train), selectrows(y, train)) | ||
# MLJBase.fit(model, 1, Xtrain, ytrain); | ||
|
||
# EvoTrees params | ||
rng = StableRNG(6) | ||
params_evo = EvoTreeClassifier(; | ||
T = Float32, | ||
nrounds = 200, | ||
lambda = 0.0, | ||
gamma = 0.0, | ||
eta = 0.1, | ||
max_depth = 7, | ||
min_weight = 1.0, | ||
rowsample = 1.0, | ||
colsample = 1.0, | ||
nbins = 64, | ||
rng, | ||
) | ||
|
||
using CategoricalArrays | ||
x_train = Xtrain[:matrix] | ||
y_train = CategoricalArrays.levelcode.(ytrain) | ||
|
||
mean(y_train) | ||
sum(ytrain .== true) ./ length(y_train) | ||
|
||
@info "evotrees train CPU:" | ||
params_evo.device = "cpu" | ||
@time m_evo = fit_evotree(params_evo; x_train, y_train); | ||
# @time m_evo = fit_evotree(params_evo; x_train, y_train); | ||
# @time m_evo = fit_evotree(params_evo; x_train, y_train); | ||
|
||
# function h1(h, hL, hR, ∑, K, nbins) | ||
# KK = 2 * K + 1 | ||
# @inbounds for j in js | ||
# @inbounds for k = 1:KK | ||
# val = h[k, 1, j] | ||
# hL[k, 1, j] = val | ||
# hR[k, 1, j] = ∑[k, j] - val | ||
# end | ||
# @inbounds for bin = 2:nbins | ||
# @inbounds for k = 1:KK | ||
# val = h[k, bin, j] | ||
# hL[k, bin, j] = hL[k, bin-1, j] + val | ||
# hR[k, bin, j] = hR[k, bin-1, j] - val | ||
# end | ||
# end | ||
# end | ||
# return hR | ||
# end | ||
|
||
# function h2(h, hL, hR, nbins) | ||
# cumsum!(hL, h, dims = 2) | ||
# hR .= view(hL, :, nbins:nbins, :) .- hL | ||
# return hR | ||
# end | ||
|
||
# nbins = 64 | ||
# js = 12 | ||
# K = 2 | ||
# h = rand(2*K+1, nbins, js) | ||
# hL = zeros(2*K+1, nbins, js) | ||
# hR = zeros(2*K+1, nbins, js) | ||
# ∑ = dropdims(sum(h, dims=2), dims=2) | ||
|
||
# x1 = h1(h, hL, hR, ∑, K, nbins) | ||
# x2 = h2(h, hL, hR, nbins) | ||
|
||
# minimum(x1 .- x2) | ||
# maximum(x1 .- x2) | ||
|
||
mutable struct Node | ||
h | ||
hL | ||
hR | ||
end | ||
|
||
function h1_A(node, K, nbins) | ||
|
||
KK = 2 * K + 1 | ||
h = node.h | ||
hL = node.hL | ||
hR = node.hR | ||
∑ = node.∑ | ||
|
||
hL = copy(hL) | ||
hR = copy(hR) | ||
@inbounds for j in js | ||
@inbounds for k = 1:KK | ||
val = h[k, 1, j] | ||
hL[k, 1, j] = val | ||
hR[k, 1, j] = ∑[k] - val | ||
end | ||
@inbounds for bin = 2:nbins | ||
@inbounds for k = 1:KK | ||
val = h[k, bin, j] | ||
hL[k, bin, j] = hL[k, bin-1, j] + val | ||
hR[k, bin, j] = hR[k, bin-1, j] - val | ||
end | ||
end | ||
end | ||
|
||
hL2 = copy(hL) | ||
hR2 = copy(hR) | ||
cumsum!(hL2, h, dims = 2) | ||
hR2 .= view(hL2, :, nbins:nbins, :) .- hL2 | ||
|
||
@info "max abs diff hR" maximum(abs.(hR[3,:,:] .- hR2[3,:,:])) | ||
return nothing | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
717304d
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()
717304d
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/74652
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: