getOutputLayerNeurons method
Gets the output layer neurons based on the provided class attribute className.
This method searches for the attribute with the name className in the
attributesList. If the attribute type is 'nominal', it creates a Neuron
for each nominal value. If the attribute type is 'numeric', it creates a single
Neuron with the attribute name. Throws OutputLayerNameError if the attribute
is not found.
-
Parameters:
- className: The name of the class attribute for which output neurons are needed.
-
Returns: A list of Neurons representing the output layer.
Implementation
List<Neuron> getOutputLayerNeurons({required String className}) {
try {
List<Neuron> neurons = [];
ARFFAttributes attributes =
attributesList.firstWhere((attribute) => attribute.name == className);
if (attributes.type == 'nominal') {
for (String name in attributes.nominalValues!) {
neurons.add(Neuron(name: name));
}
return neurons;
} else if (attributes.type == 'numeric') {
neurons.add(Neuron(name: attributes.name));
return neurons;
} else {
return [];
}
} catch (exception) {
throw OutputLayerNameError();
}
}