shark_globals

Several mathematical, linear-algebra, or other functions within Shark are not part of any particular class. They are collected here in the doxygen group "shark_globals". More...

Namespaces

 shark
 AbstractMultiObjectiveOptimizer.
 

Typedefs

typedef detail::SharedContainer< Type > shark::Data< Type >::Container
 
typedef batch_type & shark::Data< Type >::batch_reference
 
typedef batch_type const & shark::Data< Type >::const_batch_reference
 
typedef Batch< element_type >::reference shark::Data< Type >::element_reference
 
typedef Batch< element_type >::const_reference shark::Data< Type >::const_element_reference
 
typedef std::vector< std::size_t > shark::Data< Type >::IndexSet
 
typedef boost::iterator_range< detail::DataElementIterator< Data< Type > > > shark::Data< Type >::element_range
 
typedef boost::iterator_range< detail::DataElementIterator< Data< Type > const > > shark::Data< Type >::const_element_range
 
typedef detail::BatchRange< Data< Type > > shark::Data< Type >::batch_range
 
typedef detail::BatchRange< Data< Type > const > shark::Data< Type >::const_batch_range
 
typedef element_type shark::UnlabeledData< InputT >::InputType
 
typedef detail::SharedContainer< InputT > shark::UnlabeledData< InputT >::InputContainer
 
typedef InputT shark::LabeledData< InputT, LabelT >::InputType
 
typedef LabelT shark::LabeledData< InputT, LabelT >::LabelType
 
typedef UnlabeledData< InputT > shark::LabeledData< InputT, LabelT >::InputContainer
 
typedef Data< LabelT > shark::LabeledData< InputT, LabelT >::LabelContainer
 
typedef InputContainer::IndexSet shark::LabeledData< InputT, LabelT >::IndexSet
 
typedef InputLabelBatch< typename Batch< InputType >::type &, typename Batch< LabelType >::type &> shark::LabeledData< InputT, LabelT >::batch_reference
 
typedef InputLabelBatch< typename Batch< InputType >::type const &, typename Batch< LabelType >::type const &> shark::LabeledData< InputT, LabelT >::const_batch_reference
 
typedef batch_reference::reference shark::LabeledData< InputT, LabelT >::element_reference
 
typedef const_batch_reference::const_reference shark::LabeledData< InputT, LabelT >::const_element_reference
 
typedef boost::iterator_range< detail::DataElementIterator< LabeledData< InputType, LabelType > > > shark::LabeledData< InputT, LabelT >::element_range
 
typedef boost::iterator_range< detail::DataElementIterator< LabeledData< InputType, LabelType > const > > shark::LabeledData< InputT, LabelT >::const_element_range
 
typedef detail::BatchRange< LabeledData< InputType, LabelType > > shark::LabeledData< InputT, LabelT >::batch_range
 
typedef detail::BatchRange< LabeledData< InputType, LabelType > const > shark::LabeledData< InputT, LabelT >::const_batch_range
 

Functions

template<class T >
shark::maxExpInput ()
 Maximum allowed input value for exp. More...
 
template<class T >
shark::minExpInput ()
 Minimum value for exp(x) allowed so that it is not 0. More...
 
template<class T >
boost::enable_if< std::is_arithmetic< T >, T >::type shark::sqr (const T &x)
 Calculates x^2. More...
 
template<class T >
shark::cube (const T &x)
 Calculates x^3. More...
 
template<class T >
boost::enable_if< std::is_arithmetic< T >, T >::type shark::sigmoid (T x)
 Logistic function/logistic function. More...
 
template<class T >
shark::safeExp (T x)
 Thresholded exp function, over- and underflow safe. More...
 
template<class T >
shark::safeLog (T x)
 Thresholded log function, over- and underflow safe. More...
 
template<class T >
boost::enable_if< std::is_arithmetic< T >, T >::type shark::softPlus (T x)
 Numerically stable version of the function log(1+exp(x)). More...
 
double shark::softPlus (double x)
 Numerically stable version of the function log(1+exp(x)). calculated with float precision to save some time. More...
 
template<class T >
shark::copySign (T x, T y)
 
 shark::Data< Type >::BOOST_STATIC_CONSTANT (std::size_t, DefaultBatchSize=256)
 Defines the default batch size of the Container. More...
 
template<class T >
bool shark::Data< Type >::operator== (const Data< T > &rhs)
 Two containers compare equal if they share the same data. More...
 
template<class T >
bool shark::Data< Type >::operator!= (const Data< T > &rhs)
 Two containers compare unequal if they don't share the same data. More...
 
const_element_range shark::Data< Type >::elements () const
 Returns the range of elements. More...
 
element_range shark::Data< Type >::elements ()
 Returns therange of elements. More...
 
const_batch_range shark::Data< Type >::batches () const
 Returns the range of batches. More...
 
batch_range shark::Data< Type >::batches ()
 Returns the range of batches. More...
 
std::size_t shark::Data< Type >::numberOfBatches () const
 Returns the number of batches of the set. More...
 
std::size_t shark::Data< Type >::numberOfElements () const
 Returns the total number of elements. More...
 
Shape const & shark::Data< Type >::shape () const
 Returns the shape of the elements in the dataset. More...
 
Shapeshark::Data< Type >::shape ()
 Returns the shape of the elements in the dataset. More...
 
bool shark::Data< Type >::empty () const
 Check whether the set is empty. More...
 
element_reference shark::Data< Type >::element (std::size_t i)
 
const_element_reference shark::Data< Type >::element (std::size_t i) const
 
batch_reference shark::Data< Type >::batch (std::size_t i)
 
const_batch_reference shark::Data< Type >::batch (std::size_t i) const
 
 shark::Data< Type >::Data ()
 Constructor which constructs an empty set. More...
 
 shark::Data< Type >::Data (std::size_t numBatches)
 Construct a dataset with empty batches. More...
 
 shark::Data< Type >::Data (std::size_t size, element_type const &element, std::size_t batchSize=DefaultBatchSize)
 Construction with size and a single element. More...
 
void shark::Data< Type >::read (InArchive &archive)
 Read the component from the supplied archive. More...
 
void shark::Data< Type >::write (OutArchive &archive) const
 Write the component to the supplied archive. More...
 
virtual void shark::Data< Type >::makeIndependent ()
 This method makes the vector independent of all siblings and parents. More...
 
void shark::Data< Type >::splitBatch (std::size_t batch, std::size_t elementIndex)
 
Data shark::Data< Type >::splice (std::size_t batch)
 Splits the container into two independent parts. The front part remains in the container, the back part is returned. More...
 
void shark::Data< Type >::append (Data const &other)
 Appends the contents of another data object to the end. More...
 
void shark::Data< Type >::push_back (const_batch_reference batch)
 
template<class Range >
void shark::Data< Type >::repartition (Range const &batchSizes)
 Reorders the batch structure in the container to that indicated by the batchSizes vector. More...
 
std::vector< std::size_t > shark::Data< Type >::getPartitioning () const
 Creates a vector with the batch sizes of every batch. More...
 
void shark::Data< Type >::indexedSubset (IndexSet const &indices, Data &subset, Data &complement) const
 Fill in the subset defined by the list of indices as well as its complement. More...
 
Data shark::Data< Type >::indexedSubset (IndexSet const &indices) const
 
 shark::UnlabeledData< InputT >::UnlabeledData ()
 Constructor. More...
 
 shark::UnlabeledData< InputT >::UnlabeledData (Data< InputT > const &points)
 Construction from data. More...
 
 shark::UnlabeledData< InputT >::UnlabeledData (std::size_t size, element_type const &element, std::size_t batchSize=base_type::DefaultBatchSize)
 Construction with size and a single element. More...
 
 shark::UnlabeledData< InputT >::UnlabeledData (std::size_t numBatches)
 Create an empty set with just the correct number of batches. More...
 
 shark::UnlabeledData< InputT >::UnlabeledData (UnlabeledData const &container, std::vector< std::size_t > batchSizes)
 Construct a dataset with different batch sizes. it is a copy of the other dataset. More...
 
UnlabeledData shark::UnlabeledData< InputT >::operator= (Data< InputT > const &data)
 we allow assignment from Data. More...
 
UnlabeledDatashark::UnlabeledData< InputT >::inputs ()
 Access to the base_type class as "inputs". More...
 
UnlabeledData const & shark::UnlabeledData< InputT >::inputs () const
 Access to the base_type class as "inputs". More...
 
UnlabeledData shark::UnlabeledData< InputT >::splice (std::size_t batch)
 Splits the container in two independent parts. The left part remains in the container, the right is stored as return type. More...
 
virtual void shark::UnlabeledData< InputT >::shuffle ()
 shuffles all elements in the entire dataset (that is, also across the batches) More...
 
const_element_range shark::LabeledData< InputT, LabelT >::elements () const
 Returns the range of elements. More...
 
element_range shark::LabeledData< InputT, LabelT >::elements ()
 Returns therange of elements. More...
 
const_batch_range shark::LabeledData< InputT, LabelT >::batches () const
 Returns the range of batches. More...
 
batch_range shark::LabeledData< InputT, LabelT >::batches ()
 Returns the range of batches. More...
 
std::size_t shark::LabeledData< InputT, LabelT >::numberOfBatches () const
 Returns the number of batches of the set. More...
 
std::size_t shark::LabeledData< InputT, LabelT >::numberOfElements () const
 Returns the total number of elements. More...
 
bool shark::LabeledData< InputT, LabelT >::empty () const
 Check whether the set is empty. More...
 
InputContainer const & shark::LabeledData< InputT, LabelT >::inputs () const
 Access to inputs as a separate container. More...
 
InputContainershark::LabeledData< InputT, LabelT >::inputs ()
 Access to inputs as a separate container. More...
 
LabelContainer const & shark::LabeledData< InputT, LabelT >::labels () const
 Access to labels as a separate container. More...
 
LabelContainershark::LabeledData< InputT, LabelT >::labels ()
 Access to labels as a separate container. More...
 
 shark::LabeledData< InputT, LabelT >::LabeledData ()
 Empty data set. More...
 
 shark::LabeledData< InputT, LabelT >::LabeledData (std::size_t numBatches)
 Create an empty set with just the correct number of batches. More...
 
 shark::LabeledData< InputT, LabelT >::LabeledData (std::size_t size, element_type const &element, std::size_t batchSize=DefaultBatchSize)
 
 shark::LabeledData< InputT, LabelT >::LabeledData (Data< InputType > const &inputs, Data< LabelType > const &labels)
 Construction from data. More...
 
element_reference shark::LabeledData< InputT, LabelT >::element (std::size_t i)
 
const_element_reference shark::LabeledData< InputT, LabelT >::element (std::size_t i) const
 
batch_reference shark::LabeledData< InputT, LabelT >::batch (std::size_t i)
 
const_batch_reference shark::LabeledData< InputT, LabelT >::batch (std::size_t i) const
 
Shape const & shark::LabeledData< InputT, LabelT >::inputShape () const
 Returns the Shape of the inputs. More...
 
Shapeshark::LabeledData< InputT, LabelT >::inputShape ()
 Returns the Shape of the inputs. More...
 
Shape const & shark::LabeledData< InputT, LabelT >::labelShape () const
 Returns the Shape of the labels. More...
 
Shapeshark::LabeledData< InputT, LabelT >::labelShape ()
 Returns the Shape of the labels. More...
 
void shark::LabeledData< InputT, LabelT >::read (InArchive &archive)
 from ISerializable More...
 
void shark::LabeledData< InputT, LabelT >::write (OutArchive &archive) const
 from ISerializable More...
 
virtual void shark::LabeledData< InputT, LabelT >::makeIndependent ()
 This method makes the vector independent of all siblings and parents. More...
 
virtual void shark::LabeledData< InputT, LabelT >::shuffle ()
 shuffles all elements in the entire dataset (that is, also across the batches) More...
 
void shark::LabeledData< InputT, LabelT >::splitBatch (std::size_t batch, std::size_t elementIndex)
 
LabeledData shark::LabeledData< InputT, LabelT >::splice (std::size_t batch)
 Splits the container into two independent parts. The left part remains in the container, the right is stored as return type. More...
 
void shark::LabeledData< InputT, LabelT >::append (LabeledData const &other)
 Appends the contents of another data object to the end. More...
 
void shark::LabeledData< InputT, LabelT >::push_back (typename Batch< InputType >::type const &inputs, typename Batch< LabelType >::type const &labels)
 
void shark::LabeledData< InputT, LabelT >::push_back (const_batch_reference batch)
 
