Cosan
1.0
Data Analytics Library
onehotEncoder.h
Go to the documentation of this file.
1
#ifndef COSAN_ONEHOTENCODER_H
2
#define COSAN_ONEHOTENCODER_H
3
4
#include <
cosan/preprocessing/encoder.h
>
5
6
namespace
Cosan
{
7
template
<Numeric NumericType>
8
class
OnehotEncoder
:
public
Encoder
<NumericType> {
9
public
:
10
std::vector<int>
getEncoding
(
int
colIdx,
const
std::string &category) {
11
int
categoryCount = this->
getCategories
()[colIdx].size();
12
int
ordinal = this->
getCategories
()[colIdx][category];
13
std::vector<int> encoding(categoryCount,0);
14
encoding[ordinal] = 1;
15
return
encoding;
16
}
17
};
18
19
}
20
21
22
#endif //COSAN_ONEHOTENCODER_H
encoder.h
Cosan
Definition:
CosanBO.h:29
Cosan::Encoder
Definition:
encoder.h:9
Cosan::Encoder::getCategories
std::vector< std::unordered_map< std::string, gsl::index > > getCategories() const
Definition:
encoder.h:71
Cosan::OnehotEncoder
Definition:
onehotEncoder.h:8
Cosan::OnehotEncoder::getEncoding
std::vector< int > getEncoding(int colIdx, const std::string &category)
Definition:
onehotEncoder.h:10
cosan
preprocessing
onehotEncoder.h
Generated by
1.8.20