Skip to content

Instantly share code, notes, and snippets.

View ahmetozlu's full-sized avatar
💭
I may be slow to respond.

Ozlu ahmetozlu

💭
I may be slow to respond.
View GitHub Profile
@ahmetozlu
ahmetozlu / singly_linked_list_challenge
Created September 9, 2017 19:28
C Program to Implement Advanced Singly Linked List using Dynamic Memory Allocation
/*
----------------------------------------------
--- Author : Ahmet Özlü
--- Mail : ahmetozlu93@gmail.com
--- Date : 1st September 2017
----------------------------------------------
*/
#include <stdio.h>
#include <malloc.h>
@ahmetozlu
ahmetozlu / face_recognizer.py
Last active June 11, 2023 14:03
Detect, Recognize, Crop Faces from Video and Save Them as Images
#----------------------------------------------
#--- Author : Ahmet Ozlu
#--- Mail : ahmetozlu93@gmail.com
#--- Date : 21st September 2017
#----------------------------------------------
import face_recognition
import cv2
import os
import create_csv
@ahmetozlu
ahmetozlu / create_csv.py
Created September 30, 2017 16:41
Automatically creates you a CSV file
#----------------------------------------------
#--- Author : Ahmet Ozlu
#--- Mail : ahmetozlu93@gmail.com
#--- Date : 21st September 2017
#----------------------------------------------
import sys
import os.path
import csv
@ahmetozlu
ahmetozlu / SPPM
Last active November 22, 2017 21:22
Smartphone Power Monitor Arduino Software
//----------------------------------------------
//--- Author : Ahmet Ozlu
//--- Mail : ahmetozlu93@gmail.com
//--- Date : 26th October 2017
//----------------------------------------------
/*declaration of variables*/
int sensorValue;
int sensorValue2;
# imports
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from sklearn.metrics import r2_score
import matplotlib.pyplot as plt
import numpy
from keras.optimizers import Adam
import keras
from matplotlib import pyplot
# Read data from csv file for training and validation data
TrainingSet = numpy.genfromtxt("./training.csv", delimiter=",", skip_header=True)
ValidationSet = numpy.genfromtxt("./validation.csv", delimiter=",", skip_header=True)
# Split into input (X) and output (Y) variables
X1 = TrainingSet[:,0:6]
Y1 = TrainingSet[:,6]
X2 = ValidationSet[:,0:6]
Y2 = ValidationSet[:,6]
# Create model
model = Sequential()
model.add(Dense(128, activation="relu", input_dim=6))
model.add(Dense(32, activation="relu"))
model.add(Dense(8, activation="relu"))
# Since the regression is performed, a Dense layer containing a single neuron with a linear activation function.
# Typically ReLu-based activation are used but since it is performed regression, it is needed a linear activation.
model.add(Dense(1, activation="linear"))
# Compile model: The model is initialized with the Adam optimizer and then it is compiled.
# Plot training history
pyplot.plot(history.history['loss'], label='train')
pyplot.plot(history.history['val_loss'], label='test')
pyplot.legend()
pyplot.show()
# Plot actual vs prediction for training set
TestResults = numpy.genfromtxt("trainresults.csv", delimiter=",")
plt.plot(Y1,TestResults,'ro')
plt.title('Training Set')
plt.xlabel('Actual')
plt.ylabel('Predicted')
# Compute R-Square value for training set
TestR2Value = r2_score(Y1,TestResults)
print("Training Set R-Square=", TestR2Value)
# Plot actual vs prediction for validation set
ValResults = numpy.genfromtxt("valresults.csv", delimiter=",")
plt.plot(Y2,ValResults,'ro')
plt.title('Validation Set')
plt.xlabel('Actual')
plt.ylabel('Predicted')
# Compute R-Square value for validation set
ValR2Value = r2_score(Y2,ValResults)
print("Validation Set R-Square=",ValR2Value)