template<class Range >
void shark::LabeledData< InputT, LabelT >::repartition (Range const &batchSizes)
 Reorders the batch structure in the container to that indicated by the batchSizes vector. More...
 
std::vector< std::size_t > shark::LabeledData< InputT, LabelT >::getPartitioning () const
 Creates a vector with the batch sizes of every batch. More...
 
LabeledData shark::LabeledData< InputT, LabelT >::indexedSubset (IndexSet const &indices) const
 Fill in the subset defined by the list of indices. More...
 
template<class Range >
Data< typename Range::value_type > shark::createDataFromRange (Range const &inputs, std::size_t maximumBatchSize=0)
 creates a data object from a range of elements More...
 
template<class Range >
UnlabeledData< typename boost::range_value< Range >::type > shark::createUnlabeledDataFromRange (Range const &inputs, std::size_t maximumBatchSize=0)
 creates a data object from a range of elements More...
 
template<class Range1 , class Range2 >
LabeledData< typename boost::range_value< Range1 >::type, typename boost::range_value< Range2 >::type > shark::createLabeledDataFromRange (Range1 const &inputs, Range2 const &labels, std::size_t maximumBatchSize=0)
 creates a labeled data object from two ranges, representing inputs and labels More...
 
template<class T , class U >
std::ostream & shark::operator<< (std::ostream &stream, const LabeledData< T, U > &d)
 brief Outstream of elements for labeled data. More...
 
unsigned int shark::numberOfClasses (Data< unsigned int > const &labels)
 Return the number of classes of a set of class labels with unsigned int label encoding. More...
 
std::vector< std::size_t > shark::classSizes (Data< unsigned int > const &labels)
 Returns the number of members of each class in the dataset. More...
 
template<class InputType >
std::size_t shark::dataDimension (Data< InputType > const &dataset)
 Return the dimensionality of a dataset. More...
 
template<class InputType , class LabelType >
std::size_t shark::inputDimension (LabeledData< InputType, LabelType > const &dataset)
 Return the input dimensionality of a labeled dataset. More...
 
template<class InputType , class LabelType >
std::size_t shark::labelDimension (LabeledData< InputType, LabelType > const &dataset)
 Return the label/output dimensionality of a labeled dataset. More...
 
template<class InputType >
std::size_t shark::numberOfClasses (LabeledData< InputType, unsigned int > const &dataset)
 Return the number of classes (highest label value +1) of a classification dataset with unsigned int label encoding. More...
 
template<class InputType , class LabelType >
std::vector< std::size_t > shark::classSizes (LabeledData< InputType, LabelType > const &dataset)
 Returns the number of members of each class in the dataset. More...
 
template<class T , class Functor >
boost::lazy_disable_if< CanBeCalled< Functor, typename Data< T >::batch_type >, TransformedData< Functor, T >>::type shark::transform (Data< T > const &data, Functor f)
 Transforms a dataset using a Functor f and returns the transformed result. More...
 
template<class T , class Functor >
boost::lazy_enable_if< CanBeCalled< Functor, typename Data< T >::batch_type >, TransformedData< Functor, T >>::type shark::transform (Data< T > const &data, Functor const &f)
 Transforms a dataset using a Functor f and returns the transformed result. More...
 
template<class I , class L , class Functor >
LabeledData< typename detail::TransformedDataElement< Functor, I >::type, L > shark::transformInputs (LabeledData< I, L > const &data, Functor const &f)
 Transforms the inputs of a dataset and return the transformed result. More...
 
template<class I , class L , class Functor >
LabeledData< I, typename detail::TransformedDataElement< Functor, L >::type > shark::transformLabels (LabeledData< I, L > const &data, Functor const &f)
 Transforms the labels of a dataset and returns the transformed result. More...
 
template<class T , class FeatureSet >
Data< blas::vector< T > > shark::selectFeatures (Data< blas::vector< T > > const &data, FeatureSet const &features)
 Creates a copy of a dataset selecting only a certain set of features. More...
 
template<class T , class FeatureSet >
LabeledData< RealVector, T > shark::selectInputFeatures (LabeledData< RealVector, T > const &data, FeatureSet const &features)
 
template<class DatasetT >
DatasetT shark::splitAtElement (DatasetT &data, std::size_t elementIndex)
 Removes the last part of a given dataset and returns a new split containing the removed elements. More...
 
template<class I >
void shark::repartitionByClass (LabeledData< I, unsigned int > &data, std::size_t batchSize=LabeledData< I, unsigned int >::DefaultBatchSize)
 reorders the dataset such, that points are grouped by labels More...
 
template<class I >
LabeledData< I, unsigned int > shark::binarySubProblem (LabeledData< I, unsigned int >const &data, unsigned int zeroClass, unsigned int oneClass)
 
template<class I >
LabeledData< I, unsigned int > shark::oneVersusRestProblem (LabeledData< I, unsigned int >const &data, unsigned int oneClass)
 Construct a binary (two-class) one-versus-rest problem from a multi-class problem. More...
 
template<typename RowType >
RowType shark::getColumn (Data< RowType > const &data, std::size_t columnID)
 
template<typename RowType >
void shark::setColumn (Data< RowType > &data, std::size_t columnID, RowType newColumn)
 

Variables

static const double shark::SQRT_2_PI = boost::math::constants::root_two_pi<double>()
 Constant for sqrt( 2 * pi ). More...
 
Container shark::Data< Type >::m_data
 data More...
 
Shape shark::Data< Type >::m_shape
 shape of a datapoint More...
 
static const std::size_t shark::LabeledData< InputT, LabelT >::DefaultBatchSize = InputContainer::DefaultBatchSize
 
InputContainer shark::LabeledData< InputT, LabelT >::m_data
 
LabelContainer shark::LabeledData< InputT, LabelT >::m_label
 point data More...
 

Friends

template<class InputT , class LabelT >
class shark::Data< Type >::LabeledData
 
void shark::Data< Type >::swap (Data &a, Data &b)
 
void shark::LabeledData< InputT, LabelT >::swap (LabeledData &a, LabeledData &b)
 
