错误索引超出了数组的界限。(C#ASP.NET)

错误索引超出了数组的界限。(C#ASP.NET),c#,asp.net,weka,C#,Asp.net,Weka,(我使用Visual Studio 2015进行编程。我编写代码预测结果,并使用.arff文件(来自WEKA)获取实例。) 当我完成变量的输入并运行程序时,我遇到了问题。 然后出现错误:“错误索引超出了数组的边界。”从0-83开始,当我将值输入整数变量(从文本框)时,没有出现错误。但如果我输入84或更多的值,就会出现错误 错误发生在: “TextBox1.Text=Convert.ToString(model.classifyInstance(insts.lastInstance());” 我不

(我使用Visual Studio 2015进行编程。我编写代码预测结果,并使用.arff文件(来自WEKA)获取实例。)

当我完成变量的输入并运行程序时,我遇到了问题。 然后出现错误:“错误索引超出了数组的边界。”从0-83开始,当我将值输入整数变量(从文本框)时,没有出现错误。但如果我输入84或更多的值,就会出现错误

错误发生在:
“TextBox1.Text=Convert.ToString(model.classifyInstance(insts.lastInstance());”

我不知道怎么解决它。请帮忙

using System;
using System.Data.SqlClient;
using System.Configuration;
using weka.core;
using weka.classifiers.functions;
using weka.classifiers.meta;
using weka.classifiers;

namespace pdhd
{
    public partial class Survey : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void Button1_Click(object sender, EventArgs e) {
            int weight = Convert.ToInt32(txtWeight.Text);
            int height = Convert.ToInt32(txtHeight.Text);
            int sex; if (BoxMale.Checked == true && BoxFemale.Checked == false) { sex = 1; }
            else if (BoxMale.Checked == false && BoxFemale.Checked == true) { sex = 2; }
            else { sex = 0; }
            float H = (height / 100) ^ 2;
            int age = Convert.ToInt32(txtAge.Text);
            float bmi = weight / H;
            int bloodup = Convert.ToInt32(txtBloodUp.Text);
            int blooddown = Convert.ToInt32(txtBloodDown.Text);
            int ppg = Convert.ToInt32(txtBloodSugar.Text);
            char pardiabete; if (BoxParentDiabete.Checked == true) { pardiabete = 'Y'; } else { pardiabete = 'N'; }
            char parhyper; if (BoxParentHP.Checked == true) { parhyper = 'Y'; } else { parhyper = 'N'; }
            char parheart; if (BoxParentHD.Checked == true) { parheart = 'Y'; } else { parheart = 'N'; }
            char brodiabete; if (BoxBroSisDiabete.Checked == true) { brodiabete = 'Y'; } else { brodiabete = 'N'; }
            char brohyper; if (BoxBroSisHP.Checked == true) { brohyper = 'Y'; } else { brohyper = 'N'; }
            char broheart; if (BoxBroSisHD.Checked == true) { broheart = 'Y'; } else { broheart = 'N'; }
            char waterThirst; if (BoxWaterThirst.Checked == true) { waterThirst = 'Y'; } else { waterThirst = 'N'; }
            char eatthin; if (BoxEatWeightLose.Checked == true) { eatthin = 'Y'; } else { eatthin = 'N'; }
            char weightlost; if (BoxFastWeightLose.Checked == true) { weightlost = 'Y'; } else { weightlost = 'N'; }
            char bodyitch; if (BoxBodyItch.Checked == true) { bodyitch = 'Y'; } else { bodyitch = 'N'; }
            char eyeblur; if (BoxEyeBlur.Checked == true) { eyeblur = 'Y'; } else { eyeblur = 'N'; }
            char handlegnerve; if (BoxHandLegNerve.Checked == true) { handlegnerve = 'Y'; } else { handlegnerve = 'N'; }
            char smoke; if (BoxSmoke.Checked == true) { smoke = 'Y'; } else { smoke = 'N'; }
            char drink; if (BoxBoost.Checked == true) { drink = 'Y'; } else { drink = 'N'; }
            int exercise = Convert.ToInt32(txtExcercise.Text);
            char likesalt; if (BoxLikeSalt.Checked == true) { likesalt = 'Y'; } else { likesalt = 'N'; }
            char urine; if (BoxFrequentPiss.Checked == true) { urine = 'Y'; } else { urine = 'N'; }
            CreateModelDB(sex, age, bmi, bloodup, blooddown, ppg, pardiabete, brodiabete, waterThirst, eatthin, weightlost, bodyitch, eyeblur, handlegnerve, smoke, drink, exercise, likesalt, urine);
             }
        public void CreateModelDB(int SEX, int AGE, float BMI, int BLOODUP, int BLOODDOWN, int PPG, char PARDIABETE, char BRODIABETE, char WATER, char EATTHIN, char WEIGHTLOST, char BODYITCH, char EYEBLUR, char HANDLEGNERVE, char SMOKE, char DRINK, int EXERCISE, char LIKESALT, char URINE) {

            try
            {
                weka.core.Instances insts = new weka.core.Instances(new java.io.FileReader("/ReferenceForVS/Net_Project/data/pdhd_diabete.arff"));

                weka.core.DenseInstance record = new weka.core.DenseInstance(20);


                record.setValue(insts.attribute(0), SEX);
                record.setValue(insts.attribute(1), AGE);
                record.setValue(insts.attribute(2), BMI);
                record.setValue(insts.attribute(3), BLOODUP);
                record.setValue(insts.attribute(4), BLOODDOWN);
                record.setValue(insts.attribute(5), PPG);
                record.setValue(insts.attribute(6), PARDIABETE);
                record.setValue(insts.attribute(7), BRODIABETE);
                record.setValue(insts.attribute(8), WATER);
                record.setValue(insts.attribute(9), EATTHIN);
                record.setValue(insts.attribute(10), WEIGHTLOST);
                record.setValue(insts.attribute(11), BODYITCH);
                record.setValue(insts.attribute(12), EYEBLUR);
                record.setValue(insts.attribute(13), HANDLEGNERVE);
                record.setValue(insts.attribute(14), SMOKE);
                record.setValue(insts.attribute(15), DRINK);
                record.setValue(insts.attribute(16), EXERCISE);
                record.setValue(insts.attribute(17), LIKESALT);
                record.setValue(insts.attribute(18), URINE);

                insts.add(record);
                insts.setClassIndex(insts.numAttributes() - 1);

                weka.classifiers.trees.J48 model = new weka.classifiers.trees.J48();

                model.buildClassifier(insts);

                TextBox1.Text = Convert.ToString(model.classifyInstance(insts.lastInstance()));

            }
            catch(java.lang.Exception ex)
            {
                ex.printStackTrace();
            }
        }
     }
}

pdhd_diabete.arff中有多少个实例?.arff文件中有20个实例。1-19是因素,20是结果或目标类。