src/esn.cpp
ArrayBO EchoBay::esn_compute(YAML::Node confParams, Reservoir &ESN, const DataStorage &store, 
                        const std::string &problemType, const std::string &fitnessRule, 
                        const int blockStep, Eigen::Ref<MatrixBO> Wout, 
                        const std::string &outputFolder, const bool saveflag, const int guesses)
{
    Comparator fitter(problemType, fitnessRule);
    ArrayI8 evalSampling = store.get_sampleArray(EchoBay::Valid);
    fitter.set_targetLabel(store.get_data(EchoBay::Valid, EchoBay::selLabel), evalSampling);

    // Compute Prediction
    MatrixBO prediction = readout_predict(ESN, store, Wout, blockStep);

    // Calculate fitness
    // Resize output
    fitter.set_label_size(prediction.rows(), prediction.cols());
    // Get fitness
    floatBO fitness = fitter.get_fitness(prediction);
    MatrixBO outputLabel;

    outputLabel = fitter.get_outputlabel();

    // Consider memory penalization
    floatBO memory = ESN.return_net_dimension(confParams);
    ArrayBO multiFitness(2);

    multiFitness(0) = fitness;
    multiFitness(1) = (memory);
    std::cout << "Computation ended \n";

    if (saveflag)
    {
        std::string nameOut;
        nameOut = "/outputLabel_" + std::to_string(guesses) + ".csv";
        write_matrix<MatrixBO>(outputFolder + std::string(nameOut), prediction);

        // TODO move this to compute prediction
        //nameOut = "/final_state_" + std::to_string(guesses) + ".dat";
        //write_array<ArrayBO>(outputFolder + std::string(nameOut), valState.row(valPoints - 1));
    }
    return multiFitness;
}
/**
 * @brief Compute the output of a loaded Echo State Network
 * 
 * @param confParams YAML Node containing hyper-parameters at high level
 * @param ESN Reservoir Object
 * @param store Datastorage container with the data to be processed
 * @param problemType Classification, Regression or MemoryCapacity
 * @param fitnessRule Fitness function dependent from the chosen problemType
 * @param blockStep Dimension of the blocks used in Readout prediction
 * @param Wout Readout matrix
 * @param outputFolder Path to the folder where the output will be saved
 * @param saveflag If true, save the output on a file
 * @param guesses Number of guesses to be evaluated (used for output naming)
 * @return ArrayBO Return fitness value to the Bayesian Optimizer
 */
@brief Compute the output of a loaded Echo State Network


@brief Compute the output of a loaded Echo State Network
ArrayBO EchoBay::esn_compute(YAML::Node confParams, Reservoir &ESN, const DataStorage &store, 
                        const std::string &problemType, const std::string &fitnessRule, 
                        const int blockStep, Eigen::Ref<MatrixBO> Wout, 
                        const std::string &outputFolder, const bool saveflag, const int guesses)
{
    Comparator fitter(problemType, fitnessRule);
    ArrayI8 evalSampling = store.get_sampleArray(EchoBay::Valid);
    fitter.set_targetLabel(store.get_data(EchoBay::Valid, EchoBay::selLabel), evalSampling);
    MatrixBO prediction = readout_predict(ESN, store, Wout, blockStep);
    fitter.set_label_size(prediction.rows(), prediction.cols());
    floatBO fitness = fitter.get_fitness(prediction);
    MatrixBO outputLabel;
    outputLabel = fitter.get_outputlabel();
    floatBO memory = ESN.return_net_dimension(confParams);
    ArrayBO multiFitness(2);
    multiFitness(0) = fitness;
    multiFitness(1) = (memory);
    std::cout << "Computation ended \n";
    if (saveflag)
    {
        std::string nameOut;
        nameOut = "/outputLabel_" + std::to_string(guesses) + ".csv";
        write_matrix<MatrixBO>(outputFolder + std::string(nameOut), prediction);
    }
    return multiFitness;
}
ArrayBO EchoBay :: esn_compute ( YAML :: Node confParams , Reservoir & ESN , const DataStorage & store , const std :: string & problemType , const std :: string & fitnessRule , const int blockStep , Eigen :: Ref < MatrixBO > Wout , const std :: string & outputFolder , const bool saveflag , const int guesses ) { Comparator fitter ( problemType , fitnessRule ) ; ArrayI8 evalSampling = store . get_sampleArray ( EchoBay :: Valid ) ; fitter . set_targetLabel ( store . get_data ( EchoBay :: Valid , EchoBay :: selLabel ) , evalSampling ) ; MatrixBO prediction = readout_predict ( ESN , store , Wout , blockStep ) ; fitter . set_label_size ( prediction . rows ( ) , prediction . cols ( ) ) ; floatBO fitness = fitter . get_fitness ( prediction ) ; MatrixBO outputLabel ; outputLabel = fitter . get_outputlabel ( ) ; floatBO memory = ESN . return_net_dimension ( confParams ) ; ArrayBO multiFitness ( 2 ) ; multiFitness ( 0 ) = fitness ; multiFitness ( 1 ) = ( memory ) ; std :: cout << " \n " ; if ( saveflag ) { std :: string nameOut ; nameOut = " " + std :: to_string ( guesses ) + " " ; write_matrix < MatrixBO > ( outputFolder + std :: string ( nameOut ) , prediction ) ; } return multiFitness ; }
@brief Compute the output of a loaded Echo State Network
@brief Compute the output of a loaded Echo State Network
// Compute Prediction // Calculate fitness // Resize output // Get fitness // Consider memory penalization // TODO move this to compute prediction //nameOut = "/final_state_" + std::to_string(guesses) + ".dat"; //write_array<ArrayBO>(outputFolder + std::string(nameOut), valState.row(valPoints - 1));