Skip to content

Commit

Permalink
Merge pull request #5 from SermetPekin/df
Browse files Browse the repository at this point in the history
df ops
  • Loading branch information
SermetPekin authored Dec 9, 2024
2 parents ae9ff09 + e9d9740 commit b344e76
Show file tree
Hide file tree
Showing 31 changed files with 160 additions and 890 deletions.
34 changes: 34 additions & 0 deletions current_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#include "micrograd.hpp"
#include "value.hpp"
#include "mlp.hpp"
using namespace microgradCpp;
/*
--file_name ./data/iris.csv
--encode variety
*/
int main(int argc, char *argv[])
{
// DatasetType dataset = get_iris();
DataFrame df;
df.from_csv("./data/wine.csv", true, ';');
// df.normalize( );
df.encode_column("quality");
df.print();
df.shuffle();
df.print();
double TRAIN_SIZE{0.8};
// Create MLP model
// Input: 4 features, hidden layers: [7,7], output: 3 classes
// Define the model and hyperparameters
// MLP model(4, {10, 10, 3});
MLP model(4, {16, 16, 10});
auto params = model.parameters();
double learning_rate = 0.01;
int epochs; // = 100;
std::cout << "Epoch : ?";
std::cin >> epochs;
AdamOptimizer optimizer(params, learning_rate);
train_eval(df, TRAIN_SIZE, model, optimizer, epochs);
return 0;
}
19 changes: 2 additions & 17 deletions easy.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// MIT License

// MIT License
// Copyright (c) [2024] Sermet Pekin

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -20,39 +17,27 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// */

#include "micrograd.hpp"
using namespace microgradCpp;

int main()
{

DatasetType dataset = get_iris();
shuffle(dataset);
double TRAIN_SIZE{0.8};

// Create MLP model
// Input: 4 features, hidden layers: [7,7], output: 3 classes
// Define the model and hyperparameters
MLP model(4, {10, 10, 3});
double learning_rate = 0.01;
int epochs = 100;

// Train and evaluate the model
train_eval(dataset, TRAIN_SIZE, model, learning_rate, epochs);

return 0;
}


/*
Notes
-----------
g++ -std=c++17 -Iinclude -O2 -o main main_easy.cpp
// or
make run
*/
*/
18 changes: 1 addition & 17 deletions easy_adam.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@

#include "micrograd.hpp"
using namespace microgradCpp;
// MIT License

// Copyright (c) [2024] Sermet Pekin

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -23,17 +20,13 @@ using namespace microgradCpp;
// THE SOFTWARE.
// */
/*
g++ -std=c++17 -Iinclude -O2 -o main easy_adam.cpp
*/
int main()
{

DatasetType dataset = get_iris();
shuffle(dataset);
double TRAIN_SIZE{0.8};

// Create MLP model
// Input: 4 features, hidden layers: [7,7], output: 3 classes
// Define the model and hyperparameters
Expand All @@ -42,26 +35,17 @@ int main()
auto params = model.parameters();
double learning_rate = 0.001;
int epochs = 1000;


// Initialize Adam optimizer
AdamOptimizer optimizer(params, learning_rate);

// Train and evaluate the model
// train_eval(dataset, TRAIN_SIZE, model, learning_rate, epochs);
train_eval(dataset, TRAIN_SIZE, model, optimizer, epochs);

return 0;
}

/*
Notes
-----------
g++ -std=c++17 -Iinclude -O2 -o main main_easy.cpp
// or
make run
*/
26 changes: 2 additions & 24 deletions easy_df.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
// MIT License

// MIT License
// Copyright (c) [2024] Sermet Pekin

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -21,34 +18,23 @@
// THE SOFTWARE.
// */
#include "micrograd.hpp"

#include "value.hpp"
#include "mlp.hpp"

using namespace microgradCpp;

int main()
{

// DatasetType dataset = get_iris();

DataFrame df;
df.from_csv("./data/iris.csv");
df.normalize();
df.encode_column("variety");



df.print();
df.shuffle();
df.print();

// stop();

// return 0;
// shuffle(dataset);
double TRAIN_SIZE{0.8};

// Create MLP model
// Input: 4 features, hidden layers: [7,7], output: 3 classes
// Define the model and hyperparameters
Expand All @@ -58,27 +44,19 @@ int main()
int epochs = 300;
// Train and evaluate the model
train_eval(df, TRAIN_SIZE, model, learning_rate, epochs);

return 0;
}
/*
// Initialize Adam optimizer
AdamOptimizer optimizer(params, learning_rate);
// Train and evaluate the model
// train_eval(dataset, TRAIN_SIZE, model, learning_rate, epochs);
train_eval(dataset, TRAIN_SIZE, model, optimizer, epochs);
*/
/*
Notes
-----------
g++ -std=c++17 -Iinclude -O2 -o main easy_df.cpp
// or
make run
*/
*/
54 changes: 6 additions & 48 deletions easy_df_adam.cpp
Original file line number Diff line number Diff line change
@@ -1,90 +1,48 @@
// MIT License

// Copyright (c) [2024] Sermet Pekin

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
// */

#include "micrograd.hpp"

#include "value.hpp"
#include "mlp.hpp"

using namespace microgradCpp;

int main()
{

// DatasetType dataset = get_iris();

DataFrame df;
df.from_csv("./data/iris.csv");
df.normalize();
df.encode_column("variety");

df.print();
df.shuffle();
df.print();

// return 0;
// stop();

// return 0;
// shuffle(dataset);
double TRAIN_SIZE{0.8};

// Create MLP model
// Input: 4 features, hidden layers: [7,7], output: 3 classes
// Define the model and hyperparameters
// MLP model(4, {10, 10, 3});
MLP model(4, {16, 16, 3});


auto params = model.parameters();
double learning_rate = 0.01;
int epochs = 100;


int epochs; // = 100;
std::cout << "Epoch : ?";
std::cin >> epochs;
// Initialize Adam optimizer
AdamOptimizer optimizer(params, learning_rate);

// Train and evaluate the model
// train_eval(dataset, TRAIN_SIZE, model, learning_rate, epochs);
// train_eval(dataset, TRAIN_SIZE, model, optimizer, epochs);

// Train and evaluate the model
train_eval(df, TRAIN_SIZE, model, optimizer, epochs);

return 0;
}
/*
*/
/*
Notes
-----------
g++ -std=c++17 -Iinclude -O2 -o main easy_df.cpp
g++ -std=c++17 -Iinclude -O2 -o main easy_df_adam.cpp
// or
make run
*/
*/
Loading

0 comments on commit b344e76

Please sign in to comment.