mlpack
3.4.2
mlpack-3.4.2
src
mlpack
methods
cf
interpolation_policies
average_interpolation.hpp
Go to the documentation of this file.
1
12
#ifndef MLPACK_METHODS_CF_AVERAGE_INTERPOLATION_HPP
13
#define MLPACK_METHODS_CF_AVERAGE_INTERPOLATION_HPP
14
15
#include <
mlpack/prereqs.hpp
>
16
17
namespace
mlpack
{
18
namespace
cf {
19
39
class
AverageInterpolation
40
{
41
public
:
42
// Empty constructor.
43
AverageInterpolation
() { }
44
48
AverageInterpolation
(
const
arma::sp_mat&
/* cleanedData */
) { }
49
63
template
<
typename
VectorType,
64
typename
DecompositionPolicy>
65
void
GetWeights
(VectorType&& weights,
66
const
DecompositionPolicy&
/* decomposition */
,
67
const
size_t
/* queryUser */
,
68
const
arma::Col<size_t>& neighbors,
69
const
arma::vec&
/* similarities */
,
70
const
arma::sp_mat&
/* cleanedData */
)
71
{
72
if
(neighbors.n_elem == 0)
73
{
74
Log::Fatal
<<
"Require: neighbors.n_elem > 0. There should be at "
75
<<
"least one neighbor!"
<< std::endl;
76
}
77
78
if
(weights.n_elem != neighbors.n_elem)
79
{
80
Log::Fatal
<<
"The size of the first parameter (weights) should "
81
<<
"be set to the number of neighbors before calling GetWeights()."
82
<< std::endl;
83
}
84
85
weights.fill(1.0 / neighbors.n_elem);
86
}
87
};
88
89
}
// namespace cf
90
}
// namespace mlpack
91
92
#endif
prereqs.hpp
The core includes that mlpack expects; standard C++ includes and Armadillo.
mlpack::cf::AverageInterpolation::AverageInterpolation
AverageInterpolation()
Definition:
average_interpolation.hpp:43
mlpack
Linear algebra utility functions, generally performed on matrices or vectors.
Definition:
add_to_cli11.hpp:21
mlpack::cf::AverageInterpolation::AverageInterpolation
AverageInterpolation(const arma::sp_mat &)
This constructor is needed for interface consistency.
Definition:
average_interpolation.hpp:48
mlpack::Log::Fatal
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Definition:
log.hpp:90
mlpack::cf::AverageInterpolation::GetWeights
void GetWeights(VectorType &&weights, const DecompositionPolicy &, const size_t, const arma::Col< size_t > &neighbors, const arma::vec &, const arma::sp_mat &)
Interoplation weights are identical and sum up to one.
Definition:
average_interpolation.hpp:65
mlpack::cf::AverageInterpolation
This class performs average interpolation to generate interpolation weights for neighborhood-based co...
Definition:
average_interpolation.hpp:40
Generated by
1.8.20