locked
How do I add multiple inputs in Bayes Point Machines? (in the infer.net example) RRS feed

  • Question

  • I have been following this example on Bayes Point Machines: http://research.microsoft.com/en-us/um/cambridge/projects/infernet/docs/Bayes%20Point%20Machine%20tutorial.aspx

    The values used as input are income and ages defined as such:

    double[] incomes = { 63, 16, 28, 55, 22, 20 };

    double[] ages = { 38, 23, 40, 27, 18, 40 };


    And the exit values for training are defined as a boolean:
    bool[] willBuy = { true, false, true, true, false, false };

    I've tried adding more values like height or gender but I can't seem to find a way to make the library accept more than two values.

    Can anyone explain to me how it should be done?
    • Edited by Tramagust Wednesday, June 27, 2012 3:41 PM added hyperlink
    Wednesday, June 27, 2012 3:29 PM

Answers

  • You need to insert your new values (e.g. height[i]) after ages[i] in this line :

    for (int i = 0; i < xdata.Length; i++) xdata[i] = Vector.FromArray(incomes[i], ages[i], 1);

    You then need to replace the 3s on this line with 1+(total number of values).  Since originally there were 2 values, this was set to 3.

    Variable<Vector> w = Variable.Random(new VectorGaussian(Vector.Zero(3),
                              
    PositiveDefiniteMatrix.Identity(3)));

    This ensures that the vector of weights w is the same size as the vector of input values.

    John W.

    • Marked as answer by Tramagust Thursday, June 28, 2012 9:25 PM
    • Unmarked as answer by Tramagust Thursday, June 28, 2012 9:25 PM
    • Marked as answer by Tramagust Thursday, June 28, 2012 9:26 PM
    Wednesday, June 27, 2012 5:34 PM

All replies

  • You need to insert your new values (e.g. height[i]) after ages[i] in this line :

    for (int i = 0; i < xdata.Length; i++) xdata[i] = Vector.FromArray(incomes[i], ages[i], 1);

    You then need to replace the 3s on this line with 1+(total number of values).  Since originally there were 2 values, this was set to 3.

    Variable<Vector> w = Variable.Random(new VectorGaussian(Vector.Zero(3),
                              
    PositiveDefiniteMatrix.Identity(3)));

    This ensures that the vector of weights w is the same size as the vector of input values.

    John W.

    • Marked as answer by Tramagust Thursday, June 28, 2012 9:25 PM
    • Unmarked as answer by Tramagust Thursday, June 28, 2012 9:25 PM
    • Marked as answer by Tramagust Thursday, June 28, 2012 9:26 PM
    Wednesday, June 27, 2012 5:34 PM
  • Thank you very much. It worked perfectly. I had suspected the change must be made in that for but I had missed the size declaration of W
    Thursday, June 28, 2012 9:26 PM