SG++-Doxygen-Documentation
Loading...
Searching...
No Matches
sgpp::datadriven::VisualizerDensityEstimation Class Reference

#include <VisualizerDensityEstimation.hpp>

Inheritance diagram for sgpp::datadriven::VisualizerDensityEstimation:
sgpp::datadriven::Visualizer sgpp::datadriven::VisualizerClassification

Public Member Functions

void runVisualization (ModelFittingBase &model, DataSource &dataSource, size_t fold, size_t batch) override
 Method to run the visualization process for a given batch and fold.
 
 VisualizerDensityEstimation ()=default
 
 VisualizerDensityEstimation (VisualizerConfiguration config)
 Constructor given a configuration.
 
 ~VisualizerDensityEstimation () override=default
 Default destructor.
 
- Public Member Functions inherited from sgpp::datadriven::Visualizer
const VisualizerConfigurationgetVisualizerConfiguration () const
 Get the configuration of the visualizer object.
 
 Visualizer ()
 
virtual ~Visualizer ()=default
 Virtual destructor.
 

Protected Member Functions

void getHeatmap (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which starts the heatmap generation for Density Estimation Models.
 
void getHeatmap2D (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which generates the heatmap of models of 2 dimensions.
 
void getHeatmap3D (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which generates the heatmap of models of 3 dimensions.
 
void getHeatmapMore4D (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which generates the heatmap of models of 4 or more dimensions.
 
void getLinearCuts (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which starts the linear cut generation for Density Estimation Models.
 
void getLinearCuts1D (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which generates the linear cuts graphs for models of 1 dimension.
 
void getLinearCuts2D (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which generates the linear cuts graphs for models of 2 dimensions.
 
void getLinearCutsMore3D (ModelFittingBase &model, std::string currentDirectory, DataMatrix &matrix)
 Method which generates the linear cuts graphs for models of 3 or more dimensions.
 
void initializeMatrices (ModelFittingBase &model, DataMatrix &cutMatrix, DataMatrix &heatMapMatrix)
 Method which builds the matrices used to generate the cuts and the heatmaps.
 
void storeCutJson (DataMatrix &matrix, std::string filepath)
 Method to generate and store in json format for the plotly library the output of the linear cuts for models of 1 dimension.
 
void storeCutJson (DataMatrix &matrix, std::vector< size_t > indexes, size_t &varDim, std::string filepath)
 Method to generate and store in json format for the plotly library the output of the linear cuts for models of 2 or more dimensions.
 
void storeGrid (ModelFittingBase &model, std::string currentDirectory)
 Method which stores the coordinates of the grid points of a Density Estimation model.
 
void storeHeatmapJson (DataMatrix &matrix, ModelFittingBase &model, std::string filepath)
 Method to generate and store in json format for the plotly library the output of the heatmaps for models of 2 dimensions.
 
void storeHeatmapJson (DataMatrix &matrix, ModelFittingBase &model, std::vector< size_t > indexes, size_t &varDim1, size_t &varDim2, std::string filepath)
 Method to generate and store in json format for the plotly library the output of the hetamaps for models of 3 or more dimensions.
 
void storeTsneJson (DataMatrix &matrix, ModelFittingBase &model, std::string currentDirectory)
 Method to generate and store in json format for the plotly library the output of the tsne algorithm.
 
void swapColumns (DataMatrix &matrix, size_t col1, size_t col2)
 Method to swap to columns of a matrix.
 
void translateColumns (DataMatrix &matrix, size_t maxColumns)
 Method which shifts one position the columns of a matrix from left to right in a circular fashion until the column given by the parameters maxColumns.
 
void translateColumnsLeft (DataMatrix &matrix, std::vector< size_t > indexes)
 Method which shifts the columns given by the vector indexes of a matrix from right to left in a circular fashion.
 
void translateColumnsRight (DataMatrix &matrix, std::vector< size_t > indexes)
 Method which shifts the columns given by the vector indexes of a matrix from left to right in a circular fashion.
 
void updateIndexesCuts (std::vector< size_t > &columnIndexes, DataMatrix &matrix)
 Method to update the columns indexes to be shifted when generating the linear cuts.
 
void updateIndexesHeatmap (std::vector< size_t > &columnIndexes, DataMatrix &matrix)
 Method to update the columns indexes to be shifted when generating the heatmap.
 
- Protected Member Functions inherited from sgpp::datadriven::Visualizer
void createFolder (std::string folder_path)
 Method to create a folder based on the operating system of the user.
 

Additional Inherited Members

- Protected Attributes inherited from sgpp::datadriven::Visualizer
VisualizerConfiguration config
 Configuration object for the fitter.
 
std::string currentDirectory
 Variable to store the current folder in which the visualizer is working on.
 
DataMatrix originalData
 Matrix to store the data from the datasource.
 
size_t resolution
 Resolution used in the graphs.
 
DataMatrix tsneCompressedData
 Matrix to store the data provided by the tsne algorithm.
 

Constructor & Destructor Documentation

◆ VisualizerDensityEstimation() [1/2]

sgpp::datadriven::VisualizerDensityEstimation::VisualizerDensityEstimation ( )
default

◆ VisualizerDensityEstimation() [2/2]

sgpp::datadriven::VisualizerDensityEstimation::VisualizerDensityEstimation ( VisualizerConfiguration  config)
explicit

Constructor given a configuration.

Parameters
configThe VisualizerConfiguration object which contains the configuration to run the visualization module

References sgpp::datadriven::Visualizer::config.

◆ ~VisualizerDensityEstimation()

sgpp::datadriven::VisualizerDensityEstimation::~VisualizerDensityEstimation ( )
overridedefault

Default destructor.

Member Function Documentation

◆ getHeatmap()

void sgpp::datadriven::VisualizerDensityEstimation::getHeatmap ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

Method which starts the heatmap generation for Density Estimation Models.

Parameters
modelThe model used to evaluate the heatmap
currentDirectoryThe current directory to store the heatmap results
matrixThe matrix containing the points to evaluate the heatmap

References sgpp::datadriven::Visualizer::createFolder(), sgpp::datadriven::Visualizer::currentDirectory, sgpp::base::GeneralGridConfiguration::dim_, sgpp::datadriven::ModelFittingBase::getFitterConfiguration(), sgpp::datadriven::FitterConfiguration::getGridConfig(), getHeatmap2D(), getHeatmap3D(), and getHeatmapMore4D().

Referenced by sgpp::datadriven::VisualizerClassification::runVisualization(), and runVisualization().

◆ getHeatmap2D()

void sgpp::datadriven::VisualizerDensityEstimation::getHeatmap2D ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

Method which generates the heatmap of models of 2 dimensions.

Parameters
modelThe model used to evaluate the heatmap
currentDirectoryThe current directory to store the heatmap results
matrixThe matrix containing the points to evaluate the heatmap

References sgpp::base::DataMatrix::appendCol(), sgpp::datadriven::Visualizer::config, sgpp::datadriven::CSV, sgpp::datadriven::Visualizer::currentDirectory, sgpp::datadriven::ModelFittingBase::evaluate(), sgpp::datadriven::VisualizerConfiguration::getGeneralConfig(), sgpp::base::DataMatrix::getNrows(), sgpp::datadriven::json, storeHeatmapJson(), sgpp::datadriven::VisualizationGeneralConfig::targetFileType_, and sgpp::datadriven::CSVTools::writeMatrixToCSVFile().

Referenced by getHeatmap().

◆ getHeatmap3D()

void sgpp::datadriven::VisualizerDensityEstimation::getHeatmap3D ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

◆ getHeatmapMore4D()

void sgpp::datadriven::VisualizerDensityEstimation::getHeatmapMore4D ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

◆ getLinearCuts()

void sgpp::datadriven::VisualizerDensityEstimation::getLinearCuts ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

Method which starts the linear cut generation for Density Estimation Models.

Parameters
modelThe model used to evaluate the linear cuts
currentDirectoryThe current directory to store the linear cuts results
matrixThe matrix containing the points to evaluate the cuts

References sgpp::datadriven::Visualizer::createFolder(), sgpp::datadriven::Visualizer::currentDirectory, sgpp::base::GeneralGridConfiguration::dim_, sgpp::datadriven::ModelFittingBase::getFitterConfiguration(), sgpp::datadriven::FitterConfiguration::getGridConfig(), getLinearCuts1D(), getLinearCuts2D(), and getLinearCutsMore3D().

Referenced by sgpp::datadriven::VisualizerClassification::runVisualization(), and runVisualization().

◆ getLinearCuts1D()

void sgpp::datadriven::VisualizerDensityEstimation::getLinearCuts1D ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

Method which generates the linear cuts graphs for models of 1 dimension.

Parameters
modelthe model used to evaluate the linear cuts
currentDirectoryThe current directory to store the linear cuts results
matrixThe matrix containing the points to evaluate the cuts

References sgpp::base::DataMatrix::appendCol(), sgpp::datadriven::Visualizer::config, sgpp::datadriven::CSV, sgpp::datadriven::Visualizer::currentDirectory, sgpp::datadriven::ModelFittingBase::evaluate(), sgpp::datadriven::VisualizerConfiguration::getGeneralConfig(), sgpp::base::DataMatrix::getNrows(), sgpp::datadriven::json, storeCutJson(), sgpp::datadriven::VisualizationGeneralConfig::targetFileType_, and sgpp::datadriven::CSVTools::writeMatrixToCSVFile().

Referenced by getLinearCuts().

◆ getLinearCuts2D()

void sgpp::datadriven::VisualizerDensityEstimation::getLinearCuts2D ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

◆ getLinearCutsMore3D()

void sgpp::datadriven::VisualizerDensityEstimation::getLinearCutsMore3D ( ModelFittingBase model,
std::string  currentDirectory,
DataMatrix matrix 
)
protected

◆ initializeMatrices()

void sgpp::datadriven::VisualizerDensityEstimation::initializeMatrices ( ModelFittingBase model,
DataMatrix cutMatrix,
DataMatrix heatMapMatrix 
)
protected

Method which builds the matrices used to generate the cuts and the heatmaps.

Parameters
modelThe model used to evaluate the linear cuts and the heatmaps
cutMatrixMatrix to be initialized which will be used to evaluate the linear cuts
heatMapMatrixMatrix to be initialized which will be used to evaluate the heatmaps

References sgpp::base::DataMatrix::appendRow(), sgpp::datadriven::ModelFittingBase::getDataset(), sgpp::datadriven::Dataset::getDimension(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::resize(), sgpp::datadriven::Visualizer::resolution, and sgpp::base::DataVector::set().

Referenced by sgpp::datadriven::VisualizerClassification::runVisualization(), and runVisualization().

◆ runVisualization()

void sgpp::datadriven::VisualizerDensityEstimation::runVisualization ( ModelFittingBase model,
DataSource dataSource,
size_t  fold,
size_t  batch 
)
overridevirtual

◆ storeCutJson() [1/2]

void sgpp::datadriven::VisualizerDensityEstimation::storeCutJson ( DataMatrix matrix,
std::string  filepath 
)
protected

Method to generate and store in json format for the plotly library the output of the linear cuts for models of 1 dimension.

Parameters
matrixMatrix with the content to be stored
filepathThe current directory to store the json file

References json::DictNode::addDictAttr(), json::Node::addDictValue(), json::DictNode::addIDAttr(), json::DictNode::addListAttr(), sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNrows(), json::JSON::serialize(), and sgpp::base::DataVector::toString().

◆ storeCutJson() [2/2]

void sgpp::datadriven::VisualizerDensityEstimation::storeCutJson ( DataMatrix matrix,
std::vector< size_t >  indexes,
size_t &  varDim,
std::string  filepath 
)
protected

Method to generate and store in json format for the plotly library the output of the linear cuts for models of 2 or more dimensions.

Parameters
matrixMatrix with the content to be stored
indexesVectors containing the dimensions used when generating these cuts
varDimTHe dimension number varying and whose evaluation is shown in the model
filepathThe current directory to store the json file

References json::DictNode::addDictAttr(), json::Node::addDictValue(), json::DictNode::addIDAttr(), json::Node::addIdValue(), json::DictNode::addListAttr(), sgpp::base::DataMatrix::copyFrom(), sgpp::base::DataVector::get(), sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), sgpp::base::DataMatrix::resizeToSubMatrix(), json::JSON::serialize(), and sgpp::base::DataVector::toString().

Referenced by getLinearCuts1D(), getLinearCuts2D(), and getLinearCutsMore3D().

◆ storeGrid()

void sgpp::datadriven::VisualizerDensityEstimation::storeGrid ( ModelFittingBase model,
std::string  currentDirectory 
)
protected

Method which stores the coordinates of the grid points of a Density Estimation model.

Parameters
modelThe model from where the grid is obtained
currentDirectoryThe current directory to store the grid data

References sgpp::base::Grid::clone(), sgpp::datadriven::Visualizer::currentDirectory, sgpp::datadriven::ModelFittingBaseSingleGrid::getGrid(), grid(), and sgpp::datadriven::CSVTools::writeMatrixToCSVFile().

Referenced by runVisualization().

◆ storeHeatmapJson() [1/2]

void sgpp::datadriven::VisualizerDensityEstimation::storeHeatmapJson ( DataMatrix matrix,
ModelFittingBase model,
std::string  filepath 
)
protected

Method to generate and store in json format for the plotly library the output of the heatmaps for models of 2 dimensions.

Parameters
matrixMatrix with the content to be stored
modelThe model used when evaluating the heatmaps
filepathThe current directory to store the json file

References json::DictNode::addDictAttr(), json::Node::addDictValue(), json::DictNode::addIDAttr(), json::DictNode::addListAttr(), sgpp::base::Grid::clone(), sgpp::base::DataMatrix::getColumn(), sgpp::datadriven::ModelFittingBaseSingleGrid::getGrid(), sgpp::base::DataMatrix::getNrows(), grid(), sgpp::base::DataMatrix::max(), sgpp::base::DataMatrix::min(), json::JSON::serialize(), and sgpp::base::DataVector::toString().

◆ storeHeatmapJson() [2/2]

void sgpp::datadriven::VisualizerDensityEstimation::storeHeatmapJson ( DataMatrix matrix,
ModelFittingBase model,
std::vector< size_t >  indexes,
size_t &  varDim1,
size_t &  varDim2,
std::string  filepath 
)
protected

Method to generate and store in json format for the plotly library the output of the hetamaps for models of 3 or more dimensions.

Parameters
matrixMatrix with the content to be stored
modelThe model used when evaluating the heatmaps
indexesVectors containing the dimensions used when generating these heatmaps
varDim1The first dimension number varying and whose evaluation is shown in the model
varDim2The second dimension number varying and whose evaluation is shown in the model
filepathThe current directory to store the json file

References json::DictNode::addDictAttr(), json::Node::addDictValue(), json::DictNode::addIDAttr(), json::Node::addIdValue(), json::DictNode::addListAttr(), sgpp::base::DataMatrix::appendRow(), sgpp::base::Grid::clone(), sgpp::base::DataMatrix::copyFrom(), sgpp::base::DataVector::get(), sgpp::base::DataMatrix::getColumn(), sgpp::datadriven::ModelFittingBaseSingleGrid::getGrid(), sgpp::base::DataMatrix::getNcols(), sgpp::base::DataMatrix::getNrows(), sgpp::base::DataMatrix::getRow(), grid(), sgpp::base::DataMatrix::max(), sgpp::base::DataMatrix::min(), sgpp::base::DataMatrix::resizeToSubMatrix(), json::JSON::serialize(), and sgpp::base::DataVector::toString().

Referenced by getHeatmap2D(), getHeatmap3D(), and getHeatmapMore4D().

◆ storeTsneJson()

void sgpp::datadriven::VisualizerDensityEstimation::storeTsneJson ( DataMatrix matrix,
ModelFittingBase model,
std::string  currentDirectory 
)
protected

Method to generate and store in json format for the plotly library the output of the tsne algorithm.

Parameters
matrixMatrix with the content to be stored
modelModel used in the evaluation
currentDirectoryThe current directory to store the json file

References json::DictNode::addDictAttr(), json::Node::addDictValue(), json::DictNode::addIDAttr(), json::DictNode::addListAttr(), sgpp::datadriven::Visualizer::currentDirectory, sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNrows(), json::JSON::serialize(), and sgpp::base::DataVector::toString().

◆ swapColumns()

void sgpp::datadriven::VisualizerDensityEstimation::swapColumns ( DataMatrix matrix,
size_t  col1,
size_t  col2 
)
protected

Method to swap to columns of a matrix.

Parameters
matrixThe matrix whose columns are to be swaped
col1The column identifier to be swaped with the column identified by col2
col2The colum identifier to be swaped with the column identified by col1

References sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNrows(), and sgpp::base::DataMatrix::setColumn().

Referenced by updateIndexesCuts(), and updateIndexesHeatmap().

◆ translateColumns()

void sgpp::datadriven::VisualizerDensityEstimation::translateColumns ( DataMatrix matrix,
size_t  maxColumns 
)
protected

Method which shifts one position the columns of a matrix from left to right in a circular fashion until the column given by the parameters maxColumns.

Parameters
matrixThe matrix to be shifted
maxColumnsThe max number of columns used when shifting

References sgpp::base::DataMatrix::copyFrom(), sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNrows(), and sgpp::base::DataMatrix::setColumn().

Referenced by getHeatmap3D(), sgpp::datadriven::VisualizerClassification::getHeatmap3DClassification(), and getLinearCuts2D().

◆ translateColumnsLeft()

void sgpp::datadriven::VisualizerDensityEstimation::translateColumnsLeft ( DataMatrix matrix,
std::vector< size_t >  indexes 
)
protected

Method which shifts the columns given by the vector indexes of a matrix from right to left in a circular fashion.

If indexes are <1,3,6> Then column 1 will be shifted to 6, 6 to 3 and 1 to 6.

Parameters
matrixThe matrix to be shifted
indexesVector containing the columns to shift

References sgpp::base::DataMatrix::copyFrom(), sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNrows(), and sgpp::base::DataMatrix::setColumn().

Referenced by getHeatmapMore4D(), and sgpp::datadriven::VisualizerClassification::getHeatmapMore4DClassification().

◆ translateColumnsRight()

void sgpp::datadriven::VisualizerDensityEstimation::translateColumnsRight ( DataMatrix matrix,
std::vector< size_t >  indexes 
)
protected

Method which shifts the columns given by the vector indexes of a matrix from left to right in a circular fashion.

If indexes are <1,3,6> Then column 1 will be shifted to 3, 3 to 6 and 6 to 1.

Parameters
matrixThe matrix to be shifted
indexesVector containing the columns to shift

References sgpp::base::DataMatrix::copyFrom(), sgpp::base::DataMatrix::getColumn(), sgpp::base::DataMatrix::getNrows(), and sgpp::base::DataMatrix::setColumn().

Referenced by getHeatmapMore4D(), sgpp::datadriven::VisualizerClassification::getHeatmapMore4DClassification(), and getLinearCutsMore3D().

◆ updateIndexesCuts()

void sgpp::datadriven::VisualizerDensityEstimation::updateIndexesCuts ( std::vector< size_t > &  columnIndexes,
DataMatrix matrix 
)
protected

Method to update the columns indexes to be shifted when generating the linear cuts.

Parameters
columnIndexesVector to update
matrixThe matrix whose columns are being shifted

References sgpp::base::DataMatrix::getNcols(), and swapColumns().

Referenced by getLinearCutsMore3D().

◆ updateIndexesHeatmap()

void sgpp::datadriven::VisualizerDensityEstimation::updateIndexesHeatmap ( std::vector< size_t > &  columnIndexes,
DataMatrix matrix 
)
protected

Method to update the columns indexes to be shifted when generating the heatmap.

Parameters
columnIndexesVector to update
matrixThe matrix whose columns are being shifted

References sgpp::base::DataMatrix::getNcols(), and swapColumns().

Referenced by getHeatmapMore4D(), and sgpp::datadriven::VisualizerClassification::getHeatmapMore4DClassification().


The documentation for this class was generated from the following files: