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
// function to send order
function sendOrder(string memory burgerMenu, uint quantity) payable public {
// only the customer can use this function
require(msg.sender == customerAddress);
// increase the order index
orderseq++;
// create the order
orders[orderseq] = Order(orderseq, burgerMenu, quantity, 0, 0, 0, 0, true);
// event triggers when order sent
event OrderSent(address customer, string burgerMenu, uint quantity, uint orderNo);
// event triggers when price sent
event PriceSent(address customer, uint orderNo, uint price);
// event triggers when safe payment sent
event SafePaymentSent(address customer, uint orderNo, uint value, uint now);
// event triggers when invoice sent
// BurgerMenuOrder constructor
constructor(address _buyerAddr) public payable {
owner = msg.sender;
customerAddress = _buyerAddr;
}
// mapping for orders to have an list for the orders
mapping (uint => Order) orders;
// mapping for invoices to have an list for the invoices
mapping (uint => Invoice) invoices;
// index value of the orders
uint orderseq;
// index value of the invoices
// the contract's owner address
address payable public owner;
// the customer address
address public customerAddress;
// Order struct
struct Order {
uint ID;
string burgerMenu;
# 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)
# 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 training history
pyplot.plot(history.history['loss'], label='train')
pyplot.plot(history.history['val_loss'], label='test')
pyplot.legend()
pyplot.show()
# 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.
# 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]