enum  shark::LabelPosition { shark::FIRST_COLUMN, shark::LAST_COLUMN }
 Position of the label in a CSV file. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (Data< FloatVector > &data, std::string const &contents, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< RealVector >::DefaultBatchSize)
 Import unlabeled vectors from a read-in character-separated value file. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (Data< RealVector > &data, std::string const &contents, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< RealVector >::DefaultBatchSize)
 Import unlabeled vectors from a read-in character-separated value file. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (Data< unsigned int > &data, std::string const &contents, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< unsigned int >::DefaultBatchSize)
 Import "csv" from string consisting only of a single unsigned int per row. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (Data< int > &data, std::string const &contents, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< int >::DefaultBatchSize)
 Import "csv" from string consisting only of a single int per row. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (Data< float > &data, std::string const &contents, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< double >::DefaultBatchSize)
 Import "csv" from string consisting only of a single double per row. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (Data< double > &data, std::string const &contents, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< double >::DefaultBatchSize)
 Import "csv" from string consisting only of a single double per row. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (LabeledData< RealVector, unsigned int > &dataset, std::string const &contents, LabelPosition lp, char separator=',', char comment='#', std::size_t maximumBatchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import labeled data from a character-separated value file. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (LabeledData< FloatVector, unsigned int > &dataset, std::string const &contents, LabelPosition lp, char separator=',', char comment='#', std::size_t maximumBatchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import labeled data from a character-separated value file. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (LabeledData< RealVector, RealVector > &dataset, std::string const &contents, LabelPosition lp, std::size_t numberOfOutputs=1, char separator=',', char comment='#', std::size_t maximumBatchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import regression data from a read-in character-separated value file. More...
 
SHARK_EXPORT_SYMBOL void shark::csvStringToData (LabeledData< FloatVector, FloatVector > &dataset, std::string const &contents, LabelPosition lp, std::size_t numberOfOutputs=1, char separator=',', char comment='#', std::size_t maximumBatchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import regression data from a read-in character-separated value file. More...
 
template<class T >
void shark::importCSV (Data< T > &data, std::string fn, char separator=',', char comment='#', std::size_t maximumBatchSize=Data< T >::DefaultBatchSize, std::size_t titleLines=0)
 Import a Dataset from a csv file. More...
 
template<class T >
void shark::importCSV (LabeledData< blas::vector< T >, unsigned int > &data, std::string fn, LabelPosition lp, char separator=',', char comment='#', std::size_t maximumBatchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import a labeled Dataset from a csv file. More...
 
template<class T >
void shark::importCSV (LabeledData< blas::vector< T >, blas::vector< T > > &data, std::string fn, LabelPosition lp, std::size_t numberOfOutputs=1, char separator=',', char comment='#', std::size_t maximumBatchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import a labeled Dataset from a csv file. More...
 
template<typename Type >
void shark::exportCSV (Data< Type > const &set, std::string fn, char separator=',', bool sci=true, unsigned int width=0)
 Format unlabeled data into a character-separated value file. More...
 
template<typename InputType , typename LabelType >
void shark::exportCSV (LabeledData< InputType, LabelType > const &dataset, std::string fn, LabelPosition lp, char separator=',', bool sci=true, unsigned int width=0)
 Format labeled data into a character-separated value file. More...
 
template<class I , class L >
CVFolds< LabeledData< I, L > > shark::createCVIID (LabeledData< I, L > &set, std::size_t numberOfPartitions, std::size_t batchSize=Data< I >::DefaultBatchSize)
 Create a partition for cross validation. More...
 
template<class I , class L >
CVFolds< LabeledData< I, L > > shark::createCVSameSize (LabeledData< I, L > &set, std::size_t numberOfPartitions, std::size_t batchSize=LabeledData< I, L >::DefaultBatchSize)
 Create a partition for cross validation. More...
 
template<class I >
CVFolds< LabeledData< I, unsigned int > > shark::createCVSameSizeBalanced (LabeledData< I, unsigned int > &set, std::size_t numberOfPartitions, std::size_t batchSize=Data< I >::DefaultBatchSize, RecreationIndices *cv_indices=NULL)
 Create a partition for cross validation. More...
 
template<class I , class L >
CVFolds< LabeledData< I, L > > shark::createCVBatch (LabeledData< I, L > const &set, std::size_t numberOfPartitions)
 Create a partition for cross validation without changing the dataset. More...
 
template<class I , class L >
CVFolds< LabeledData< I, L > > shark::createCVIndexed (LabeledData< I, L > &set, std::size_t numberOfPartitions, std::vector< std::size_t > indices, std::size_t batchSize=Data< I >::DefaultBatchSize)
 Create a partition for cross validation from indices. More...
 
template<class I , class L >
CVFolds< LabeledData< I, L > > shark::createCVFullyIndexed (LabeledData< I, L > &set, std::size_t numberOfPartitions, RecreationIndices indices, std::size_t batchSize=Data< I >::DefaultBatchSize)
 Create a partition for cross validation from indices for both ordering and partitioning. More...
 
template<class T >
std::ostream & shark::operator<< (std::ostream &stream, const Data< T > &d)
 Outstream of elements. More...
 
SHARK_EXPORT_SYMBOL std::pair< std::string, std::string > shark::splitUrl (std::string const &url)
 Split a URL into its domain and resource parts. More...
 
SHARK_EXPORT_SYMBOL std::string shark::download (std::string const &url, unsigned short port=80)
 Download a document with the HTTP protocol. More...
 
template<class InputType , class LabelType >
void shark::downloadSparseData (LabeledData< InputType, LabelType > &dataset, std::string const &url, unsigned short port=80, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Download and import a sparse data (libSVM) file. More...
 
template<class InputType , class LabelType >
void shark::downloadFromMLData (LabeledData< InputType, LabelType > &dataset, std::string const &name, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Download a data set from mldata.org. More...
 
template<class InputType >
void shark::downloadCsvData (LabeledData< InputType, unsigned int > &dataset, std::string const &url, LabelPosition lp, char separator=',', char comment='#', unsigned short port=80, std::size_t maximumBatchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Download and import a dense data (CSV) file for classification. More...
 
template<class InputType >
void shark::downloadCsvData (LabeledData< InputType, RealVector > &dataset, std::string const &url, LabelPosition lp, std::size_t numberOfOutputs=1, char separator=',', char comment='#', unsigned short port=80, std::size_t maximumBatchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Download and import a dense data (CSV) file for regression. More...
 
enum  shark::KernelMatrixNormalizationType {
  shark::NONE, shark::MULTIPLICATIVE_TRACE_ONE, shark::MULTIPLICATIVE_TRACE_N, shark::MULTIPLICATIVE_VARIANCE_ONE,
  shark::CENTER_ONLY, shark::CENTER_AND_MULTIPLICATIVE_TRACE_ONE
}
 
template<typename InputType , typename LabelType >
void shark::exportKernelMatrix (LabeledData< InputType, LabelType > const &dataset, AbstractKernelFunction< InputType > &kernel, std::ostream &out, KernelMatrixNormalizationType normalizer=NONE, bool scientific=false, unsigned int fieldwidth=0)
 Write a kernel Gram matrix to stream. More...
 
template<typename InputType , typename LabelType >
void shark::exportKernelMatrix (LabeledData< InputType, LabelType > const &dataset, AbstractKernelFunction< InputType > &kernel, std::string fn, KernelMatrixNormalizationType normalizer=NONE, bool sci=false, unsigned int width=0)
 Write a kernel Gram matrix to file. More...
 
template<typename InputType , typename LabelType >
void shark::export_kernel_matrix (LabeledData< InputType, LabelType > const &dataset, AbstractKernelFunction< InputType > &kernel, std::ostream &out, KernelMatrixNormalizationType normalizer=NONE, bool scientific=false, unsigned int fieldwidth=0)
 
template<typename InputType , typename LabelType >
void shark::export_kernel_matrix (LabeledData< InputType, LabelType > const &dataset, AbstractKernelFunction< InputType > &kernel, std::string fn, KernelMatrixNormalizationType normalizer=NONE, bool sci=false, unsigned int width=0)
 
void shark::import_libsvm (LabeledData< RealVector, unsigned int > &dataset, std::istream &stream, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import data from a LIBSVM file. More...
 
void shark::import_libsvm (LabeledData< CompressedRealVector, unsigned int > &dataset, std::istream &stream, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import data from a LIBSVM file. More...
 
void shark::import_libsvm (LabeledData< RealVector, unsigned int > &dataset, std::string fn, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import data from a LIBSVM file. More...
 
void shark::import_libsvm (LabeledData< CompressedRealVector, unsigned int > &dataset, std::string fn, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import data from a LIBSVM file. More...
 
template<typename InputType >
void shark::export_libsvm (LabeledData< InputType, unsigned int > &dataset, const std::string &fn, bool dense=false, bool oneMinusOne=true, bool sortLabels=false, bool append=false)
 Export data to LIBSVM format. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< RealVector, unsigned int > &dataset, std::istream &stream, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import classification data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< RealVector, RealVector > &dataset, std::istream &stream, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import regression data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< CompressedRealVector, unsigned int > &dataset, std::istream &stream, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import classification data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< CompressedRealVector, RealVector > &dataset, std::istream &stream, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import regression data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< RealVector, unsigned int > &dataset, std::string fn, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import classification data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< RealVector, RealVector > &dataset, std::string fn, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import regression data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< CompressedRealVector, unsigned int > &dataset, std::string fn, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, unsigned int >::DefaultBatchSize)
 Import classification data from a sparse data (libSVM) file. More...
 
SHARK_EXPORT_SYMBOL void shark::importSparseData (LabeledData< CompressedRealVector, RealVector > &dataset, std::string fn, unsigned int highestIndex=0, std::size_t batchSize=LabeledData< RealVector, RealVector >::DefaultBatchSize)
 Import regression data from a sparse data (libSVM) file. More...
 
template<typename InputType >
void shark::exportSparseData (LabeledData< InputType, unsigned int > const &dataset, std::ostream &stream, bool oneMinusOne=true, bool sortLabels=false)
 Export classification data to sparse data (libSVM) format. More...
 
template<typename InputType >
void shark::exportSparseData (LabeledData< InputType, unsigned int > const &dataset, const std::string &fn, bool oneMinusOne=true, bool sortLabels=false, bool append=false)
 Export classification data to sparse data (libSVM) format. More...
 
template<typename InputType >
void shark::exportSparseData (LabeledData< InputType, RealVector > const &dataset, std::ostream &stream)
 Export regression data to sparse data (libSVM) format. More...
 
template<typename InputType >
void shark::exportSparseData (LabeledData< InputType, RealVector > const &dataset, const std::string &fn, bool append=false)
 Export regression data to sparse data (libSVM) format. More...
 
template<class X , class R >
X::value_type shark::blas::createHouseholderReflection (vector_expression< X, cpu_tag > const &x, vector_expression< R, cpu_tag > &reflection)
 Generates a Householder reflection from a vector to use with applyHouseholderLeft/Right. More...
 
template<class Mat , class R , class T , class Device >
void shark::blas::applyHouseholderOnTheRight (matrix_expression< Mat, Device > &matrix, vector_expression< R, Device > const &reflection, T beta)
 
template<class Mat , class R , class T , class Device >
void shark::blas::applyHouseholderOnTheLeft (matrix_expression< Mat, Device > &matrix, vector_expression< R, Device > const &reflection, T const &beta)
 rotates a matrix using a householder reflection More...
 
template<class Mat , class R , class T , class Device >
void shark::blas::applyHouseholderOnTheLeft (temporary_proxy< Mat > matrix, vector_expression< R, Device > const &reflection, T const &beta)
 rotates a matrix using a householder reflection More...
 
template<class MatrixT >
void shark::blas::randomRotationMatrix (random::rng_type &rng, matrix_container< MatrixT, cpu_tag > &matrixC)
 Initializes a matrix such that it forms a random rotation matrix. More...
 
RealMatrix shark::blas::randomRotationMatrix (random::rng_type &rng, size_t size)
 Creates a random rotation matrix with a certain size using the random number generator rng. More...
 
template<class InputType , class OutputType >
void shark::initRandomNormal (AbstractModel< InputType, OutputType > &model, double s)
 Initialize model parameters normally distributed. More...
 
template<class InputType , class OutputType >
void shark::initRandomUniform (AbstractModel< InputType, OutputType > &model, double lower, double upper)
 Initialize model parameters uniformly at random. More...
 

Detailed Description

Several mathematical, linear-algebra, or other functions within Shark are not part of any particular class. They are collected here in the doxygen group "shark_globals".

Typedef Documentation

◆ batch_range [1/2]

template<class Type>
typedef detail::BatchRange<Data<Type> > shark::Data< Type >::batch_range

Definition at line 166 of file Dataset.h.

◆ batch_range [2/2]

template<class InputT, class LabelT>
typedef detail::BatchRange<LabeledData<InputType,LabelType> > shark::LabeledData< InputT, LabelT >::batch_range

Definition at line 501 of file Dataset.h.

◆ batch_reference [1/2]

template<class Type>
typedef batch_type& shark::Data< Type >::batch_reference

Definition at line 142 of file Dataset.h.

◆ batch_reference [2/2]

template<class InputT, class LabelT>
typedef InputLabelBatch< typename Batch<InputType>::type&, typename Batch<LabelType>::type& > shark::LabeledData< InputT, LabelT >::batch_reference

Definition at line 490 of file Dataset.h.

◆ const_batch_range [1/2]

template<class Type>
typedef detail::BatchRange<Data<Type> const> shark::Data< Type >::const_batch_range

Definition at line 167 of file Dataset.h.

◆ const_batch_range [2/2]

template<class InputT, class LabelT>
typedef detail::BatchRange<LabeledData<InputType,LabelType> const> shark::LabeledData< InputT, LabelT >::const_batch_range

Definition at line 502 of file Dataset.h.

◆ const_batch_reference [1/2]

template<class Type>
typedef batch_type const& shark::Data< Type >::const_batch_reference

Definition at line 143 of file Dataset.h.

◆ const_batch_reference [2/2]

template<class InputT, class LabelT>
typedef InputLabelBatch< typename Batch<InputType>::type const&, typename Batch<LabelType>::type const& > shark::LabeledData< InputT, LabelT >::const_batch_reference

Definition at line 494 of file Dataset.h.

◆ const_element_range [1/2]

template<class Type>
typedef boost::iterator_range< detail::DataElementIterator<Data<Type> const> > shark::Data< Type >::const_element_range

Definition at line 165 of file Dataset.h.

◆ const_element_range [2/2]

template<class InputT, class LabelT>
typedef boost::iterator_range< detail::DataElementIterator<LabeledData<InputType,LabelType> const> > shark::LabeledData< InputT, LabelT >::const_element_range

Definition at line 500 of file Dataset.h.

◆ const_element_reference [1/2]

template<class Type>
typedef Batch<element_type>::const_reference shark::Data< Type >::const_element_reference

Definition at line 147 of file Dataset.h.

◆ const_element_reference [2/2]

template<class InputT, class LabelT>
typedef const_batch_reference::const_reference shark::LabeledData< InputT, LabelT >::const_element_reference

Definition at line 497 of file Dataset.h.

◆ Container

template<class Type>
typedef detail::SharedContainer<Type> shark::Data< Type >::Container
protected

Definition at line 131 of file Dataset.h.

◆ element_range [1/2]

template<class Type>
typedef boost::iterator_range< detail::DataElementIterator<Data<Type> > > shark::Data< Type >::element_range

Definition at line 164 of file Dataset.h.

◆ element_range [2/2]

template<class InputT, class LabelT>
typedef boost::iterator_range< detail::DataElementIterator<LabeledData<InputType,LabelType> > > shark::LabeledData< InputT, LabelT >::element_range

Definition at line 499 of file Dataset.h.

◆ element_reference [1/2]

template<class Type>
typedef Batch<element_type>::reference shark::Data< Type >::element_reference

Definition at line 146 of file Dataset.h.

◆ element_reference [2/2]

template<class InputT, class LabelT>
typedef batch_reference::reference shark::LabeledData< InputT, LabelT >::element_reference

Definition at line 496 of file Dataset.h.

◆ IndexSet [1/2]

template<class Type>
typedef std::vector<std::size_t> shark::Data< Type >::IndexSet

Definition at line 149 of file Dataset.h.

◆ IndexSet [2/2]

template<class InputT, class LabelT>
typedef InputContainer::IndexSet shark::LabeledData< InputT, LabelT >::IndexSet

Definition at line 474 of file Dataset.h.

◆ InputContainer [1/2]

template<class InputT>
typedef detail::SharedContainer<InputT> shark::UnlabeledData< InputT >::InputContainer

Definition at line 379 of file Dataset.h.

◆ InputContainer [2/2]

template<class InputT, class LabelT>
typedef UnlabeledData<InputT> shark::LabeledData< InputT, LabelT >::InputContainer

Definition at line 472 of file Dataset.h.

◆ InputType [1/2]

template<class InputT>
typedef element_type shark::UnlabeledData< InputT >::InputType

Definition at line 378 of file Dataset.h.

◆ InputType [2/2]

template<class InputT, class LabelT>
typedef InputT shark::LabeledData< InputT, LabelT >::InputType

Definition at line 470 of file Dataset.h.

◆ LabelContainer

template<class InputT, class LabelT>
typedef Data<LabelT> shark::LabeledData< InputT, LabelT >::LabelContainer

Definition at line 473 of file Dataset.h.

◆ LabelType

template<class InputT, class LabelT>
typedef LabelT shark::LabeledData< InputT, LabelT >::LabelType

Definition at line 471 of file Dataset.h.

Enumeration Type Documentation

◆ KernelMatrixNormalizationType

Enumerator
NONE 
MULTIPLICATIVE_TRACE_ONE 
MULTIPLICATIVE_TRACE_N 
MULTIPLICATIVE_VARIANCE_ONE 
CENTER_ONLY 
CENTER_AND_MULTIPLICATIVE_TRACE_ONE 

Definition at line 57 of file ExportKernelMatrix.h.

◆ LabelPosition

Position of the label in a CSV file.

This type describes the position of the label in a record of a CSV file. The label can be positioned either in the first or the last column, or there can be no label present at all.
Enumerator
FIRST_COLUMN 
LAST_COLUMN 

Definition at line 66 of file Csv.h.

Function Documentation

◆ append() [1/2]

template<class Type>
void shark::Data< Type >::append ( Data< Type > const &  other)
inline

Appends the contents of another data object to the end.

The batches are not copied but now referenced from both datasets. Thus changing the appended dataset might change this one as well.

Definition at line 305 of file Dataset.h.

◆ append() [2/2]

template<class InputT, class LabelT>
void shark::LabeledData< InputT, LabelT >::append ( LabeledData< InputT, LabelT > const &  other)
inline

Appends the contents of another data object to the end.

The batches are not copied but now referenced from both datasets. Thus changing the appended dataset might change this one as well.

Definition at line 689 of file Dataset.h.

◆ applyHouseholderOnTheLeft() [1/2]

template<class Mat , class R , class T , class Device >
void shark::blas::applyHouseholderOnTheLeft ( matrix_expression< Mat, Device > &  matrix,
vector_expression< R, Device > const &  reflection,
T const &  beta 
)

rotates a matrix using a householder reflection

calculates (1-beta*xx^T)*A

Definition at line 112 of file rotations.h.

References beta, and SIZE_CHECK.

Referenced by shark::blas::applyHouseholderOnTheLeft().

◆ applyHouseholderOnTheLeft() [2/2]

template<class Mat , class R , class T , class Device >
void shark::blas::applyHouseholderOnTheLeft ( temporary_proxy< Mat >  matrix,
vector_expression< R, Device > const &  reflection,
T const &  beta 
)

rotates a matrix using a householder reflection

calculates (1-beta*xx^T)*A

Definition at line 137 of file rotations.h.

References shark::blas::applyHouseholderOnTheLeft().

◆ applyHouseholderOnTheRight()

template<class Mat , class R , class T , class Device >
void shark::blas::applyHouseholderOnTheRight ( matrix_expression< Mat, Device > &  matrix,
vector_expression< R, Device > const &  reflection,
beta 
)

Definition at line 85 of file rotations.h.

References beta, and SIZE_CHECK.

◆ batch() [1/4]

◆ batch() [2/4]

template<class Type>
const_batch_reference shark::Data< Type >::batch ( std::size_t  i) const
inline

Definition at line 243 of file Dataset.h.

◆ batch() [3/4]

template<class InputT, class LabelT>
batch_reference shark::LabeledData< InputT, LabelT >::batch ( std::size_t  i)
inline

◆ batch() [4/4]

template<class InputT, class LabelT>
const_batch_reference shark::LabeledData< InputT, LabelT >::batch ( std::size_t  i) const
inline

Definition at line 623 of file Dataset.h.

◆ batches() [1/4]

template<class Type>
const_batch_range shark::Data< Type >::batches ( ) const
inline

Returns the range of batches.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 195 of file Dataset.h.

Referenced by shark::createDataFromRange(), shark::ExactGradient< RBMType >::evalDerivative(), main(), shark::negativeLogLikelihoodFromLogPartition(), and shark::transform().

◆ batches() [2/4]

template<class Type>
batch_range shark::Data< Type >::batches ( )
inline

Returns the range of batches.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 202 of file Dataset.h.

◆ batches() [3/4]

template<class InputT, class LabelT>
const_batch_range shark::LabeledData< InputT, LabelT >::batches ( ) const
inline

Returns the range of batches.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 530 of file Dataset.h.

◆ batches() [4/4]

template<class InputT, class LabelT>
batch_range shark::LabeledData< InputT, LabelT >::batches ( )
inline

Returns the range of batches.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 537 of file Dataset.h.

◆ binarySubProblem()

template<class I >
LabeledData<I,unsigned int> shark::binarySubProblem ( LabeledData< I, unsigned int >const &  data,
unsigned int  zeroClass,
unsigned int  oneClass 
)

Definition at line 1062 of file Dataset.h.

Referenced by main().

◆ BOOST_STATIC_CONSTANT()

template<class Type>
shark::Data< Type >::BOOST_STATIC_CONSTANT ( std::size_t  ,
DefaultBatchSize  = 256 
)

Defines the default batch size of the Container.

Zero means: unlimited

◆ classSizes() [1/2]

std::vector<std::size_t> shark::classSizes ( Data< unsigned int > const &  labels)
inline

Returns the number of members of each class in the dataset.

Definition at line 865 of file Dataset.h.

References shark::Data< Type >::batch(), shark::Data< Type >::numberOfBatches(), and shark::numberOfClasses().

Referenced by shark::classSizes(), main(), shark::repartitionByClass(), and shark::ROC::ROC().

◆ classSizes() [2/2]

template<class InputType , class LabelType >
std::vector<std::size_t> shark::classSizes ( LabeledData< InputType, LabelType > const &  dataset)
inline

Returns the number of members of each class in the dataset.

Definition at line 900 of file Dataset.h.

References shark::classSizes(), and shark::LabeledData< InputT, LabelT >::labels().

◆ copySign()

template<class T >
T shark::copySign ( x,
y 
)

brief lets x have the same sign as y.

This is the famous well known copysign function from fortran.

Definition at line 175 of file Math.h.

◆ createCVBatch()

template<class I , class L >
CVFolds<LabeledData<I,L> > shark::createCVBatch ( LabeledData< I, L > const &  set,
std::size_t  numberOfPartitions 
)

Create a partition for cross validation without changing the dataset.

This method behaves similar to createCVIID with the difference that batches are not reordered. Thus the batches are only rearranged randomly in folds, but the dataset itself is not changed.

Parameters
numberOfPartitionsnumber of partitions to create
setthe input data from which to draw the partitions

Definition at line 327 of file CVDatasetTools.h.

References shark::random::globalRng, shark::shuffle(), and shark::CVFolds< DatasetTypeT >::size().

◆ createCVFullyIndexed()

template<class I , class L >
CVFolds<LabeledData<I,L> > shark::createCVFullyIndexed ( LabeledData< I, L > &  set,
std::size_t  numberOfPartitions,
RecreationIndices  indices,
std::size_t  batchSize = Data<I>::DefaultBatchSize 
)

Create a partition for cross validation from indices for both ordering and partitioning.

Create a partition from indices. There is one index vector assigning an order to the samples, and another one assigning each sample to a validation partition. That is, given a dataset set, and at the i-th processing step, this function puts the order_indices[i]-th sample into the partition_indices[i]-th partition. The order_indices part of the above procedure matters if both an inner and outer partition are to be recreated: for the inner partition to be recreated, too, the outer partition must be recreated in the same order, not just partitioned into the same splits.

Parameters
setpartitions will be subsets of this set
numberOfPartitionsnumber of partitions to create
indicesstores location index in the first and partition index in the second vector
batchSizemaximum batch size

Definition at line 427 of file CVDatasetTools.h.

References shark::LabeledData< InputT, LabelT >::batch(), shark::batchSize(), shark::CVFolds< DatasetTypeT >::size(), SIZE_CHECK, shark::subBatch(), and shark::swap().

◆ createCVIID()

template<class I , class L >
CVFolds<LabeledData<I,L> > shark::createCVIID ( LabeledData< I, L > &  set,
std::size_t  numberOfPartitions,
std::size_t  batchSize = Data<I>::DefaultBatchSize 
)

Create a partition for cross validation.

The subset each training examples belongs to is drawn independently and uniformly distributed. For every partition, all but one subset form the training set, while the remaining one is used for validation. The partitions can be accessed using getCVPartitionName

Parameters
setthe input data for which the new partitions are created
numberOfPartitionsnumber of partitions to create
batchSizemaximum batch size

Definition at line 240 of file CVDatasetTools.h.

References shark::batchSize(), shark::createCVIndexed(), shark::random::discrete(), and shark::random::globalRng.

Referenced by main(), and run_one_trial().

◆ createCVIndexed()

template<class I , class L >
CVFolds<LabeledData<I,L> > shark::createCVIndexed ( LabeledData< I, L > &  set,
std::size_t  numberOfPartitions,
std::vector< std::size_t >  indices,
std::size_t  batchSize = Data<I>::DefaultBatchSize 
)

Create a partition for cross validation from indices.

Create a partition from indices. The indices vector for each sample states of what validation partition that sample should become a member. In other words, the index maps a sample to a validation partition, meaning that it will become a part of the training partition for all other folds.

Parameters
setpartitions will be subsets of this set
numberOfPartitionsnumber of partitions to create
indicespartition indices of the examples in [0, ..., numberOfPartitions[.
batchSizemaximum batch size

Definition at line 366 of file CVDatasetTools.h.

References shark::LabeledData< InputT, LabelT >::batch(), shark::batchSize(), shark::CVFolds< DatasetTypeT >::size(), SIZE_CHECK, shark::subBatch(), and shark::swap().

Referenced by shark::createCVIID(), and main().

◆ createCVSameSize()

template<class I , class L >
CVFolds<LabeledData<I,L> > shark::createCVSameSize ( LabeledData< I, L > &  set,
std::size_t  numberOfPartitions,
std::size_t  batchSize = LabeledData<I,L>::DefaultBatchSize 
)

Create a partition for cross validation.

Every subset contains (approximately) the same number of elements. For every partition, all but one subset form the training set, while the remaining one is used for validation. The partitions can be accessed using getCVPartitionName

Parameters
numberOfPartitionsnumber of partitions to create
setthe input data from which to draw the partitions
batchSizemaximum batch size

Definition at line 261 of file CVDatasetTools.h.

References shark::batchSize().

Referenced by main().

◆ createCVSameSizeBalanced()

template<class I >
CVFolds<LabeledData<I,unsigned int> > shark::createCVSameSizeBalanced ( LabeledData< I, unsigned int > &  set,
std::size_t  numberOfPartitions,
std::size_t  batchSize = Data<I>::DefaultBatchSize,
RecreationIndices cv_indices = NULL 
)

Create a partition for cross validation.

Every subset contains (approximately) the same number of elements. For every partition, all but one subset form the training set, while the remaining one is used for validation.

Parameters
numberOfPartitionsnumber of partitions to create
setthe input data from which to draw the partitions
batchSizemaximum batch size
cv_indicesif not NULL [default]: for each element, store the fold it is assigned to; this can be used to later/externally recreate the fold via createCVIndexed

Definition at line 298 of file CVDatasetTools.h.

References shark::batchSize(), shark::numberOfClasses(), and shark::DataView< DatasetType >::size().

Referenced by main().

◆ createDataFromRange()

template<class Range >
Data<typename Range::value_type> shark::createDataFromRange ( Range const &  inputs,
std::size_t  maximumBatchSize = 0 
)

◆ createHouseholderReflection()

template<class X , class R >
X::value_type shark::blas::createHouseholderReflection ( vector_expression< X, cpu_tag > const &  x,
vector_expression< R, cpu_tag > &  reflection 
)

Generates a Householder reflection from a vector to use with applyHouseholderLeft/Right.

Given a Vector x=(x0,x1,...,xn), finds a reflection with the property (c, 0,0,...0) = (I-beta v v^t)x and v = (x0-c,x1,x2,...,xn)

Definition at line 52 of file rotations.h.

References SIZE_CHECK.

◆ createLabeledDataFromRange()

template<class Range1 , class Range2 >
LabeledData< typename boost::range_value<Range1>::type, typename boost::range_value<Range2>::type> shark::createLabeledDataFromRange ( Range1 const &  inputs,
Range2 const &  labels,
std::size_t  maximumBatchSize = 0 
)

creates a labeled data object from two ranges, representing inputs and labels

Definition at line 829 of file Dataset.h.

References shark::createDataFromRange(), and SHARK_RUNTIME_CHECK.

Referenced by shark::createLabeledDataFromRange(), shark::LabeledDataDistribution< RealVector, unsigned int >::generateDataset(), and main().

◆ createUnlabeledDataFromRange()

template<class Range >
UnlabeledData<typename boost::range_value<Range>::type> shark::createUnlabeledDataFromRange ( Range const &  inputs,
std::size_t  maximumBatchSize = 0 
)

creates a data object from a range of elements

Definition at line 820 of file Dataset.h.

References shark::createDataFromRange().

Referenced by shark::createUnlabeledDataFromRange(), and shark::DataDistribution< RealVector >::generateDataset().

◆ csvStringToData() [1/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( Data< FloatVector > &  data,
std::string const &  contents,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data< RealVector >::DefaultBatchSize 
)

Import unlabeled vectors from a read-in character-separated value file.

Parameters
dataContainer storing the loaded data
contentsThe read in csv-file
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
maximumBatchSizeSize of batches in the dataset

Referenced by shark::downloadCsvData(), and shark::importCSV().

◆ csvStringToData() [2/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( Data< RealVector > &  data,
std::string const &  contents,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data< RealVector >::DefaultBatchSize 
)

Import unlabeled vectors from a read-in character-separated value file.

Parameters
dataContainer storing the loaded data
contentsThe read in csv-file
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
maximumBatchSizeSize of batches in the dataset

◆ csvStringToData() [3/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( Data< unsigned int > &  data,
std::string const &  contents,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data< unsigned int >::DefaultBatchSize 
)

Import "csv" from string consisting only of a single unsigned int per row.

Parameters
dataContainer storing the loaded data
contentsThe read in csv-file
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing characters indicating comment line. By default it is "#"
maximumBatchSizeSize of batches in the dataset

◆ csvStringToData() [4/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( Data< int > &  data,
std::string const &  contents,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data< int >::DefaultBatchSize 
)

Import "csv" from string consisting only of a single int per row.

Parameters
dataContainer storing the loaded data
contentsThe read in csv-file
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing characters indicating comment line. By default it is "#"
maximumBatchSizeSize of batches in the dataset

◆ csvStringToData() [5/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( Data< float > &  data,
std::string const &  contents,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data< double >::DefaultBatchSize 
)

Import "csv" from string consisting only of a single double per row.

Parameters
dataContainer storing the loaded data
contentsThe read in csv-file
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing characters indicating comment line. By default it is "#"
maximumBatchSizeSize of batches in the dataset

◆ csvStringToData() [6/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( Data< double > &  data,
std::string const &  contents,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data< double >::DefaultBatchSize 
)

Import "csv" from string consisting only of a single double per row.

Parameters
dataContainer storing the loaded data
contentsThe read in csv-file
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing characters indicating comment line. By default it is "#"
maximumBatchSizeSize of batches in the dataset

◆ csvStringToData() [7/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( LabeledData< RealVector, unsigned int > &  dataset,
std::string const &  contents,
LabelPosition  lp,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = LabeledData< RealVector, unsigned int >::DefaultBatchSize 
)

Import labeled data from a character-separated value file.

Parameters
datasetContainer storing the loaded data
contentsthe read-in file contents.
lpPosition of the label in the record, either first or last column
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentCharacter for indicating a comment, by default '#'
maximumBatchSizemaximum size of a batch in the dataset after import

◆ csvStringToData() [8/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( LabeledData< FloatVector, unsigned int > &  dataset,
std::string const &  contents,
LabelPosition  lp,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = LabeledData< RealVector, unsigned int >::DefaultBatchSize 
)

Import labeled data from a character-separated value file.

Parameters
datasetContainer storing the loaded data
contentsthe read-in file contents.
lpPosition of the label in the record, either first or last column
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentCharacter for indicating a comment, by default '#'
maximumBatchSizemaximum size of a batch in the dataset after import

◆ csvStringToData() [9/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( LabeledData< RealVector, RealVector > &  dataset,
std::string const &  contents,
LabelPosition  lp,
std::size_t  numberOfOutputs = 1,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = LabeledData< RealVector, RealVector >::DefaultBatchSize 
)

Import regression data from a read-in character-separated value file.

Parameters
datasetContainer storing the loaded data
contentsThe read in csv-file
lpPosition of the label in the record, either first or last column
separatorSeparator between entries, typically a comma or a space
commentCharacter for indicating a comment, by default empty
numberOfOutputsDimensionality of label/output
maximumBatchSizemaximum size of a batch in the dataset after import

◆ csvStringToData() [10/10]

SHARK_EXPORT_SYMBOL void shark::csvStringToData ( LabeledData< FloatVector, FloatVector > &  dataset,
std::string const &  contents,
LabelPosition  lp,
std::size_t  numberOfOutputs = 1,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = LabeledData< RealVector, RealVector >::DefaultBatchSize 
)

Import regression data from a read-in character-separated value file.

Parameters
datasetContainer storing the loaded data
contentsThe read in csv-file
lpPosition of the label in the record, either first or last column
separatorSeparator between entries, typically a comma or a space
commentCharacter for indicating a comment, by default empty
numberOfOutputsDimensionality of label/output
maximumBatchSizemaximum size of a batch in the dataset after import

◆ cube()

template<class T >
T shark::cube ( const T &  x)
inline

Calculates x^3.

Definition at line 86 of file Math.h.

◆ Data() [1/3]

template<class Type>
shark::Data< Type >::Data ( )
inline

Constructor which constructs an empty set.

Definition at line 250 of file Dataset.h.

◆ Data() [2/3]

template<class Type>
shark::Data< Type >::Data ( std::size_t  numBatches)
inlineexplicit

Construct a dataset with empty batches.

Definition at line 253 of file Dataset.h.

◆ Data() [3/3]

template<class Type>
shark::Data< Type >::Data ( std::size_t  size,
element_type const &  element,
std::size_t  batchSize = DefaultBatchSize 
)
inlineexplicit

Construction with size and a single element.

Optionally the desired batch Size can be set

Parameters
sizethe new size of the container
elementthe blueprint element from which to create the Container
batchSizethe size of the batches. if this is 0, the size is unlimited

Definition at line 263 of file Dataset.h.

◆ dataDimension()

◆ download()

SHARK_EXPORT_SYMBOL std::string shark::download ( std::string const &  url,
unsigned short  port = 80 
)

Download a document with the HTTP protocol.

Parameters
urldownload URL, for example "www.shark-ml.org/index.html"
portTCP/IP port, defaults to 80

The function requests the document with a HTTP request and returns the body of the corresponding HTTP reply. In case of success this is the requested document. In case of an error the function throws an exception. Note that the function does not perform standard actions of web browsers, e.g., execute javascript or follow http redirects. All HTTP response status codes other than 200 are reported as failure to download the document and trigger an exception.

Referenced by shark::downloadCsvData(), and shark::downloadSparseData().

◆ downloadCsvData() [1/2]

template<class InputType >
void shark::downloadCsvData ( LabeledData< InputType, unsigned int > &  dataset,
std::string const &  url,
LabelPosition  lp,
char  separator = ',',
char  comment = '#',
unsigned short  port = 80,
std::size_t  maximumBatchSize = LabeledData<RealVector, RealVector>::DefaultBatchSize 
)

Download and import a dense data (CSV) file for classification.

Parameters
datasetcontainer storing the loaded data
urlhttp URL
lpPosition of the label in the record, either first or last column
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
portTCP/IP port, default is 80
maximumBatchSizesize of batches in the dataset

Definition at line 135 of file Download.h.

References shark::csvStringToData(), and shark::download().

Referenced by main().

◆ downloadCsvData() [2/2]

template<class InputType >
void shark::downloadCsvData ( LabeledData< InputType, RealVector > &  dataset,
std::string const &  url,
LabelPosition  lp,
std::size_t  numberOfOutputs = 1,
char  separator = ',',
char  comment = '#',
unsigned short  port = 80,
std::size_t  maximumBatchSize = LabeledData<RealVector, RealVector>::DefaultBatchSize 
)

Download and import a dense data (CSV) file for regression.

Parameters
datasetcontainer storing the loaded data
urlhttp URL
lpPosition of the label in the record, either first or last column
numberOfOutputsdimensionality of the labels
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
portTCP/IP port, default is 80
maximumBatchSizesize of batches in the dataset

Definition at line 160 of file Download.h.

References shark::csvStringToData(), and shark::download().

◆ downloadFromMLData()

template<class InputType , class LabelType >
void shark::downloadFromMLData ( LabeledData< InputType, LabelType > &  dataset,
std::string const &  name,
std::size_t  batchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)

Download a data set from mldata.org.

Parameters
datasetcontainer storing the loaded data
namedata set name
batchSizesize of batch

Definition at line 108 of file Download.h.

References shark::batchSize(), and shark::downloadSparseData().

Referenced by main().

◆ downloadSparseData()

template<class InputType , class LabelType >
void shark::downloadSparseData ( LabeledData< InputType, LabelType > &  dataset,
std::string const &  url,
unsigned short  port = 80,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)

Download and import a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
urlhttp URL
portTCP/IP port, default is 80
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

Definition at line 89 of file Download.h.

References shark::batchSize(), shark::download(), and shark::importSparseData().

Referenced by shark::downloadFromMLData(), and main().

◆ element() [1/4]

◆ element() [2/4]

template<class Type>
const_element_reference shark::Data< Type >::element ( std::size_t  i) const
inline

Definition at line 235 of file Dataset.h.

◆ element() [3/4]

◆ element() [4/4]

template<class InputT, class LabelT>
const_element_reference shark::LabeledData< InputT, LabelT >::element ( std::size_t  i) const
inline

Definition at line 615 of file Dataset.h.

◆ elements() [1/4]

◆ elements() [2/4]

template<class Type>
element_range shark::Data< Type >::elements ( )
inline

Returns therange of elements.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 184 of file Dataset.h.

◆ elements() [3/4]

template<class InputT, class LabelT>
const_element_range shark::LabeledData< InputT, LabelT >::elements ( ) const
inline

Returns the range of elements.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 509 of file Dataset.h.

Referenced by shark::JaakkolaHeuristic::JaakkolaHeuristic().

◆ elements() [4/4]

template<class InputT, class LabelT>
element_range shark::LabeledData< InputT, LabelT >::elements ( )
inline

Returns therange of elements.

It is compatible to boost::range and STL and can be used whenever an algorithm requires element access via begin()/end() in which case data.elements() provides the correct interface

Definition at line 519 of file Dataset.h.

◆ empty() [1/2]

template<class Type>
bool shark::Data< Type >::empty ( ) const
inline

Check whether the set is empty.

Definition at line 227 of file Dataset.h.

◆ empty() [2/2]

template<class InputT, class LabelT>
bool shark::LabeledData< InputT, LabelT >::empty ( ) const
inline

◆ export_kernel_matrix() [1/2]

template<typename InputType , typename LabelType >
void shark::export_kernel_matrix ( LabeledData< InputType, LabelType > const &  dataset,
AbstractKernelFunction< InputType > &  kernel,
std::ostream &  out,
KernelMatrixNormalizationType  normalizer = NONE,
bool  scientific = false,
unsigned int  fieldwidth = 0 
)

Definition at line 297 of file ExportKernelMatrix.h.

References shark::exportKernelMatrix().

◆ export_kernel_matrix() [2/2]

template<typename InputType , typename LabelType >
void shark::export_kernel_matrix ( LabeledData< InputType, LabelType > const &  dataset,
AbstractKernelFunction< InputType > &  kernel,
std::string  fn,
KernelMatrixNormalizationType  normalizer = NONE,
bool  sci = false,
unsigned int  width = 0 
)

Definition at line 312 of file ExportKernelMatrix.h.

References shark::exportKernelMatrix().

◆ export_libsvm()

template<typename InputType >
void shark::export_libsvm ( LabeledData< InputType, unsigned int > &  dataset,
const std::string &  fn,
bool  dense = false,
bool  oneMinusOne = true,
bool  sortLabels = false,
bool  append = false 
)
inline

Export data to LIBSVM format.

Deprecated:
use exportSparseData instead
Parameters
datasetContainer storing the data
fnOutput file
denseFlag for using dense output format
oneMinusOneFlag for applying the transformation y<-2y-1 to binary labels
sortLabelsFlag for sorting data points according to labels
appendFlag for appending to the output file instead of overwriting it

Definition at line 127 of file Libsvm.h.

References shark::exportSparseData().

◆ exportCSV() [1/2]

template<typename Type >
void shark::exportCSV ( Data< Type > const &  set,
std::string  fn,
char  separator = ',',
bool  sci = true,
unsigned int  width = 0 
)

Format unlabeled data into a character-separated value file.

Parameters
setContainer to be exported
fnThe file to be written to
separatorSeparator between entries, typically a comma or a space
scishould the output be in scientific notation?
widthargument to std::setw when writing the output

Definition at line 464 of file Csv.h.

References shark::exportCSV(), and SHARK_RUNTIME_CHECK.

◆ exportCSV() [2/2]

template<typename InputType , typename LabelType >
void shark::exportCSV ( LabeledData< InputType, LabelType > const &  dataset,
std::string  fn,
LabelPosition  lp,
char  separator = ',',
bool  sci = true,
unsigned int  width = 0 
)

Format labeled data into a character-separated value file.

Parameters
datasetContainer to be exported
fnThe file to be written to
lpPosition of the label in the record, either first or last column
separatorSeparator between entries, typically a comma or a space
scishould the output be in scientific notation?
widthargument to std::setw when writing the output

Definition at line 486 of file Csv.h.

References SHARK_RUNTIME_CHECK.

Referenced by shark::exportCSV().

◆ exportKernelMatrix() [1/2]

template<typename InputType , typename LabelType >
void shark::exportKernelMatrix ( LabeledData< InputType, LabelType > const &  dataset,
AbstractKernelFunction< InputType > &  kernel,
std::ostream &  out,
KernelMatrixNormalizationType  normalizer = NONE,
bool  scientific = false,
unsigned int  fieldwidth = 0 
)

Write a kernel Gram matrix to stream.

Parameters
datasetdata basis for the Gram matrix
kernelpointer to kernel function to be used
outThe stream to be written to
normalizerwhat kind of normalization to apply. see enum declaration for details.
scientificshould the output be in scientific notation?
fieldwidthfield width for pretty printing

Definition at line 76 of file ExportKernelMatrix.h.

References shark::DataView< DatasetType >::size(), and SIZE_CHECK.

Referenced by shark::export_kernel_matrix(), and shark::exportKernelMatrix().

◆ exportKernelMatrix() [2/2]

template<typename InputType , typename LabelType >
void shark::exportKernelMatrix ( LabeledData< InputType, LabelType > const &  dataset,
AbstractKernelFunction< InputType > &  kernel,
std::string  fn,
KernelMatrixNormalizationType  normalizer = NONE,
bool  sci = false,
unsigned int  width = 0 
)

Write a kernel Gram matrix to file.

Parameters
datasetdata basis for the Gram matrix
kernelpointer to kernel function to be used
fnThe filename of the file to be written to
normalizerwhat kind of normalization to apply. see enum declaration for details.
scishould the output be in scientific notation?
widthfield width for pretty printing

Definition at line 273 of file ExportKernelMatrix.h.

References shark::exportKernelMatrix().

◆ exportSparseData() [1/4]

template<typename InputType >
void shark::exportSparseData ( LabeledData< InputType, unsigned int > const &  dataset,
std::ostream &  stream,
bool  oneMinusOne = true,
bool  sortLabels = false 
)

Export classification data to sparse data (libSVM) format.

Parameters
datasetContainer storing the data
streamOutput stream
oneMinusOneFlag for applying the transformation y<-2y-1 to binary labels
sortLabelsFlag for sorting data points according to labels

Definition at line 171 of file SparseData.h.

References shark::LabeledData< InputT, LabelT >::batch(), shark::batchSize(), shark::getBatchElement(), shark::LabeledData< InputT, LabelT >::numberOfBatches(), and shark::numberOfClasses().

Referenced by shark::export_libsvm(), and shark::exportSparseData().

◆ exportSparseData() [2/4]

template<typename InputType >
void shark::exportSparseData ( LabeledData< InputType, unsigned int > const &  dataset,
const std::string &  fn,
bool  oneMinusOne = true,
bool  sortLabels = false,
bool  append = false 
)

Export classification data to sparse data (libSVM) format.

Parameters
datasetContainer storing the data
fnOutput file name
oneMinusOneFlag for applying the transformation y<-2y-1 to binary labels
sortLabelsFlag for sorting data points according to labels
appendFlag for appending to the output file instead of overwriting it

Definition at line 213 of file SparseData.h.

References shark::exportSparseData(), and SHARK_RUNTIME_CHECK.

◆ exportSparseData() [3/4]

template<typename InputType >
void shark::exportSparseData ( LabeledData< InputType, RealVector > const &  dataset,
std::ostream &  stream 
)

Export regression data to sparse data (libSVM) format.

Parameters
datasetContainer storing the data
streamOutput stream

Definition at line 233 of file SparseData.h.

References shark::LabeledData< InputT, LabelT >::batch(), shark::batchSize(), shark::getBatchElement(), shark::LabeledData< InputT, LabelT >::numberOfBatches(), and SHARK_ASSERT.

◆ exportSparseData() [4/4]

template<typename InputType >
void shark::exportSparseData ( LabeledData< InputType, RealVector > const &  dataset,
const std::string &  fn,
bool  append = false 
)

Export regression data to sparse data (libSVM) format.

Parameters
datasetContainer storing the data
fnOutput file
appendFlag for appending to the output file instead of overwriting it

Definition at line 258 of file SparseData.h.

References shark::exportSparseData(), and SHARK_RUNTIME_CHECK.

◆ getColumn()

template<typename RowType >
RowType shark::getColumn ( Data< RowType > const &  data,
std::size_t  columnID 
)

Definition at line 1110 of file Dataset.h.

References shark::dataDimension(), and SHARK_ASSERT.

◆ getPartitioning() [1/2]

template<class Type>
std::vector<std::size_t> shark::Data< Type >::getPartitioning ( ) const
inline

Creates a vector with the batch sizes of every batch.

This method can be used together with repartition to ensure that two datasets have the same batch structure.

Definition at line 326 of file Dataset.h.

◆ getPartitioning() [2/2]

template<class InputT, class LabelT>
std::vector<std::size_t> shark::LabeledData< InputT, LabelT >::getPartitioning ( ) const
inline

Creates a vector with the batch sizes of every batch.

This method can be used together with repartition to ensure that two datasets have the same batch structure.

Definition at line 723 of file Dataset.h.

◆ import_libsvm() [1/4]

void shark::import_libsvm ( LabeledData< RealVector, unsigned int > &  dataset,
std::istream &  stream,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)
inline

Import data from a LIBSVM file.

Deprecated:
use importSparseData instead
Parameters
datasetcontainer storing the loaded data
streamstream to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

Definition at line 59 of file Libsvm.h.

References shark::batchSize(), and shark::importSparseData().

◆ import_libsvm() [2/4]

void shark::import_libsvm ( LabeledData< CompressedRealVector, unsigned int > &  dataset,
std::istream &  stream,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)
inline

Import data from a LIBSVM file.

Deprecated:
use importSparseData instead
Parameters
datasetcontainer storing the loaded data
streamstream to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

Definition at line 75 of file Libsvm.h.

References shark::batchSize(), and shark::importSparseData().

◆ import_libsvm() [3/4]

void shark::import_libsvm ( LabeledData< RealVector, unsigned int > &  dataset,
std::string  fn,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)
inline

Import data from a LIBSVM file.

Deprecated:
use importSparseData instead
Parameters
datasetcontainer storing the loaded data
fnthe file to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

Definition at line 91 of file Libsvm.h.

References shark::batchSize(), and shark::importSparseData().

◆ import_libsvm() [4/4]

void shark::import_libsvm ( LabeledData< CompressedRealVector, unsigned int > &  dataset,
std::string  fn,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)
inline

Import data from a LIBSVM file.

Deprecated:
use importSparseData instead
Parameters
datasetcontainer storing the loaded data
fnthe file to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

Definition at line 107 of file Libsvm.h.

References shark::batchSize(), and shark::importSparseData().

◆ importCSV() [1/3]

template<class T >
void shark::importCSV ( Data< T > &  data,
std::string  fn,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = Data<T>::DefaultBatchSize,
std::size_t  titleLines = 0 
)

Import a Dataset from a csv file.

Parameters
dataContainer storing the loaded data
fnThe file to be read from
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
maximumBatchSizeSize of batches in the dataset
titleLinesSpecifies a number of lines to be skipped in the beginning of the file

Definition at line 369 of file Csv.h.

References SHARK_RUNTIME_CHECK.

Referenced by getSamples(), loadData(), and main().

◆ importCSV() [2/3]

template<class T >
void shark::importCSV ( LabeledData< blas::vector< T >, unsigned int > &  data,
std::string  fn,
LabelPosition  lp,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = LabeledData<RealVector, unsigned int>::DefaultBatchSize 
)

Import a labeled Dataset from a csv file.

Parameters
dataContainer storing the loaded data
fnThe file to be read from
lpPosition of the label in the record, either first or last column
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
maximumBatchSizeSize of batches in the dataset

Definition at line 403 of file Csv.h.

References shark::csvStringToData(), and SHARK_RUNTIME_CHECK.

◆ importCSV() [3/3]

template<class T >
void shark::importCSV ( LabeledData< blas::vector< T >, blas::vector< T > > &  data,
std::string  fn,
LabelPosition  lp,
std::size_t  numberOfOutputs = 1,
char  separator = ',',
char  comment = '#',
std::size_t  maximumBatchSize = LabeledData<RealVector, RealVector>::DefaultBatchSize 
)

Import a labeled Dataset from a csv file.

Parameters
dataContainer storing the loaded data
fnThe file to be read from
lpPosition of the label in the record, either first or last column
numberOfOutputsdimensionality of the labels
separatorOptional separator between entries, typically a comma, spaces ar automatically ignored
commentTrailing character indicating comment line. By dfault it is '#'
maximumBatchSizeSize of batches in the dataset

Definition at line 434 of file Csv.h.

References shark::csvStringToData(), and SHARK_RUNTIME_CHECK.

◆ importSparseData() [1/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< RealVector, unsigned int > &  dataset,
std::istream &  stream,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, unsigned int >::DefaultBatchSize 
)

Import classification data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
streamstream to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

Referenced by shark::downloadSparseData(), shark::import_libsvm(), and main().

◆ importSparseData() [2/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< RealVector, RealVector > &  dataset,
std::istream &  stream,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, RealVector >::DefaultBatchSize 
)

Import regression data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
streamstream to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ importSparseData() [3/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< CompressedRealVector, unsigned int > &  dataset,
std::istream &  stream,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, unsigned int >::DefaultBatchSize 
)

Import classification data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
streamstream to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ importSparseData() [4/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< CompressedRealVector, RealVector > &  dataset,
std::istream &  stream,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, RealVector >::DefaultBatchSize 
)

Import regression data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
streamstream to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ importSparseData() [5/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< RealVector, unsigned int > &  dataset,
std::string  fn,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, unsigned int >::DefaultBatchSize 
)

Import classification data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
fnthe file to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ importSparseData() [6/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< RealVector, RealVector > &  dataset,
std::string  fn,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, RealVector >::DefaultBatchSize 
)

Import regression data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
fnthe file to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ importSparseData() [7/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< CompressedRealVector, unsigned int > &  dataset,
std::string  fn,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, unsigned int >::DefaultBatchSize 
)

Import classification data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
fnthe file to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ importSparseData() [8/8]

SHARK_EXPORT_SYMBOL void shark::importSparseData ( LabeledData< CompressedRealVector, RealVector > &  dataset,
std::string  fn,
unsigned int  highestIndex = 0,
std::size_t  batchSize = LabeledData< RealVector, RealVector >::DefaultBatchSize 
)

Import regression data from a sparse data (libSVM) file.

Parameters
datasetcontainer storing the loaded data
fnthe file to be read from
highestIndexhighest feature index, or 0 for auto-detection
batchSizesize of batch

◆ indexedSubset() [1/3]

template<class Type>
void shark::Data< Type >::indexedSubset ( IndexSet const &  indices,
Data< Type > &  subset,
Data< Type > &  complement 
) const
inline

Fill in the subset defined by the list of indices as well as its complement.

Definition at line 333 of file Dataset.h.

◆ indexedSubset() [2/3]

template<class Type>
Data shark::Data< Type >::indexedSubset ( IndexSet const &  indices) const
inline

Definition at line 340 of file Dataset.h.

◆ indexedSubset() [3/3]

template<class InputT, class LabelT>
LabeledData shark::LabeledData< InputT, LabelT >::indexedSubset ( IndexSet const &  indices) const
inline

Fill in the subset defined by the list of indices.

Definition at line 736 of file Dataset.h.

Referenced by main().

◆ initRandomNormal()

template<class InputType , class OutputType >
void shark::initRandomNormal ( AbstractModel< InputType, OutputType > &  model,
double  s 
)

Initialize model parameters normally distributed.

Parameters
modelmodel to be initialized
svariance of mean-free normal distribution

Definition at line 282 of file AbstractModel.h.

References shark::random::gauss(), shark::random::globalRng, shark::IParameterizable< ParameterType >::numberOfParameters(), and shark::IParameterizable< ParameterType >::setParameterVector().

Referenced by main(), and unsupervisedPreTraining().

◆ initRandomUniform()

template<class InputType , class OutputType >
void shark::initRandomUniform ( AbstractModel< InputType, OutputType > &  model,
double  lower,
double  upper 
)

Initialize model parameters uniformly at random.

Parameters
modelmodel to be initialized
lowerlower bound of initialization interval
upperupper bound of initialization interval

Definition at line 295 of file AbstractModel.h.

References shark::random::globalRng, shark::IParameterizable< ParameterType >::numberOfParameters(), shark::AbstractModel< InputTypeT, OutputTypeT, ParameterType >::outputShape(), shark::IParameterizable< ParameterType >::setParameterVector(), and shark::random::uni().

Referenced by experiment(), main(), trainAutoencoderModel(), trainProblem(), and trainRBM().

◆ inputDimension()

◆ inputs() [1/4]

template<class InputT>
UnlabeledData& shark::UnlabeledData< InputT >::inputs ( )
inline

Access to the base_type class as "inputs".

Added for consistency with the LabeledData::labels() method.

Definition at line 425 of file Dataset.h.

◆ inputs() [2/4]

template<class InputT>
UnlabeledData const& shark::UnlabeledData< InputT >::inputs ( ) const
inline

Access to the base_type class as "inputs".

Added for consistency with the LabeledData::labels() method.

Definition at line 432 of file Dataset.h.

◆ inputs() [3/4]

◆ inputs() [4/4]

template<class InputT, class LabelT>
InputContainer& shark::LabeledData< InputT, LabelT >::inputs ( )
inline

Access to inputs as a separate container.

Definition at line 560 of file Dataset.h.

◆ inputShape() [1/2]

template<class InputT, class LabelT>
Shape const& shark::LabeledData< InputT, LabelT >::inputShape ( ) const
inline

◆ inputShape() [2/2]

template<class InputT, class LabelT>
Shape& shark::LabeledData< InputT, LabelT >::inputShape ( )
inline

Returns the Shape of the inputs.

Definition at line 633 of file Dataset.h.

◆ labelDimension()

template<class InputType , class LabelType >
std::size_t shark::labelDimension ( LabeledData< InputType, LabelType > const &  dataset)

◆ LabeledData() [1/4]

template<class InputT, class LabelT>
shark::LabeledData< InputT, LabelT >::LabeledData ( )
inline

Empty data set.

Definition at line 576 of file Dataset.h.

◆ LabeledData() [2/4]

template<class InputT, class LabelT>
shark::LabeledData< InputT, LabelT >::LabeledData ( std::size_t  numBatches)
inline

Create an empty set with just the correct number of batches.

The user must initialize the dataset after that by himself.

Definition at line 582 of file Dataset.h.

◆ LabeledData() [3/4]

template<class InputT, class LabelT>
shark::LabeledData< InputT, LabelT >::LabeledData ( std::size_t  size,
element_type const &  element,
std::size_t  batchSize = DefaultBatchSize 
)
inline

Optionally the desired batch Size can be set

Parameters
sizethe new size of the container
elementthe blueprint element from which to create the Container
batchSizethe size of the batches. if this is 0, the size is unlimited

Definition at line 592 of file Dataset.h.

◆ LabeledData() [4/4]

template<class InputT, class LabelT>
shark::LabeledData< InputT, LabelT >::LabeledData ( Data< InputType > const &  inputs,
Data< LabelType > const &  labels 
)
inline

Construction from data.

Beware that when calling this constructor the organization of batches must be equal in both containers. This Constructor will not split the data!

Definition at line 601 of file Dataset.h.

◆ labels() [1/2]

◆ labels() [2/2]

template<class InputT, class LabelT>
LabelContainer& shark::LabeledData< InputT, LabelT >::labels ( )
inline

Access to labels as a separate container.

Definition at line 569 of file Dataset.h.

◆ labelShape() [1/2]

template<class InputT, class LabelT>
Shape const& shark::LabeledData< InputT, LabelT >::labelShape ( ) const
inline

Returns the Shape of the labels.

Definition at line 638 of file Dataset.h.

Referenced by shark::bootstrap().

◆ labelShape() [2/2]

template<class InputT, class LabelT>
Shape& shark::LabeledData< InputT, LabelT >::labelShape ( )
inline

Returns the Shape of the labels.

Definition at line 643 of file Dataset.h.

◆ makeIndependent() [1/2]

template<class Type>
virtual void shark::Data< Type >::makeIndependent ( )
inlinevirtual

This method makes the vector independent of all siblings and parents.

Definition at line 279 of file Dataset.h.

Referenced by main().

◆ makeIndependent() [2/2]

template<class InputT, class LabelT>
virtual void shark::LabeledData< InputT, LabelT >::makeIndependent ( )
inlinevirtual

This method makes the vector independent of all siblings and parents.

Definition at line 662 of file Dataset.h.

Referenced by main().

◆ maxExpInput()

template<class T >
T shark::maxExpInput ( )

Maximum allowed input value for exp.

Definition at line 70 of file Math.h.

◆ minExpInput()

template<class T >
T shark::minExpInput ( )

Minimum value for exp(x) allowed so that it is not 0.

Definition at line 75 of file Math.h.

◆ numberOfBatches() [1/2]

◆ numberOfBatches() [2/2]

template<class InputT, class LabelT>
std::size_t shark::LabeledData< InputT, LabelT >::numberOfBatches ( ) const
inline

Returns the number of batches of the set.

Definition at line 542 of file Dataset.h.

Referenced by shark::KernelTargetAlignment< InputType, LabelType >::evalDerivative(), shark::exportSparseData(), and shark::repartitionByClass().

◆ numberOfClasses() [1/2]

◆ numberOfClasses() [2/2]

template<class InputType >
std::size_t shark::numberOfClasses ( LabeledData< InputType, unsigned int > const &  dataset)

Return the number of classes (highest label value +1) of a classification dataset with unsigned int label encoding.

Definition at line 895 of file Dataset.h.

References shark::LabeledData< InputT, LabelT >::labels(), and shark::numberOfClasses().

◆ numberOfElements() [1/2]

template<class Type>
std::size_t shark::Data< Type >::numberOfElements ( ) const
inline

Returns the total number of elements.

Definition at line 211 of file Dataset.h.

Referenced by shark::ProjectBudgetMaintenanceStrategy< RealVector >::addToModel(), shark::MergeBudgetMaintenanceStrategy< RealVector >::addToModel(), shark::bootstrap(), shark::calculateMixedKernelMatrix(), shark::calculateRegularizedKernelMatrix(), shark::CSVMProblem< MatrixT >::CSVMProblem(), shark::dataDimension(), shark::Data< LabelT >::elements(), shark::LabeledData< InputType, LabelType >::elements(), shark::ExactGradient< RBMType >::eval(), shark::ZeroOneLoss< unsigned int, RealVector >::eval(), shark::NegativeAUC< LabelType, OutputType >::eval(), shark::AbstractLoss< unsigned int, RealVector >::eval(), shark::NegativeWilcoxonMannWhitneyStatistic< LabelType, OutputType >::eval(), shark::NegativeLogLikelihood::evalDerivative(), shark::SingleChainApproximator< MarkovChainType >::evalDerivative(), shark::ExampleModifiedKernelMatrix< InputType, CacheType >::ExampleModifiedKernelMatrix(), shark::exportFiltersToPGMGrid(), shark::GaussianKernelMatrix< T, CacheType >::GaussianKernelMatrix(), shark::GeneralQuadraticProblem< MatrixT >::GeneralQuadraticProblem(), getSamples(), shark::KernelMatrix< InputType, CacheType >::KernelMatrix(), shark::LabeledData< InputType, LabelType >::LabeledData(), main(), shark::QpMcBoxDecomp< Matrix >::QpMcBoxDecomp(), shark::QpMcSimplexDecomp< Matrix >::QpMcSimplexDecomp(), shark::MergeBudgetMaintenanceStrategy< RealVector >::reduceBudget(), shark::setColumn(), shark::MultiChainApproximator< MarkovChainType >::setData(), shark::KernelExpansion< InputType >::setStructure(), shark::KernelExpansion< InputType >::sparsify(), shark::NormalizeComponentsZCA::train(), shark::NormalizeKernelUnitVariance< InputType >::train(), and shark::RankingSvmTrainer< InputType, CacheType >::train().

◆ numberOfElements() [2/2]

◆ oneVersusRestProblem()

template<class I >
LabeledData<I,unsigned int> shark::oneVersusRestProblem ( LabeledData< I, unsigned int >const &  data,
unsigned int  oneClass 
)

Construct a binary (two-class) one-versus-rest problem from a multi-class problem.

The function returns a new LabeledData object. The input part coincides with the multi-class data, but the label part is replaced with binary labels 0 and 1. All instances of the given class (parameter oneClass) get a label of one, all others are assigned a label of zero.

Definition at line 1102 of file Dataset.h.

References shark::transformLabels().

Referenced by shark::CSvmTrainer< InputType, CacheType >::get_db_dParams().

◆ operator!=()

template<class Type>
template<class T >
bool shark::Data< Type >::operator!= ( const Data< T > &  rhs)
inline

Two containers compare unequal if they don't share the same data.

Definition at line 157 of file Dataset.h.

◆ operator<<() [1/2]

template<class T >
std::ostream& shark::operator<< ( std::ostream &  stream,
const Data< T > &  d 
)

Outstream of elements.

Definition at line 360 of file Dataset.h.

◆ operator<<() [2/2]

template<class T , class U >
std::ostream& shark::operator<< ( std::ostream &  stream,
const LabeledData< T, U > &  d 
)

brief Outstream of elements for labeled data.

Definition at line 845 of file Dataset.h.

◆ operator=()

template<class InputT>
UnlabeledData shark::UnlabeledData< InputT >::operator= ( Data< InputT > const &  data)
inline

we allow assignment from Data.

Definition at line 417 of file Dataset.h.

◆ operator==()

template<class Type>
template<class T >
bool shark::Data< Type >::operator== ( const Data< T > &  rhs)
inline

Two containers compare equal if they share the same data.

Definition at line 152 of file Dataset.h.

◆ push_back() [1/3]

template<class Type>
void shark::Data< Type >::push_back ( const_batch_reference  batch)
inline

Definition at line 309 of file Dataset.h.

Referenced by shark::LabeledData< InputType, LabelType >::push_back().

◆ push_back() [2/3]

template<class InputT, class LabelT>
void shark::LabeledData< InputT, LabelT >::push_back ( typename Batch< InputType >::type const &  inputs,
typename Batch< LabelType >::type const &  labels 
)
inline

Definition at line 694 of file Dataset.h.

◆ push_back() [3/3]

template<class InputT, class LabelT>
void shark::LabeledData< InputT, LabelT >::push_back ( const_batch_reference  batch)
inline

Definition at line 702 of file Dataset.h.

◆ randomRotationMatrix() [1/2]

template<class MatrixT >
void shark::blas::randomRotationMatrix ( random::rng_type &  rng,
matrix_container< MatrixT, cpu_tag > &  matrixC 
)

Initializes a matrix such that it forms a random rotation matrix.

The matrix needs to be quadratic and have the proper size (e.g. call matrix::resize before).

One common way to do this is using Gram-Schmidt-Orthogonalisation on a matrix which is initialized with gaussian numbers. However, this is highly unstable for big matrices.

This algorithm is implemented from one of the algorithms presented in Francesco Mezzadri "How to generate random matrices from the classical compact groups" http://arxiv.org/abs/math-ph/0609050v2

He gives two algorithms: the first one uses QR decomposition on the random gaussian matrix and ensures that the signs of Q are correct by multiplying every column of Q with the sign of the diagonal of R.

We use another algorithm implemented in the paper which works similarly, but reversed. We apply Householder rotations H_N H_{N-1}..H_1 where H_1 is generated from a random vector on the n-dimensional unit sphere. this requires less operations and is thus preferable. Also only half the random numbers need to be generated

Definition at line 168 of file rotations.h.

References SIZE_CHECK.

Referenced by shark::RotatedObjectiveFunction::init(), shark::CIGTAB1::init(), shark::IHR4::init(), shark::IHR3::init(), shark::CIGTAB2::init(), shark::IHR1::init(), shark::IHR2::init(), shark::ELLI1::init(), shark::ELLI2::init(), shark::IHR6::init(), and shark::blas::randomRotationMatrix().

◆ randomRotationMatrix() [2/2]

RealMatrix shark::blas::randomRotationMatrix ( random::rng_type &  rng,
size_t  size 
)

Creates a random rotation matrix with a certain size using the random number generator rng.

Definition at line 198 of file rotations.h.

References shark::blas::randomRotationMatrix().

◆ read() [1/2]

template<class Type>
void shark::Data< Type >::read ( InArchive archive)
inlinevirtual

Read the component from the supplied archive.

Parameters
[in,out]archiveThe archive to read from.

Reimplemented from shark::ISerializable.

Definition at line 269 of file Dataset.h.

◆ read() [2/2]

template<class InputT, class LabelT>
void shark::LabeledData< InputT, LabelT >::read ( InArchive archive)
inlinevirtual

from ISerializable

Reimplemented from shark::ISerializable.

Definition at line 650 of file Dataset.h.

◆ repartition() [1/2]

template<class Type>
template<class Range >
void shark::Data< Type >::repartition ( Range const &  batchSizes)
inline

Reorders the batch structure in the container to that indicated by the batchSizes vector.

After the operation the container will contain batchSizes.size() batchs with the i-th batch having size batchSize[i]. However the sum of all batch sizes must be equal to the current number of elements

Definition at line 318 of file Dataset.h.

◆ repartition() [2/2]

template<class InputT, class LabelT>
template<class Range >
void shark::LabeledData< InputT, LabelT >::repartition ( Range const &  batchSizes)
inline

Reorders the batch structure in the container to that indicated by the batchSizes vector.

After the operation the container will contain batchSizes.size() batches with the i-th batch having size batchSize[i]. However the sum of all batch sizes must be equal to the current number of elements

Definition at line 714 of file Dataset.h.

Referenced by shark::repartitionByClass().

◆ repartitionByClass()

template<class I >
void shark::repartitionByClass ( LabeledData< I, unsigned int > &  data,
std::size_t  batchSize = LabeledData<I,unsigned int>::DefaultBatchSize 
)

reorders the dataset such, that points are grouped by labels

The elements are not only reordered but the batches are also resized such, that every batch only contains elements of one class. This method must be used in order to use binarySubproblem.

Definition at line 1016 of file Dataset.h.

References shark::Data< Type >::batch(), shark::LabeledData< InputT, LabelT >::batch(), shark::batchSize(), shark::classSizes(), shark::LabeledData< InputT, LabelT >::numberOfBatches(), shark::LabeledData< InputT, LabelT >::repartition(), shark::swap(), and shark::Data< Type >::swap.

Referenced by main().

◆ safeExp()

template<class T >
T shark::safeExp ( x)

Thresholded exp function, over- and underflow safe.

Replaces the value of exp(x) for numerical reasons by the a threshold value if it gets too large. Use it only, if there is no other way to get the function stable!

Parameters
xthe exponent

Definition at line 112 of file Math.h.

◆ safeLog()

template<class T >
T shark::safeLog ( x)

Thresholded log function, over- and underflow safe.

Replaces the value of log(x) for numerical reasons by the a threshold value if it gets too low. Use it only, if there is no other way to get the function stable!

Parameters
xthe exponent

Definition at line 127 of file Math.h.

◆ selectFeatures()

template<class T , class FeatureSet >
Data<blas::vector<T> > shark::selectFeatures ( Data< blas::vector< T > > const &  data,
FeatureSet const &  features 
)

Creates a copy of a dataset selecting only a certain set of features.

Definition at line 965 of file Dataset.h.

References shark::transform().

Referenced by shark::selectInputFeatures().

◆ selectInputFeatures()

template<class T , class FeatureSet >
LabeledData<RealVector,T> shark::selectInputFeatures ( LabeledData< RealVector, T > const &  data,
FeatureSet const &  features 
)

◆ setColumn()

template<typename RowType >
void shark::setColumn ( Data< RowType > &  data,
std::size_t  columnID,
RowType  newColumn 
)

◆ shape() [1/2]

template<class Type>
Shape const& shark::Data< Type >::shape ( ) const
inline

Returns the shape of the elements in the dataset.

Definition at line 217 of file Dataset.h.

Referenced by shark::bootstrap(), shark::createDataFromRange(), main(), and shark::transform().

◆ shape() [2/2]

template<class Type>
Shape& shark::Data< Type >::shape ( )
inline

Returns the shape of the elements in the dataset.

Definition at line 222 of file Dataset.h.

◆ shuffle() [1/2]

template<class InputT>
virtual void shark::UnlabeledData< InputT >::shuffle ( )
inlinevirtual

shuffles all elements in the entire dataset (that is, also across the batches)

Definition at line 448 of file Dataset.h.

◆ shuffle() [2/2]

template<class InputT, class LabelT>
virtual void shark::LabeledData< InputT, LabelT >::shuffle ( )
inlinevirtual

shuffles all elements in the entire dataset (that is, also across the batches)

Definition at line 668 of file Dataset.h.

Referenced by main().

◆ sigmoid()

template<class T >
boost::enable_if<std::is_arithmetic<T>, T>::type shark::sigmoid ( x)

Logistic function/logistic function.

Calculates the sigmoid function 1/(1+exp(-x)). The type must be arithmetic. For example float,double,long double, int,... but no custom Type.

Definition at line 95 of file Math.h.

Referenced by shark::CrossEntropy::evalDerivative().

◆ softPlus() [1/2]

template<class T >
boost::enable_if<std::is_arithmetic<T>, T>::type shark::softPlus ( x)

Numerically stable version of the function log(1+exp(x)).

Numerically stable version of the function log(1+exp(x)). This function is the integral of the famous sigmoid function. The type must be arithmetic. For example float,double,long double, int,... but no custom Type.

Definition at line 147 of file Math.h.

Referenced by shark::BipolarLayer::logMarginalize(), and shark::BinaryLayer::logMarginalize().

◆ softPlus() [2/2]

double shark::softPlus ( double  x)
inline

Numerically stable version of the function log(1+exp(x)). calculated with float precision to save some time.

Numerically stable version of the function log(1+exp(x)). This function is the integral of the famous sigmoid function.

Definition at line 161 of file Math.h.

◆ splice() [1/3]

template<class Type>
Data shark::Data< Type >::splice ( std::size_t  batch)
inline

Splits the container into two independent parts. The front part remains in the container, the back part is returned.

Order of elements remain unchanged. The SharedVector is not allowed to be shared for this to work.

Definition at line 294 of file Dataset.h.

◆ splice() [2/3]

template<class InputT>
UnlabeledData shark::UnlabeledData< InputT >::splice ( std::size_t  batch)
inline

Splits the container in two independent parts. The left part remains in the container, the right is stored as return type.

Order of elements remain unchanged. The SharedVector is not allowed to be shared for this to work.

Definition at line 440 of file Dataset.h.

◆ splice() [3/3]

template<class InputT, class LabelT>
LabeledData shark::LabeledData< InputT, LabelT >::splice ( std::size_t  batch)
inline

Splits the container into two independent parts. The left part remains in the container, the right is stored as return type.

Order of elements remain unchanged. The SharedVector is not allowed to be shared for this to work.

Definition at line 681 of file Dataset.h.

Referenced by main().

◆ splitAtElement()

template<class DatasetT >
DatasetT shark::splitAtElement ( DatasetT &  data,
std::size_t  elementIndex 
)

Removes the last part of a given dataset and returns a new split containing the removed elements.

For this operation, the dataset is not allowed to be shared. data The dataset which should be splited index the first element to be split

Returns
the set which contains the splitd element (right part of the given set)

Definition at line 992 of file Dataset.h.

References shark::batchSize(), and SIZE_CHECK.

Referenced by main().

◆ splitBatch() [1/2]

template<class Type>
void shark::Data< Type >::splitBatch ( std::size_t  batch,
std::size_t  elementIndex 
)
inline

Definition at line 286 of file Dataset.h.

◆ splitBatch() [2/2]

template<class InputT, class LabelT>
void shark::LabeledData< InputT, LabelT >::splitBatch ( std::size_t  batch,
std::size_t  elementIndex 
)
inline

Definition at line 672 of file Dataset.h.

◆ splitUrl()

SHARK_EXPORT_SYMBOL std::pair<std::string, std::string> shark::splitUrl ( std::string const &  url)

Split a URL into its domain and resource parts.

Returns a std::pair where the first element is the domain and the second is the resource. With std::tie you can do pattern-matching: std::tie(domain, resource) = splitUrl(url); will fill the std::string variables domain and resource.

◆ sqr()

◆ transform() [1/2]

template<class T , class Functor >
boost::lazy_disable_if< CanBeCalled<Functor,typename Data<T>::batch_type>, TransformedData<Functor,T>>::type shark::transform ( Data< T > const &  data,
Functor  f 
)

◆ transform() [2/2]

template<class T , class Functor >
boost::lazy_enable_if< CanBeCalled<Functor,typename Data<T>::batch_type>, TransformedData<Functor,T>>::type shark::transform ( Data< T > const &  data,
Functor const &  f 
)

Transforms a dataset using a Functor f and returns the transformed result.

this version is used, when the Functor supports batch-by-batch transformations

Definition at line 934 of file Dataset.h.

References shark::Data< Type >::batch(), shark::Data< Type >::batches(), shark::Data< Type >::numberOfBatches(), shark::Data< Type >::shape(), and SHARK_PARALLEL_FOR.

◆ transformInputs()

template<class I , class L , class Functor >
LabeledData<typename detail::TransformedDataElement<Functor,I >::type, L > shark::transformInputs ( LabeledData< I, L > const &  data,
Functor const &  f 
)

Transforms the inputs of a dataset and return the transformed result.

Definition at line 951 of file Dataset.h.

References shark::LabeledData< InputT, LabelT >::inputs(), shark::LabeledData< InputT, LabelT >::labels(), and shark::transform().

Referenced by main(), and run_one_trial().

◆ transformLabels()

template<class I , class L , class Functor >
LabeledData<I,typename detail::TransformedDataElement<Functor,L >::type > shark::transformLabels ( LabeledData< I, L > const &  data,
Functor const &  f 
)

Transforms the labels of a dataset and returns the transformed result.

Definition at line 958 of file Dataset.h.

References shark::LabeledData< InputT, LabelT >::inputs(), shark::LabeledData< InputT, LabelT >::labels(), and shark::transform().

Referenced by main(), and shark::oneVersusRestProblem().

◆ UnlabeledData() [1/5]

template<class InputT>
shark::UnlabeledData< InputT >::UnlabeledData ( )
inline

Constructor.

Definition at line 386 of file Dataset.h.

◆ UnlabeledData() [2/5]

template<class InputT>
shark::UnlabeledData< InputT >::UnlabeledData ( Data< InputT > const &  points)
inline

Construction from data.

Definition at line 390 of file Dataset.h.

◆ UnlabeledData() [3/5]

template<class InputT>
shark::UnlabeledData< InputT >::UnlabeledData ( std::size_t  size,
element_type const &  element,
std::size_t  batchSize = base_type::DefaultBatchSize 
)
inline

Construction with size and a single element.

Optionally the desired batch Size can be set

Parameters
sizethe new size of the container
elementthe blueprint element from which to create the Container
batchSizethe size of the batches. if this is 0, the size is unlimited

Definition at line 401 of file Dataset.h.

◆ UnlabeledData() [4/5]

template<class InputT>
shark::UnlabeledData< InputT >::UnlabeledData ( std::size_t  numBatches)
inline

Create an empty set with just the correct number of batches.

The user must initialize the dataset after that by himself.

Definition at line 408 of file Dataset.h.

◆ UnlabeledData() [5/5]

template<class InputT>
shark::UnlabeledData< InputT >::UnlabeledData ( UnlabeledData< InputT > const &  container,
std::vector< std::size_t >  batchSizes 
)
inline

Construct a dataset with different batch sizes. it is a copy of the other dataset.

Definition at line 413 of file Dataset.h.

◆ write() [1/2]

template<class Type>
void shark::Data< Type >::write ( OutArchive archive) const
inlinevirtual

Write the component to the supplied archive.

Parameters
[in,out]archiveThe archive to write to.

Reimplemented from shark::ISerializable.

Definition at line 274 of file Dataset.h.

◆ write() [2/2]

template<class InputT, class LabelT>
void shark::LabeledData< InputT, LabelT >::write ( OutArchive archive) const
inlinevirtual

from ISerializable

Reimplemented from shark::ISerializable.

Definition at line 656 of file Dataset.h.

Variable Documentation

◆ DefaultBatchSize

template<class InputT, class LabelT>
const std::size_t shark::LabeledData< InputT, LabelT >::DefaultBatchSize = InputContainer::DefaultBatchSize
static

Definition at line 476 of file Dataset.h.

◆ m_data [1/2]

◆ m_data [2/2]

template<class InputT, class LabelT>
InputContainer shark::LabeledData< InputT, LabelT >::m_data
protected

Definition at line 740 of file Dataset.h.

Referenced by shark::LabeledData< InputType, LabelType >::append().

◆ m_label

template<class InputT, class LabelT>
LabelContainer shark::LabeledData< InputT, LabelT >::m_label
protected

point data

Definition at line 741 of file Dataset.h.

Referenced by shark::LabeledData< InputType, LabelType >::append().

◆ m_shape

◆ SQRT_2_PI

const double shark::SQRT_2_PI = boost::math::constants::root_two_pi<double>()
static

Constant for sqrt( 2 * pi ).

Definition at line 65 of file Math.h.

Referenced by shark::GaussianLayer::logMarginalize().

Friends

◆ LabeledData

template<class Type>
template<class InputT , class LabelT >
friend class LabeledData
friend

◆ swap [1/2]

template<class Type>
void swap ( Data< Type > &  a,
Data< Type > &  b 
)
friend

Definition at line 347 of file Dataset.h.

Referenced by shark::repartitionByClass().

◆ swap [2/2]

template<class InputT, class LabelT>
void swap ( LabeledData< InputT, LabelT > &  a,
LabeledData< InputT, LabelT > &  b 
)
friend

Definition at line 727 of file Dataset.h.