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
--- | |
version: '2' | |
services: | |
zookeeper: | |
image: confluentinc/cp-zookeeper:3.2.1 | |
ports: | |
- 32181:32181 | |
environment: | |
ZOOKEEPER_CLIENT_PORT: 32181 | |
ZOOKEEPER_TICK_TIME: 2000 |
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
from keras import optimizers | |
model = Sequential() | |
model.add(Dense(64, kernel_initializer='uniform', input_shape=(10,))) | |
model.add(Activation('tanh')) | |
model.add(Activation('softmax')) | |
sgd = optimizers.SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True) | |
model.compile(loss='mean_squared_error', optimizer=sgd) |
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
def parameter_optimize(x1, x2, y, w1=w1,w2=w2, b=b, learning_rate = learning_rate): | |
# X contains the 100 student records. | |
# Iterate through each record. | |
for i in range(len(x1)): | |
# Make prediction using the initial values of w1, w2, b. | |
y_hat = find_perceptron_prediction(x1[i], x2[i], w1, w2, b) | |
# Case where the red points are wrongly classified. | |
# This is the case where the actual output is 0 but the prediction is 1. | |
if y[i] != y_hat and y[i] == 0: | |
# Reduce the values of parameters. |
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
def parameter_optimize(x1, x2, y, w1=w1,w2=w2, b=b, learning_rate = learning_rate): | |
# X contains the 100 student records. | |
# Iterate through each record. | |
for i in range(len(x1)): | |
# Make prediction using the initial values of W[0], W[1], b. | |
y_hat = find_perceptron_prediction(x1[i], x2[i], w1, w2, b) | |
# Case where the red points are wrongly classified. | |
# This is the case where the actual output is 0 but the prediction is 1. | |
if y[i] != y_hat and y[i] == 0: | |
w1 = w1 - test_scores[i] * learning_rate |
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
def parameter_optimize(x1, x2, y, w1=w1, w2=w2, b=b, learning_rate=learning_rate): | |
# X contains the 100 student records. | |
# Iterate through each record. | |
for i in range(len(x1)): | |
# Make prediction using the initial values of w1, w2, b. | |
y_hat = find_perceptron_prediction(x1[i], x2[i], w1, w2, b) | |
# Case where the green points are wrongly classified. | |
# This is the case where the actual output is 1 but the prediction is 0. | |
if y[i] != y_hat and y[i] == 1: | |
# slowly increase the values of the parameters. |
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
def parameter_optimize(x1, x2, y, w1=w1, w2=w2, b=b, learning_rate=learning_rate): | |
# X contains the 100 student records. | |
# Iterate through each record. | |
for i in range(len(x1)): | |
# Make prediction using the initial values of w1, w2, b. | |
y_hat = find_perceptron_prediction(x1[i], x2[i], w1, w2, b) | |
# Case where the red points are wrongly classified. | |
# This is the case where the actual output is 0 but the prediction is 1. | |
if y[i] != y_hat and y[i] == 0: | |
# slowly reduce the parameter values to move the line towards red cluster. |
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
from collections import OrderedDict | |
import numpy as np | |
# Setting the values for parameters w1, w2 and b. | |
# Try the code with various parameter values. | |
w1 = 3 | |
w2 = 2 | |
b = -1 |
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
%matplotlib inline | |
import matplotlib | |
import matplotlib.pyplot as plt | |
import numpy as np | |
# extract data frame columns into numpy array. | |
test_scores = data["test_scores"].values | |
grades = data["grades"].values | |
label = data["accepted"].values |
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
def processRequest(req): | |
# Parsing the POST request body into a dictionary for easy access. | |
req_dict = json.loads(request.data) | |
entity_type = "" | |
entity_value = "" | |
speech = "" | |
# Accessing the fields on the POST request boduy of API.ai invocation of the webhook | |
intent = req_dict["result"]["metadata"]["intentName"] | |
entity_key_val = req_dict["result"]["parameters"] |
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
# -*- coding:utf8 -*- | |
# !/usr/bin/env python | |
# Copyright 2017 Google Inc. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |