I’m trying to go through the code in Julia for DataScience and this line does not work:

fit!(regr_1, XX, y)

in:

srand(100)

X = sort(5 * rand(80))

XX = reshape(X, 80, 1)

y = sin(X)

y[1:5:end] += 3 * (0.5 - rand(16))

#
Fit regression model

regr_1 = DecisionTreeRegressor()

regr_2 = DecisionTreeRegressor(pruning_purity_threshold=0.05)

fit!(regr_1, XX, y)

fit!(regr_2, XX, y)

Any help would be appreciated!

Not sure what package provides `DecisionTreeRegressor`

, but usually the convention is something like,

```
model = DecisionTreeRegressor(XX, y)
fit!(model)
```

and with keyword arguments,

```
model = DecisionTreeRegressor(XX, y, pruning_purity_threshold = 0.05)
fit!(model)
```

or

```
model = DecisionTreeRegressor(XX, y)
fit!(model, pruning_purity_threshold = 0.05)
```

ValdarT
3
This code works fine for me (need to load the package with `using DecisionTree`

, of course). What is the exact error message you are getting?

It seems the computer needed a reboot to load the packages after Pkg.add(“DecisionTree”) This has happened with several other packages previously.