.. _tabular-building-regression: =================== Building Regression =================== This page covers building **Tabular Regression** models for predicting continuous numerical values. .. contents:: On this page :local: :depth: 2 When to Use Regression ====================== Use the Regression template when: - Your outputs are **continuous numerical values** (not categories) - You want to predict quantities like temperature, energy, cost, etc. - You're approximating a function from inputs to outputs Building a Regression Model =========================== .. tabs:: .. tab:: GUI **1. Create a new project** Launch NeurEco GUI and select **Tabular Regression**. **2. Configure settings** In the **Settings** tab: - **Training data:** Select your input and output files - **Validation percentage:** Adjust if needed (default: 33.33%) - **Normalization:** Configure input/output normalization - **GPU:** Enable if available for faster training **3. Start the build** Click the **BUILD** button. NeurEco will: - Display training progress in the **Training** panel - Save checkpoints periodically - Enable **Evaluation**, **Metrics**, and **Export** panels once the first checkpoint is saved **4. Monitor progress** Watch the training metrics. The build automatically stops when optimal accuracy is reached. .. tab:: Python API **1. Import and prepare data** .. code-block:: python from NeurEco import NeurEcoTabular as Tabular import numpy as np # Load data x_train = np.genfromtxt("x_train.csv", delimiter=";", skip_header=True) y_train = np.genfromtxt("y_train.csv", delimiter=";", skip_header=True) y_train = np.reshape(y_train, (-1, 1)) # Ensure 2D shape **2. Create the model** .. code-block:: python model = Tabular.Regressor() **3. Configure and build** .. code-block:: python config = Tabular.RegressorBuildConfig( # Required: Data input_data=x_train, output_data=y_train, # Required: Output paths write_model_to="./model/regression.ednn", checkpoint_address="./model/regression.checkpoint", # Optional: Validation valid_percentage=33.33, # Optional: Normalization inputs_shifting="min_centered", inputs_scaling="max_centered", inputs_normalize_per_feature=True, outputs_shifting="auto", outputs_scaling="auto", outputs_normalize_per_feature=False, # Optional: GPU use_gpu=False, gpu_id=0, ) model.build(config) **4. Save the model** The model is automatically saved to the path specified in ``write_model_to``. .. tab:: CLI **1. Create a configuration file** Create ``build_regression.conf``: .. code-block:: json { "neurecoRegression_build": { "DevSettings": { "disconnect_inputs_if_possible": true, "final_learning": true, "initial_beta_reg": 0.1, "valid_percentage": 33.33 }, "UserSettings": { "gpu_id": 0, "use_gpu": false }, "checkpoint_address": "./model/regression.checkpoint", "exc_filenames": ["x_train.csv"], "output_filenames": ["y_train.csv"], "input_normalization": { "normalize_per_feature": true, "scale_type": "max_centered", "shift_type": "min_centered" }, "output_normalization": { "normalize_per_feature": false, "scale_type": "auto", "shift_type": "auto" }, "write_model_to": "./model/regression.ednn" } } **2. Run the build** .. code-block:: shell neureco Regression build build_regression.conf Regression-Specific Parameters ============================== While Regression uses all the common build parameters, these settings are particularly important: **Output Normalization** For regression problems: - ``outputs_normalize_per_feature=False`` is typically recommended when outputs represent the same type of quantity - Set to ``True`` if predicting different types of outputs (e.g., temperature and pressure simultaneously) **Field Output** If your outputs represent a spatial field (e.g., values at grid points): - Set ``field_output=True`` - This tells NeurEco to treat outputs as related spatial values ``field_output`` is **not** the same as ``outputs_normalize_per_feature``: one flags the outputs as a field, the other controls how they are normalized. See :ref:`field-output-vs-normalization` for the distinction (a field output requires ``field_output=True`` **with** ``outputs_normalize_per_feature=False``). Complete Parameter Reference ============================ .. list-table:: :header-rows: 1 :widths: 30 15 55 * - Parameter - Default - Description * - ``input_data`` - Required - Training inputs (array or file path) * - ``output_data`` - Required - Training outputs (array or file path) * - ``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 * - ``test_input_data`` - None - Test set inputs * - ``test_output_data`` - None - Test set outputs * - ``inputs_shifting`` - "auto" - Input shift method * - ``inputs_scaling`` - "auto" - Input scale method * - ``inputs_normalize_per_feature`` - True - Per-feature input normalization * - ``outputs_shifting`` - "auto" - Output shift method * - ``outputs_scaling`` - "auto" - Output scale method * - ``outputs_normalize_per_feature`` - False - Per-feature output normalization * - ``initial_beta_reg`` - 0.1 - Initial regularization coefficient (see :ref:`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 :ref:`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) * - ``field_output`` - False - Flag the outputs as a single physical field (distinct from ``outputs_normalize_per_feature``; see :ref:`field-output-vs-normalization`) * - ``use_gpu`` - False - Enable GPU acceleration * - ``gpu_id`` - 0 - GPU device ID Example: Energy Consumption =========================== Here's a complete example predicting energy consumption: .. tabs:: .. tab:: Python API .. code-block:: python from NeurEco import NeurEcoTabular as Tabular import numpy as np # Load the Energy Consumption dataset x_train = np.genfromtxt("x_train.csv", delimiter=";", skip_header=True) y_train = np.genfromtxt("y_train.csv", delimiter=";", skip_header=True) y_train = np.reshape(y_train, (-1, 1)) x_test = np.genfromtxt("x_test.csv", delimiter=";", skip_header=True) y_test = np.genfromtxt("y_test.csv", delimiter=";", skip_header=True) y_test = np.reshape(y_test, (-1, 1)) # Create and build the model model = Tabular.Regressor() config = Tabular.RegressorBuildConfig( input_data=x_train, output_data=y_train, write_model_to="./energy_model/energy.ednn", checkpoint_address="./energy_model/energy.checkpoint", valid_percentage=33.33, ) model.build(config) # Evaluate on test data predictions = model.evaluate(x_test) error = model.compute_error(predictions, y_test) print(f"Test error: {error}") # Clean up model.delete() Next Steps ========== - :ref:`Evaluate your model ` - :ref:`Export for deployment ` - See :ref:`advanced features ` for sensitivity analysis and more