Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MarkovProcesses.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bentriou Mahmoud
MarkovProcesses.jl
Commits
098f8c9e
Commit
098f8c9e
authored
2 years ago
by
Mahmoud Bentriou
Browse files
Options
Downloads
Patches
Plain Diff
Add new feature to rf abc: presimulated dataset
parent
d5de2c34
No related branches found
No related tags found
No related merge requests found
Pipeline
#30272
passed
2 years ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
algorithms/abc_model_choice.jl
+12
-6
12 additions, 6 deletions
algorithms/abc_model_choice.jl
with
12 additions
and
6 deletions
algorithms/abc_model_choice.jl
+
12
−
6
View file @
098f8c9e
...
...
@@ -175,11 +175,12 @@ The mandatory arguments are:
* `summary_stats_func::Function`: the function that computes the summary statistics over a model simulation.
The optional arguments are:
* `abc_trainset`: an already simulated dataset with ``abc_model_choice_dataset` (by default: nothing)
* `models_prior`: the prior over the models (by default: discrete uniform distribution)
* `k`: the k nearest samples from the observations to keep in the reference table (by default: k = N_ref)
* `distance_func`: the distance function, has to be defined if k < N_ref
* `hyperparameters_range`: a dict with the hyperparameters range values for the cross validation
fit of the
Random Forest (by default: `Dict(:n_estimators => [200], :min_samples_leaf => [1], :min_samples_split => [2])`).
* `hyperparameters_range`: a dict with the hyperparameters range values for the cross validation
fit of the
Random Forest (by default: `Dict(:n_estimators => [200], :min_samples_leaf => [1], :min_samples_split => [2])`).
See scikit-learn documentation of RandomForestClassifier for the hyperparameters name.
The result is a `RandomForestABC` object with fields:
...
...
@@ -192,16 +193,21 @@ The result is a `RandomForestABC` object with fields:
function
rf_abc_model_choice
(
models
::
Vector
{
<:
Union
{
Model
,
ParametricModel
}},
summary_stats_observations
,
summary_stats_func
::
Function
,
N_ref
::
Int
;
models_prior
::
DiscreteUnivariateDistribution
=
Categorical
([
1
/
length
(
models
)
for
i
=
1
:
length
(
models
)]),
abc_trainset
::
Union
{
Nothing
,
AbcModelChoiceDataset
}
=
nothing
,
models_prior
::
DiscreteUnivariateDistribution
=
Categorical
([
1
/
length
(
models
)
for
i
=
1
:
length
(
models
)]),
k
::
Int
=
N_ref
,
distance_func
::
Function
=
(
x
,
y
)
->
1
,
hyperparameters_range
::
Dict
=
Dict
(
:
n_estimators
=>
[
200
],
:
min_samples_leaf
=>
[
1
],
:
min_samples_split
=>
[
2
]))
@assert
k
<=
N_ref
trainset
=
abc_model_choice_dataset
(
models
,
models_prior
,
summary_stats_observations
,
summary_stats_func
,
distance_func
,
k
,
N_ref
)
if
isnothing
(
abc_trainset
)
abc_trainset
=
abc_model_choice_dataset
(
models
,
models_prior
,
summary_stats_observations
,
summary_stats_func
,
distance_func
,
k
,
N_ref
)
end
gridsearch
=
GridSearchCV
(
RandomForestClassifier
(
oob_score
=
true
),
hyperparameters_range
)
fit!
(
gridsearch
,
transpose
(
trainset
.
X
),
trainset
.
y
)
fit!
(
gridsearch
,
transpose
(
abc_
trainset
.
X
),
abc_
trainset
.
y
)
best_rf
=
gridsearch
.
best_estimator_
return
RandomForestABC
(
trainset
,
best_rf
,
summary_stats_observations
,
predict
(
best_rf
,
[
summary_stats_observations
]))
return
RandomForestABC
(
abc_
trainset
,
best_rf
,
summary_stats_observations
,
predict
(
best_rf
,
[
summary_stats_observations
]))
end
"""
...
...
This diff is collapsed.
Click to expand it.
Bentriou Mahmoud
@2017bentrioum
mentioned in commit
60275a80
·
2 years ago
mentioned in commit
60275a80
mentioned in commit 60275a800c880412c274e51fb29c6aa88861857a
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment