madeleineudell / LowRankModels.jl

LowRankModels.jl is a julia package for modeling and fitting generalized low rank models.
Other
190 stars 65 forks source link

Non-deterministic? #97

Open aaowens opened 5 years ago

aaowens commented 5 years ago
using LowRankModels, DataFrames, Random

import RDatasets

# pick a data set
df = RDatasets.dataset("psych", "msq")

# we'll just fit four of the columns, to try out all four datatypes
dd = DataFrame([df[:,s] for s in [:TOD, :Vigorous, :Wakeful, :Alert, :Aroused, :Active]])
dd[!,end] = (dd[:,end].==1)

# help out by telling GLRM the correct data types
datatypes = [:real, :ord, :ord, :ord, :ord, :bool]

First run:

Random.seed!(1)
glrm = GLRM(dd, 3, datatypes)
init_svd!(glrm)
julia> X,Y = fit!(glrm)
Fitting GLRM
Iteration 10: objective value = 616391.8041060292

Second run:

Random.seed!(1)
glrm = GLRM(dd, 3, datatypes)
init_svd!(glrm)
julia> X,Y = fit!(glrm)
Iteration 10: objective value = 616391.8040991233

The objective value listed is different, even though I used the same random seed. What explains this?

In this particular example it is fairly stable regardless, but I tried fitting a model on some of my actual data, and I can't get reproducible results.

I'm using Julia 1.1.1. Perhaps this is a multi-threading issue? I have nthreads = 1, yet when I used ctrl-C on the fit I saw an error Error thrown in threaded loop on thread 0:.