Infer.NET 101 -- example with two cyclists RRS feed

  • Question

  • I have a question about extending the last example from the Infer.NET 101 document -- the one with two cyclists. I used the example on my own data -- results of student examinations.

    I have data of around 4000 students, so I replaced the two separate instances of CyclistTraining class with a list of my own StudentTraining class (the StudentTraining looks and works exactly as CyclistTraining, I basically just renamed it):

    private List<StudentTraining> studentsTraining;
    public void CreateModel(int numStudents)
        this.numStudents = numStudents;
        this.studentsTraining = new List<StudentTraining>();
        for (int i = 0; i < this.numStudents; i++)
            this.studentsTraining.Add(new StudentTraining());

    However for 4000 students this code is very slow (the slow bit is the compilation -- the model is compiled for each student separately, which takes few minutes). I was wondering if this approach is correct or no. What I understood from the document is that the model doesn't need to be compiled every time if it doesn't change. (Am I right?) Is there any recommended approach to how to work with this amount of data?

    Monday, January 28, 2013 4:15 PM


  • In the end I rewrote the model from the example so that each variable is now an array. So for example, where there was

    protected Variable<double> AverageTime;

    which is drawn from

    protected Variable<Gaussian> AverageTimePrior;

    I am now using

    protected VariableArray<double> AbilityMean;
    protected VariableArray<Gaussian> AbilityMeanPrior;

    I kept the variable TravelTimes from the example as VariableArray<double>, because in every iteration I am adding only one new observed value per student. The inference step in my model now returns an array of Gaussians (instead of one Gaussian distribution as in the example).

    I'm hoping this is the correct approach. And (even though this was a very simple question) if somebody struggles with the same thing I'm hoping my solution might help.

    • Marked as answer by robodasha Tuesday, January 29, 2013 4:03 PM
    Tuesday, January 29, 2013 4:03 PM