//tinh mse cho moi ca the //private double CalculateMSE(Individual_NSGA individual, double[][] inputData) //{ // // Chỗ này chính là chỗ cần dùng với RBF đây // RadialNetwork rn = new RadialNetwork(m_RadialNetwork); // double fitness = 0.0; // rn.SetWeights(individual.values); // fitness = rn.Accuracy(inputData); // return fitness; //} //tinh mse cho moi ca the private double CalculateMSE(Individual_NSGA individual, double[][] inputData) { // Chỗ này chính là chỗ cần dùng với RBF đây RadialNetwork rn = new RadialNetwork(m_RadialNetwork); double fitness = 0.0; rn.SetWeights(individual.values); fitness = rn.getMSEOf(inputData); return(fitness); }
private double CalculateFitnessOf(Individual_GA individual, double[][] inputData) { // Chỗ này chính là chỗ cần dùng với RBF đây RadialNetwork rn = new RadialNetwork(m_RadialNetwork); double fitness = 0.0; rn.SetWeights(individual.values); fitness = rn.Accuracy(inputData); individual.Fitness = fitness; return(fitness); }
public NSGAII(int m_Population_size, int m_IndividualLength, RadialNetwork RadialNetwork, double m_MaxEvaluations, double[][] inputData, int numberOfObjectives) { this.m_Population_size = m_Population_size; this.m_IndividualLength = m_IndividualLength; this.m_Random = new Random(); this.Population = new Population_NSGA(m_Population_size); this.m_RadialNetwork = RadialNetwork; this.m_MaxEvaluations = m_MaxEvaluations; this.inputData = inputData; mutationProb = 1.0 / m_IndividualLength; this.Population.Population_init(m_IndividualLength, numberOfObjectives); }
} // ctor public RadialNetwork(RadialNetwork newOne) { rnd = new Random(0); this.numInput = newOne.NumInput; this.numHidden = newOne.NumHidden; this.numOutput = newOne.NumOutput; this.inputs = newOne.Inputs; this.centroids = newOne.Centroids; this.widths = newOne.Widths; this.hoWeights = newOne.HoWeights; this.oBiases = newOne.OBiases; this.outputs = newOne.Outputs; } // ctor
private void btnStart_Click(object sender, EventArgs e) { //Get input from Form //Get testing rate if (!StringIsNull(txtTestingRate.Text)) { testingRate = double.Parse(txtTestingRate.Text); } //Get window size if (!StringIsNull(txtWindowSize.Text)) { windowSize = int.Parse(txtWindowSize.Text); } //Step1: Get inputTrain, idealTrain, inputTest, idealTest //GetTrainTest(data, out train, out test, testingRate); //GetInputIdeal(train, out inputTrain, out idealTrain, windowSize); //GetInputIdeal(train, out inputTest, out idealTest, windowSize); GetAllData(data, out allData, windowSize); double[][] trainData = null; double[][] testData = null; int seed = 8; // gives a good demo GetTrainTest(allData, seed, out trainData, out testData, testingRate); Console.WriteLine("\nCreating a 4-5-3 radial basis function network"); int numInput = windowSize; int numHidden = 2 * numInput; int numOutput = 1; RadialNetwork rn = new RadialNetwork(numInput, numHidden, numOutput); Console.WriteLine("\nBeginning RBF training\n"); int maxIterations = 50; // max for GA int maxEvaluations = 1000; // max for NSGAII //double[] bestWeights = rn.TrainWithPSO(trainData, maxIterations); //double[] bestWeights = rn.TrainWithGA(trainData, maxIterations); Population_NSGA bestPopulation = rn.TrainWithNSGAII(trainData, maxEvaluations); Console.WriteLine("\nEvaluating result RBF classification accuracy on the test data"); //rn.SetWeights(bestWeights); double acc = rn.Accuracy(testData); //Set Textbox SetText(txtTestErr, acc.ToString("F5")); Console.WriteLine("Complete Program!"); }
public GAs(int m_Population_size, int m_IndividualLength, RadialNetwork RadialNetwork, double m_MaxIterations, double[][] inputData) { this.m_Population_size = m_Population_size; this.m_IndividualLength = m_IndividualLength; this.m_Random = new Random(); this.Population = new Population_GA(m_Population_size); this.m_RadialNetwork = RadialNetwork; this.m_MaxIterations = m_MaxIterations; this.Population.Population_init(m_IndividualLength); // set fitness for (int i = 0; i < m_Population_size; i++) { CalculateFitnessOf(Population.Individuals[i], inputData); } }