You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
It is sad that the examples of Accord.NET is extremely primitive and insufficient. Therefore, I am having hard time to figure out how to use the system properly.
int irNumberOfExamples = File.ReadAllLines(srFileName).Count();
double[][] input = new double[irNumberOfExamples][];
double[][] output = new double[irNumberOfExamples][];
List<double> lstOutPutClasses = new List<double>();
NumberFormatInfo formatProvider = new NumberFormatInfo();
formatProvider.NumberDecimalSeparator = ".";
formatProvider.NumberGroupSeparator = ",";
foreach (var vrPerLine in File.ReadAllLines(srFileName))
{
var vrOutPut = Convert.ToDouble(vrPerLine.Split(',').Last(), formatProvider);
if (lstOutPutClasses.Contains(vrOutPut) == false)
{
lstOutPutClasses.Add(vrOutPut);
}
}
int irCounter = 0;
foreach (var vrPerLine in File.ReadAllLines(srFileName))
{
input[irCounter] = vrPerLine.Split(',').SkipLast(1).
Select(pr => Convert.ToDouble(pr.Replace("I", "0.0").Replace("M", "0.5").Replace("F", "1.0"), formatProvider)).ToArray();
var vrCurrentOutClass = Convert.ToDouble(vrPerLine.Split(',').Last(), formatProvider);
output[irCounter][lstOutPutClasses.IndexOf(vrCurrentOutClass)] = 1;
irCounter++;
}
This generates the output class like below
And here the code of training part
int irFinalClassCount = lstOutPutClasses.Count;
double learningRate = 0.1;
int irNumberOfFeatures = input[0].Length;
ActivationNetwork network3 = new ActivationNetwork(
new SigmoidFunction(2),//activation function
irNumberOfFeatures,//input layer equal number of features
12,// 12 neurons at the hidden layer_1
irFinalClassCount); //output layer equal to number of output classes
BackPropagationLearning bpteacher = new BackPropagationLearning(network3);
bpteacher.LearningRate = 0.1;
bpteacher.Momentum = 0.5;
for (int i = 0; i < 200000; i++)
{
double error = bpteacher.RunEpoch(input, output);//train the algorithm
var vrAcc = calculateAcurracy(network3, input, output);
Console.WriteLine("BackPropagationLearning -> " + i + ", Error = " + error.ToString("N2") + "\t\t accuracy: " + vrAcc);
}
So my second question is about calculating accuracy. The BackPropagationLearning algorithm generates weights for each output neuron. So I counted the highest one as the prediction. Is my approach and code correct?
I am believe I am on the right track but I want to be sure by getting feedback of an Accord.NET library expert
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Source of the question : https://stackoverflow.com/questions/64827817/how-to-use-activationnetwork-of-accord-net-properly-to-do-machine-learning-tasks
It is sad that the examples of Accord.NET is extremely primitive and insufficient. Therefore, I am having hard time to figure out how to use the system properly.
The entire source code of my application is uploaded to here : https://github.com/FurkanGozukara/CSE419-Artificial-Intelligence-and-Machine-Learning-2020/tree/master/source%20codes/lecture%206%20perceptron%20example
The video of this lecture is here (3 hours 11 minutes) : https://youtu.be/qrklFBewlJA
My biggest question is about how to provide output classes?
Lets say for the dataset abalone (http://archive.ics.uci.edu/ml/datasets/Abalone) there are 28 output classes which are the age of abalone : https://github.com/FurkanGozukara/CSE419-Artificial-Intelligence-and-Machine-Learning-2020/blob/master/source%20codes/lecture%206%20perceptron%20example/lecture%206%20perceptron%20example/bin/Debug/netcoreapp3.1/abalone.data
How to compose the output class?
Like this way?
This generates the output class like below
And here the code of training part
So my second question is about calculating accuracy. The BackPropagationLearning algorithm generates weights for each output neuron. So I counted the highest one as the prediction. Is my approach and code correct?
I am believe I am on the right track but I want to be sure by getting feedback of an Accord.NET library expert
The text was updated successfully, but these errors were encountered: