Exemplo n.º 1
0
		/// <summary>
		/// Builds classifier using specified data set
		/// (trains neural network using that data set)
		/// </summary>
		/// <param name="data"> Instance weka data set </param>
		/// <exception cref="Exception"> </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: @Override public void buildClassifier(weka.core.Instances data) throws Exception
		public override void buildClassifier(Instances data)
		{
			// convert weka dataset to neuroph dataset
			DataSet dataSet = WekaDataSetConverter.convertWekaToNeurophDataset(data, neuralNet.InputsCount, neuralNet.OutputsCount);
			// train neural network
			neuralNet.learn(dataSet);
		}
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static void main(String[] args) throws Exception
        public static void Main(string[] args)
        {
            // create weka dataset from file
            DataSource dataSource  = new DataSource("datasets/iris.arff");
            Instances  wekaDataset = dataSource.DataSet;

            wekaDataset.setClassIndex(4);

            // normalize dataset
            Normalize filter = new Normalize();

            filter.InputFormat = wekaDataset;
            wekaDataset        = Filter.useFilter(wekaDataset, filter);

            // convert weka dataset to neuroph dataset
            DataSet neurophDataset = WekaDataSetConverter.convertWekaToNeurophDataset(wekaDataset, 4, 3);

            // convert back neuroph dataset to weka dataset
            Instances testWekaDataset = WekaDataSetConverter.convertNeurophToWekaDataset(neurophDataset);

            // print out all to compare
            Console.WriteLine("Weka data set from file");
            printDataSet(wekaDataset);

            Console.WriteLine("Neuroph data set converted from Weka data set");
            printDataSet(neurophDataset);

            Console.WriteLine("Weka data set reconverted from Neuroph data set");
            printDataSet(testWekaDataset);

            Console.WriteLine("Testing WekaNeurophClassifier");
            testNeurophWekaClassifier(wekaDataset);
        }