-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from SermetPekin/df
df ops
- Loading branch information
Showing
31 changed files
with
160 additions
and
890 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
*/ | ||
*/ |
Oops, something went wrong.