Open superbolide opened 6 years ago
This happen with Accord.NET-3.8.0 and vs2010:
using Accord.Controls;
using Accord.IO;
using Accord.MachineLearning.Bayes;
using Accord.MachineLearning.DecisionTrees;
using Accord.MachineLearning.DecisionTrees.Learning;
using Accord.MachineLearning.VectorMachines.Learning;
using Accord.Math;
using Accord.Neuro;
using Accord.Neuro.Learning;
using Accord.Statistics;
using Accord.Statistics.Analysis;
using Accord.Statistics.Distributions.Univariate;
using Accord.Statistics.Kernels;
using Accord.Statistics.Models.Regression;
using Accord.Statistics.Models.Regression.Fitting;
If a remove using system.numerics do this:
double[][] inputs =
{
/* 1.*/ new double[] { 0, 0 },
/* 2.*/ new double[] { 1, 0 },
/* 3.*/ new double[] { 0, 1 },
/* 4.*/ new double[] { 1, 1 },
};
int[] outputs =
{
/* 1. 0 xor 0 = 0: */ 0,
/* 2. 1 xor 0 = 1: */ 1,
/* 3. 0 xor 1 = 1: */ 1,
/* 4. 1 xor 1 = 0: */ 0,
};
It works!
Hi @superbolide,
Many thanks for opening the issue! The problem was that the NaiveBayes learning class was not validating the inputs correctly when one is trying to learn a multi-class classifier using only two classes where those classes are being represented as -1 and +1 values.
The solution would be to change line
int[] outputs = table.Columns["G"].ToArray<int>();
to be
int[] outputs = Classes.ToZeroOne(table.Columns["G"].ToArray<int>());
to force the outputs to be represented as 0 or 1 values instead of -1 or +1.
I will also be committing a fix to improve argument validation in this case.
Regards, Cesar
What would you like to submit? (put an 'x' inside the bracket that applies)
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Accord.Math.dll
I try this (my fist app with accord library):