Cosan  1.0
Data Analytics Library
customtransform.h
Go to the documentation of this file.
1 //
2 // Created by Xinyu Zhang on 4/4/21.
3 //
4 
5 #ifndef COSAN_CUSTOMTRANSFORM_H
6 #define COSAN_CUSTOMTRANSFORM_H
8 
9 namespace Cosan{
10  template<Numeric NumericType>
11  class CustomTransform: public Preprocessor<NumericType> {
12  public:
13  CustomTransform()=delete;
14  CustomTransform(CosanRawData<NumericType>& RD,std::vector<NumericType> newInput):Preprocessor<NumericType>() {
15  if (newInput.size()!= RD.GetrowsX()){
16  throw std::invalid_argument(
17  fmt::format("newInput does not have the same number of row as RD.X. newInput size is {:d} and RD.X has rows {:d}",newInput.size(),RD.GetrowsX() ));
18  }
19  fmt::print("*********************************\n");
20  fmt::print("Begin to generating customized features!!\n");
21 
22 // decltype(auto) X = RD.GetInput();
23 // __customFeatures = customTransform(X);
24  __customFeatures = Eigen::Map<const CosanMatrix<NumericType>>(newInput.data(), RD.GetrowsX(), 1);
25  fmt::print("End of generating customized features. One may get access to the new features via .GetCustomFeatures()!\n");
26  fmt::print("*********************************\n");
28  fmt::print("Notice that CRD.X has been modified. The dimension of X is ({:},{:}). {:} columns of new features have been added.\n",RD.GetrowsX(),RD.GetcolsX(),__customFeatures.cols());
29  }
30  decltype(auto) GetCustomFeatures(){return __customFeatures;}
31  private:
33 };
34 }
35 
36 #endif //COSAN_CUSTOMTRANSFORM_H
Cosan
Definition: CosanBO.h:29
Cosan::CustomTransform
Definition: customtransform.h:11
Cosan::CustomTransform::CustomTransform
CustomTransform(CosanRawData< NumericType > &RD, std::vector< NumericType > newInput)
Definition: customtransform.h:14
NumericType
double NumericType
Definition: onehotencodingTest.cpp:20
Cosan::CosanRawData::GetcolsX
gsl::index GetcolsX()
Get the number of columns for X.
Definition: CosanData.h:270
Cosan::CosanMatrix
Eigen::Matrix< NumericType, Eigen::Dynamic, Eigen::Dynamic > CosanMatrix
Definition: CosanBO.h:37
Cosan::CustomTransform::CustomTransform
CustomTransform()=delete
Cosan::CosanRawData
Raw Data container.
Definition: CosanData.h:36
Cosan::Preprocessor
Definition: preprocessor.h:14
Cosan::CustomTransform::__customFeatures
CosanMatrix< NumericType > __customFeatures
Definition: customtransform.h:32
Cosan::CosanRawData::GetrowsX
gsl::index GetrowsX()
Get the number of rows for X.
Definition: CosanData.h:254
preprocessor.h
Cosan::CosanRawData::ConcatenateData
void ConcatenateData(const CosanMatrix< NumericType > &inputX)
Concatenate X using CosanMatrix<NumericType> input X. Add new columns.
Definition: CosanData.h:94
Cosan::CustomTransform::GetCustomFeatures
decltype(auto) GetCustomFeatures()
Definition: customtransform.h:30