Skip to content
This repository was archived by the owner on Nov 19, 2020. It is now read-only.
This repository was archived by the owner on Nov 19, 2020. It is now read-only.

Problem with Naive Bayes - Index was outside the bounds of the array #831

@whitemouse2100

Description

@whitemouse2100

examples.xlsx
Dear
I am a new guy in machine learning. I have a problem with Naive Bayers. I use code in tutorial about Naive Bayers.
This is my code:
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string FolderPath = openFileDialog1.FileName;
DataTable DanhSach = new ExcelReader(FolderPath).GetWorksheet("Classification - Yin Yang");
double[][] inputs = DanhSach.ToJagged("X", "Y");
// double[][] outputs = DanhSach.ToJagged("G", "K");
int[] outputs = DanhSach.Columns["G"].ToArray();

            //ScatterplotBox.Show("Yin-Yang", inputs, outputs).Hold();
            var teacher = new NaiveBayesLearning<NormalDistribution>();
            var nb = teacher.Learn(inputs, outputs);
            int numberOfClasses = nb.NumberOfClasses; // should be 2 (positive or negative)
            int nunmberOfInputs = nb.NumberOfInputs;  // should be 2 (x and y coordinates)

            // Classify the samples using the model
            int[] answers = nb.Decide(inputs);

            // Plot the results
            ScatterplotBox.Show("Expected results", inputs, outputs);
            ScatterplotBox.Show("Naive Bayes results", inputs, answers)
                .Hold();

        }

I have attach file data which I download from tutorial.

Then I build this codes. And I have a bug is "Index was outside the bounds of the array". I don't know why. Please help me. Thanks very much.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions