Cosan
1.0
Data Analytics Library
datapreprocessing.cpp
Go to the documentation of this file.
1
//
2
// Created by Xinyu Zhang on 3/26/21.
3
//
4
#include <iostream>
5
#include <
cosan/data/CosanData.h
>
6
#include <
cosan/preprocessing/overunderflow.h
>
7
#include <
cosan/preprocessing/missingvalues.h
>
8
#include <
cosan/preprocessing/normalizer.h
>
9
#include <
cosan/preprocessing/standardScaler.h
>
10
#include <
cosan/preprocessing/encoder.h
>
11
#include <
cosan/preprocessing/minmaxscaler.h
>
12
#include <
cosan/preprocessing/polynomialfeatures.h
>
13
14
typedef
double
NumericType
;
15
int
main
() {
16
Cosan::CosanRawData<NumericType>
CRD(
"./example_data/toy2/X_.csv"
,
"./example_data/toy2/y.csv"
);
17
Cosan::OverUnderFlow
ouf(CRD);
18
Cosan::MissingValues
MissV(CRD);
19
Cosan::Normalizer
NM(CRD,2);
20
Cosan::StandardScaler
SS(CRD);
21
Cosan::Encoder
ED(CRD,
true
);
22
NumericType
lb=0,ub=1;
23
Cosan::MinmaxScaler
MMS(CRD,lb,ub);
24
25
return
0;
26
}
27
//
28
29
// Cosan::CosanLinearRegression CLR(true);
30
// CLR.fit(CD.GetInput(),CD.GetTarget());
31
32
// std::cout<<CD.GetrowsX()<<" "<<CD.GetcolsX()<<" "<<std::endl;
33
// for (auto each : CD.GetIdxpinfX()) {std::cout<<each[0]<<" "<<each[1]<<std::endl;}
34
// for (auto each : CD.GetIdxminfX()) {std::cout<<each[0]<<" "<<each[1]<<std::endl;}
35
// for (auto each : CD.GetIdxmissingX()) {std::cout<<each[0]<<" "<<each[1]<<std::endl;}
36
// for (auto each : CD.GetcolCatX()) {std::cout<<each<<std::endl;}
37
// for (auto each : CD.GetsvaluesX()) {std::cout<<each<<std::endl;}
38
// for (const auto & [ key, value ] : CD.GetRawToNumIdx()){
39
// std::cout<<key<<":"<<value<<std::endl;}
40
// for (const auto & [ key, value ] : CD.GetRawToCatIdx()){
41
// std::cout<<key<<":"<<value<<std::endl;}
42
43
// Cosan::CosanRawData CD1("./example_data/toy2/X_2.csv");
44
45
// // Cosan::CosanLinearRegression CLR(true);
46
// // CLR.fit(CD.GetInput(),CD.GetTarget());
47
// std::cout<<CD1.GetSummaryMessageX()<<std::endl;
48
// // std::cout<<CD.GetrowsX()<<" "<<CD.GetcolsX()<<" "<<std::endl;
49
// // for (auto each : CD.GetIdxpinfX()) {std::cout<<each[0]<<" "<<each[1]<<std::endl;}
50
// // for (auto each : CD.GetIdxminfX()) {std::cout<<each[0]<<" "<<each[1]<<std::endl;}
51
// // for (auto each : CD.GetIdxmissingX()) {std::cout<<each[0]<<" "<<each[1]<<std::endl;}
52
// // for (auto each : CD.GetcolCatX()) {std::cout<<each<<std::endl;}
53
// // for (auto each : CD.GetsvaluesX()) {std::cout<<each<<std::endl;}
54
// for (const auto & [ key, value ] : CD1.GetRawToNumIdx()){
55
// std::cout<<key<<":"<<value<<std::endl;}
56
// for (const auto & [ key, value ] : CD1.GetRawToCatIdx()){
57
// std::cout<<key<<":"<<value<<std::endl;}
58
59
// std::cout<<CD.GetInput()<<std::endl;
60
61
// double RegularizationTerm = 1;
62
// Cosan::CosanRidgeRegression CRR(RegularizationTerm,true);
63
// CRR.fit(CD.GetInput(),CD.GetTarget());
64
// std::cout<<CRR.GetBeta()<<std::endl;
65
// save_csv("./example_data/toy/beta_c1.csv",CRR.GetBeta());
66
67
// m(0, 0) = 3;
68
// m(1, 0) = 2.5;
69
// m(0, 1) = -1;
70
// m(1,1) = m(1,0)+m(0,1);
71
// std::cout<<y.rows()<<y.cols()<<std::endl;
72
// Eigen::MatrixXd beta = (X.transpose()*X).ldlt().solve(X.transpose()*y);
73
74
75
//
76
// m.transposeInPlace();
77
// cout<<m<<endl;
78
// m.resize(1,4);
79
// cout<<n<<endl;
80
Cosan::MinmaxScaler
Definition:
minmaxscaler.h:12
encoder.h
CosanData.h
Cosan::Encoder
Definition:
encoder.h:9
NumericType
double NumericType
Definition:
onehotencodingTest.cpp:20
Cosan::OverUnderFlow
Definition:
overunderflow.h:14
NumericType
double NumericType
Definition:
datapreprocessing.cpp:14
normalizer.h
main
int main()
Definition:
datapreprocessing.cpp:15
Cosan::Normalizer
Definition:
normalizer.h:12
standardScaler.h
minmaxscaler.h
polynomialfeatures.h
Cosan::CosanRawData
Raw Data container.
Definition:
CosanData.h:36
overunderflow.h
Cosan::MissingValues
Definition:
missingvalues.h:13
Cosan::StandardScaler
Definition:
standardScaler.h:11
missingvalues.h
test
tutorial_codeexamples
datapreprocessing.cpp
Generated by
1.8.20