NetDEM v1.0
Loading...
Searching...
No Matches
02_test_netsdf.cpp

This is an example of how to use the netdem library.

#include "general_net.hpp"
#include "mlpack_utils.hpp"
using namespace netdem;
using namespace std;
void TestNetSDF() {
arma::mat dataset;
bool loadedDataset = mlpack::data::Load("dataset_SDF.txt", dataset, true);
if (!loadedDataset) {
cout << "loading data erros ..." << endl;
return;
}
cout << "finished loading data ..." << endl;
arma::mat test_data = dataset;
int num_x{3}, num_y{1};
arma::mat test_x = test_data.rows(0, num_x - 1);
arma::mat test_y = test_data.row(num_x);
cout << "finished preparing testing data ..." << endl;
model.Load("ann_SDF.xml", "SDF");
cout << "finished loading ann model ..." << endl;
auto pred_y = model.Predict(test_x);
double test_accuracy = MLPackUtils::GetMAE(pred_y, test_y);
cout << "test mae: " << test_accuracy << endl;
arma::mat joined_yy = std::move(arma::join_cols(pred_y, test_y));
mlpack::data::Save("pred_vs_true_SDF.txt", joined_yy, false, true,
mlpack::data::FileType::CSVASCII);
}
A class that represents a feedforward neural network for regression.
Definition regression_net.hpp:21
void Load(std::string const &filename, std::string const &label)
Loads the neural network model from disk.
Definition regression_net.cpp:95
arma::mat Predict(const arma::mat &data_x)
Predicts with the neural network model using input data.
Definition regression_net.cpp:62
Definition bond_entry.hpp:7