6 #ifndef TURI_STANDARDIZATION_H_ 7 #define TURI_STANDARDIZATION_H_ 10 #include <core/data/flexible_type/flexible_type.hpp> 14 #include <Eigen/SparseCore> 17 #include <ml/optimization/optimization_interface.hpp> 20 #include <ml/ml_data/ml_data.hpp> 21 #include <ml/ml_data/metadata.hpp> 28 namespace supervised {
122 virtual void transform(DenseVector &point)
const = 0;
151 virtual void transform(SparseVector &point)
const = 0;
242 const std::shared_ptr<ml_metadata> & ml_mdata,
243 bool _use_reference =
true) {
246 use_reference = _use_reference;
248 for(
size_t i = 0; i < ml_mdata->num_columns(); i++){
249 if (ml_mdata->is_categorical(i)) {
250 total_size += ml_mdata->index_size(i) - use_reference;
261 for(
size_t i = 0; i < ml_mdata->num_columns(); i++) {
263 const auto& stats = ml_mdata->statistics(i);
264 bool skip_first = (use_reference && ml_mdata->is_categorical(i));
276 for (
size_t k = skip_first ? 1 : 0; k < ml_mdata->index_size(i); ++k) {
277 double r = std::pow(stats->mean(k), 2) + std::pow(stats->stdev(k), 2);
297 point = point.cwiseQuotient(scale);
309 for (
size_t i = 0; i < size_t(points.rows()); i++) {
310 points.row(i) = points.row(i).cwiseQuotient(scale.transpose());
322 point = point.cwiseProduct(scale);
336 for (SparseVector::InnerIterator i(point); i; ++i){
337 i.valueRef() = i.value() * scale(i.index());
350 for (SparseVector::InnerIterator i(point); i; ++i){
351 i.valueRef() = i.value() / scale(i.index());
void transform(DenseMatrix &points) const
The serialization input archive object which, provided with a reference to an istream, will read from the istream, providing deserialization capabilities.
const double OPTIMIZATION_ZERO
Optimization method zero.
void transform(DenseVector &point) const
void save(turi::oarchive &oarc) const
void load(turi::iarchive &iarc)
virtual void load(turi::iarchive &iarc)=0
virtual void transform(DenseVector &point) const =0
virtual ~standardization_interface()=default
standardization_interface()=default
size_t get_total_size() const
void inverse_transform(DenseVector &point) const
virtual void save(turi::oarchive &oarc) const =0
void inverse_transform(SparseVector &point) const
l2_rescaling(const std::shared_ptr< ml_metadata > &ml_mdata, bool _use_reference=true)
The serialization output archive object which, provided with a reference to an ostream, will write to the ostream, providing serialization capabilities.
virtual void inverse_transform(DenseVector &point) const =0
void transform(SparseVector &point) const