# How to get reproducible results of classification models?: example using DecisionTree

**URL:** https://discourse.julialang.org/t/how-to-get-reproducible-results-of-classification-models-example-using-decisiontree/36452
**Category:** Machine Learning
**Tags:** question
**Created:** [March 24, 2020, 3:12pm UTC](https://discourse.julialang.org/t/how-to-get-reproducible-results-of-classification-models-example-using-decisiontree/36452 "2020-03-24T15:12:55Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![rio](https://avatars.discourse-cdn.com/v4/letter/r/ea666f/32.png) [@rio](https://discourse.julialang.org/u/rio)
#### Post date: [March 24, 2020, 3:12pm UTC](https://discourse.julialang.org/t/how-to-get-reproducible-results-of-classification-models-example-using-decisiontree/36452/1 "2020-03-24T15:12:55Z")

</div>

Hi!

I would like to train a classifier (eg. Random Forests) and I would like to get the same results if I train/run the model again. My first attempt was to try to set the seed of the random number generator, like this:

```julia
# example from https://github.com/bensadeghi/DecisionTree.jl
using DecisionTree
features, labels = load_data("iris")
features = float.(features)
labels = string.(labels)

# train random forest classifier
# using 2 random features, 10 trees, 0.5 portion of samples per tree, and a maximum tree depth of 6

Random.seed!(1234) # My attempt here!

model = build_forest(labels, features, 2, 10, 0.5, 6)
println(model)

n_folds=3; n_subfeatures=2
accuracy = nfoldCV_forest(labels, features, n_folds, n_subfeatures)

```

Unfortunately, the resulting model seems to be a bit different each time I run the code. The same for the accuracy. I am using DecisionTree v0.10.1

Please, how could I get reproducible results?

Thank you in advance
