Skip to content

Commit

Permalink
edits
Browse files Browse the repository at this point in the history
  • Loading branch information
kafisatz committed Feb 3, 2025
1 parent 0ad12b0 commit 3b900f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
15 changes: 7 additions & 8 deletions tutorials/2.frenchMTPLdata_boosting.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# Load packages
##############################
t0 = time_ns()
cd(joinpath(GLOBAL_julia_code_folder, "DecisionTrees.jl"))
# @info("You may want to run 'pkg> instantiate' when you first run this. Use ] to enter the package mode.")

using Distributed
Expand All @@ -37,14 +36,14 @@ datafile = joinpath("data", "freMTPL2", "freMTPL2.csv")
# also the Noll, Salzmann, Wüthrich Paper has some descriptive graphs of the data.

# add AreaInteger as new variable, i.e. A:F -> 1:6 (as suggested in the paper of Wüthrich, Noll, Salzmann)
areasSorted = sort(unique(fullData[:Area]))
AreaInteger = map(x->findall((in)([x]), areasSorted)[1], fullData[:Area])
fullData[:AreaInteger] = AreaInteger
areasSorted = sort(unique(fullData[!,:Area]))
AreaInteger = map(x->findall((in)([x]), areasSorted)[1], fullData[!,:Area])
fullData[!,:AreaInteger] = AreaInteger

# correct for unreasonable observations
for i = 1:size(fullData, 1)
fullData[:ClaimNb][i] = min(4, fullData[:ClaimNb][i])
fullData[:Exposure][i] = min(1.0, fullData[:Exposure][i])
fullData[!,:ClaimNb][i] = min(4, fullData[!,:ClaimNb][i])
fullData[!,:Exposure][i] = min(1.0, fullData[!,:Exposure][i])
end

# set independent variables
Expand All @@ -55,7 +54,7 @@ selected_explanatory_vars = ["Area","AreaInteger","VehPower","VehAge","DrivAge",
# check type of each column
for x in selected_explanatory_vars
println(x)
println(eltype(fullData[Symbol(x)]))
println(eltype(fullData[!,Symbol(x)]))
println("first ten values")
print(fullData[1:10,Symbol(x)])
println("")
Expand Down Expand Up @@ -99,7 +98,7 @@ dtmtable.features # explanatory variables
# we realize that it may be sutiable to define the splitting in a different manner (than uniformly spaced).
# this feature might be added at a later time. You can consider the function add_coded_numdata!(...) to see how splitting points are chosen

originalTrnValIndex = deepcopy(fullData[:trnTest])
originalTrnValIndex = deepcopy(fullData[!,:trnTest])

# Redefine trn and val data sets
# if you prefer train on X% of the data, you can use this function to adjust the training set. By default it is sampled randomly
Expand Down
1 change: 0 additions & 1 deletion tutorials/3.frenchMTPLdata_modelling_GLM_residual.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
###########

t0 = time_ns()
cd(joinpath(GLOBAL_julia_code_folder, "DecisionTrees.jl"))
# @info("You may want to run 'pkg> instantiate' when you first run this. Use ] to enter the package mode.")
using Distributed
# Distributed.@everywhere using Revise
Expand Down

0 comments on commit 3b900f8

Please sign in to comment.