UFJF - Machine Learning Toolkit  0.51.8
mltk::visualize::Visualization< T > Class Template Reference

Class for data visualization. More...

#include <Visualization.hpp>

Public Member Functions

 Visualization (bool shared_session=true, bool keep_temp_files=false)
 
 Visualization (Data< T > &sample, bool shared_session=true, bool keep_temp_files=false)
 
void setTerminal (const std::string &terminal)
 
void setSample (Data< T > &sample)
 Set sample to be visualized. More...
 
void setTitle (std::string title)
 Set plot title. More...
 
void setStyle (std::string style)
 Set plot style. (points, lines, etc.) More...
 
std::string execute_command (const std::string &cmd, bool fetch_configs=true)
 
std::string plot1DRegresion (int x=0, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y")
 Plot the data as a regression dataset with points values in the y-axis. More...
 
std::string plot1DRegresionHyperplane (int x, Solution s, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y")
 Plot the data as a regression dataset with points values in the y-axis alongside with a regressor solution. More...
 
std::string plot2D (int x=0, int y=1, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y")
 Plot the selected features in 2D. More...
 
std::string plot2D (mltk::Point< double > x, mltk::Point< double > y, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y")
 
std::string plot2DwithHyperplane (int x, int y, Solution w, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y")
 Plot the data in 2D with the hyperplane in solution generated by a classifier. More...
 
std::string plot2DRegresion (int x=0, int y=1, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y", const std::string &z_label="z")
 Plot the data as a regression dataset with points values in the z-axis. More...
 
std::string plot2DRegresionHyperplane (int x, int y, Solution s, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y", const std::string &z_label="z")
 Plot the data as a regression dataset with points values in the z-axis alongside with a regressor solution. More...
 
std::string plot3D (int x=0, int y=1, int z=2, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y", const std::string &z_label="z")
 Plot the selected features in 3D. More...
 
std::string plot3D (mltk::Point< double > x, mltk::Point< double > y, mltk::Point< double > z, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y", const std::string &z_label="z")
 
std::string plot3DwithHyperplane (int x, int y, int z, Solution w, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y", const std::string &z_label="z")
 Plot the data in 2D with separated by the hyperplane in the solution. More...
 
template<class Learner >
std::string plotDecisionSurface2D (Learner &learner, int x=0, int y=1, bool is_trained=true, size_t grid_dim=50, bool save=false, double scale=1.0, const std::string &title="", const std::string &format="svg", const std::string &x_label="x", const std::string &y_label="y")
 Plot the decision boundary of a classifier with the data points above it. More...
 

Static Public Member Functions

static void cmd (const std::string &command)
 Execute a script on gnuplot. More...
 

Detailed Description

template<typename T = double>
class mltk::visualize::Visualization< T >

Class for data visualization.

Member Function Documentation

◆ cmd()

template<typename T >
void mltk::visualize::Visualization< T >::cmd ( const std::string &  command)
static

Execute a script on gnuplot.

Parameters
commandscript to be executed.

◆ plot1DRegresion()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot1DRegresion ( int  x = 0,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y" 
)

Plot the data as a regression dataset with points values in the y-axis.

Parameters
xFeature to be used in the x-axis.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot1DRegresionHyperplane()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot1DRegresionHyperplane ( int  x,
Solution  s,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y" 
)

Plot the data as a regression dataset with points values in the y-axis alongside with a regressor solution.

Parameters
xFeature to be used in the x-axis.
sLearner solution with the hyperplane to be plotted.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot2D()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot2D ( int  x = 0,
int  y = 1,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y" 
)

Plot the selected features in 2D.

Parameters
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot2DRegresion()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot2DRegresion ( int  x = 0,
int  y = 1,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y",
const std::string &  z_label = "z" 
)

Plot the data as a regression dataset with points values in the z-axis.

Parameters
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
z_labelz-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot2DRegresionHyperplane()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot2DRegresionHyperplane ( int  x,
int  y,
Solution  s,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y",
const std::string &  z_label = "z" 
)

Plot the data as a regression dataset with points values in the z-axis alongside with a regressor solution.

Parameters
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
sLearner solution with the hyperplane to be plotted.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
z_labelz-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot2DwithHyperplane()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot2DwithHyperplane ( int  x,
int  y,
Solution  w,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y" 
)

Plot the data in 2D with the hyperplane in solution generated by a classifier.

Parameters
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
wLearner solution with the hyperplane to be plotted.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot3D()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot3D ( int  x = 0,
int  y = 1,
int  z = 2,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y",
const std::string &  z_label = "z" 
)

Plot the selected features in 3D.

Parameters
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
zFeature to be used in the z-axis.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
z_labelz-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plot3DwithHyperplane()

template<typename T >
std::string mltk::visualize::Visualization< T >::plot3DwithHyperplane ( int  x,
int  y,
int  z,
Solution  w,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y",
const std::string &  z_label = "z" 
)

Plot the data in 2D with separated by the hyperplane in the solution.

Parameters
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
zFeature to be used in the z-axis.
wLearner solution with the hyperplane to be plotted.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
z_labelz-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ plotDecisionSurface2D()

template<typename T >
template<class Learner >
std::string mltk::visualize::Visualization< T >::plotDecisionSurface2D ( Learner learner,
int  x = 0,
int  y = 1,
bool  is_trained = true,
size_t  grid_dim = 50,
bool  save = false,
double  scale = 1.0,
const std::string &  title = "",
const std::string &  format = "svg",
const std::string &  x_label = "x",
const std::string &  y_label = "y" 
)

Plot the decision boundary of a classifier with the data points above it.

Template Parameters
LearnerClassifier wrapper type.
Parameters
learnerClassifier for decision boundary generation.
xFeature to be used in the x-axis.
yFeature to be used in the y-axis.
is_trainedIf the classifier is not trained, the method will call the train method.
grid_dimDimensions for the decision boundary grid. The plot has better resolution with bigger values, but it takes more time to generate the plot.
saveIf true, save the plot to disk, otherwise it shows the plot on the screen.
scaleScale factor for all axis of the plot.
titlePlot title.
formatPlot output format if is set to save to disk.
x_labelx-axis label.
y_labely-axis label.
Returns
string containing the gnuplot script generated by the plot function.

◆ setSample()

template<typename T >
void mltk::visualize::Visualization< T >::setSample ( Data< T > &  sample)

Set sample to be visualized.

Parameters
samplesamples for visualization.
Returns
void

◆ setStyle()

template<typename T >
void mltk::visualize::Visualization< T >::setStyle ( std::string  style)

Set plot style. (points, lines, etc.)

Parameters
styleStyle to be set.
Returns
void

◆ setTitle()

template<typename T >
void mltk::visualize::Visualization< T >::setTitle ( std::string  title)

Set plot title.

Parameters
titlePlot title.
Returns
void

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