Building Classification#

This page covers building Tabular Classification models for categorizing data into discrete classes.

When to Use Classification#

Use the Classification template when:

  • Your outputs are discrete categories or labels (not continuous values)

  • You want to assign inputs to one of several classes

  • Examples: disease diagnosis, quality grades, object categories

Important

Classification outputs must be one-hot encoded. Each row contains exactly one 1 (the class) and 0 elsewhere.

Building a Classification Model#

1. Create a new project

Launch NeurEco GUI and select Tabular Classification.

2. Configure settings

In the Settings tab:

  • Training data: Select your input file and one-hot encoded output file

  • Validation percentage: Adjust if needed (default: 33.33%)

  • Normalization: Configure input normalization (output normalization is handled automatically for classification)

  • GPU: Enable if available for faster training

3. Start the build

Click the BUILD button. NeurEco will:

  • Display training progress in the Training panel

  • Show classification accuracy metrics

  • Save checkpoints periodically

4. Monitor progress

Watch the training metrics including classification accuracy. The build automatically stops when optimal accuracy is reached.

One-Hot Encoding#

Classification requires one-hot encoded outputs. Here’s how to convert integer labels:

Example: Converting integer labels to one-hot

import numpy as np

# Original labels: 0, 1, 2 (3 classes)
labels = np.array([0, 1, 2, 0, 1, 2, 0, 1])

# Convert to one-hot
n_samples = len(labels)
n_classes = len(np.unique(labels))
one_hot = np.zeros((n_samples, n_classes))
one_hot[np.arange(n_samples), labels] = 1

# Result:
# [[1, 0, 0],
#  [0, 1, 0],
#  [0, 0, 1],
#  [1, 0, 0],
#  ...]

CSV format for one-hot encoded data:

class_A;class_B;class_C
1;0;0
0;1;0
0;0;1
1;0;0

Classification-Specific Considerations#

Output Normalization#

For classification, output normalization is typically not needed since the outputs are binary (0 or 1). NeurEco handles this automatically.

Interpreting Predictions#

The model outputs probability-like values for each class. To get the predicted class:

predictions = model.evaluate(x_test)
predicted_classes = np.argmax(predictions, axis=1)

Accuracy Metrics#

For classification, relevant metrics include:

  • Classification accuracy: Percentage of correctly classified samples

  • Confusion matrix: Shows which classes are confused with each other

  • Per-class accuracy: Accuracy for each individual class

Complete Parameter Reference#

Parameter

Default

Description

input_data

Required

Training inputs (array or file path)

output_data

Required

Training outputs - must be one-hot encoded

write_model_to

Required

Output path for model (.ednn)

checkpoint_address

None

Path for checkpoints

valid_percentage

33.33

Validation split percentage

validation_input_data

None

Separate validation inputs

validation_output_data

None

Separate validation outputs (one-hot)

inputs_shifting

“auto”

Input shift method

inputs_scaling

“auto”

Input scale method

inputs_normalize_per_feature

True

Per-feature input normalization

initial_beta_reg

0.1

Initial regularization coefficient (see The Regularization Coefficient)

final_learning

True

Final pruning, a last pass that disconnects unused inputs (if disconnect_inputs_if_possible is True) and a training pass that includes validation; False skips all three (see Final Learning)

disconnect_inputs_if_possible

True

Allow pruning of the links from the inputs at every structure change and, when final_learning is True, a last pass that disconnects unused inputs; False never prunes a link from an input

links_maximum_number

0

Max network connections (0=unlimited)

use_gpu

False

Enable GPU acceleration

gpu_id

0

GPU device ID

Example: Cancer Classification#

Here’s a complete example classifying cancer types from RNA expression data:

from NeurEco import NeurEcoTabular as Tabular
import numpy as np

# Load the Cancer RNA dataset — the training set ships in two parts
x_train = np.vstack([
    np.genfromtxt("x_train_0_.csv", delimiter=";", skip_header=True),
    np.genfromtxt("x_train_1_.csv", delimiter=";", skip_header=True),
])
y_train = np.vstack([
    np.genfromtxt("y_train_0_.csv", delimiter=";", skip_header=True),
    np.genfromtxt("y_train_1_.csv", delimiter=";", skip_header=True),
])
# y_train is already one-hot encoded

x_test = np.genfromtxt("x_test.csv", delimiter=";", skip_header=True)
y_test = np.genfromtxt("y_test.csv", delimiter=";", skip_header=True)

# Create and build the model
model = Tabular.Classifier()

config = Tabular.ClassifierBuildConfig(
    input_data=x_train,
    output_data=y_train,
    write_model_to="./cancer_model/cancer.ednn",
    checkpoint_address="./cancer_model/cancer.checkpoint",
    valid_percentage=33.33,
)

model.build(config)

# Evaluate on test data
predictions = model.evaluate(x_test)

# Get predicted classes
predicted_classes = np.argmax(predictions, axis=1)
actual_classes = np.argmax(y_test, axis=1)

# Calculate accuracy
accuracy = np.mean(predicted_classes == actual_classes)
print(f"Test accuracy: {accuracy * 100:.2f}%")

# Clean up
model.delete()

Next Steps#