Skip to content

Instantly share code, notes, and snippets.

View hackintoshrao's full-sized avatar
📚
Exploring AI agents on code search and understanding

Karthic Rao hackintoshrao

📚
Exploring AI agents on code search and understanding
View GitHub Profile
@hackintoshrao
hackintoshrao / flask_python_webhook.py
Created January 27, 2018 01:57
Webhook server example
# -*- 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
#
@hackintoshrao
hackintoshrao / response.json
Created January 26, 2018 14:28
JSON response from API.ai bot
{
"id": "035bea35-c51b-4ccc-be8c-61846b506b78",
"timestamp": "2018-01-26T14:04:28.967Z",
"lang": "en",
"result": {
"source": "agent",
"resolvedQuery": "I don't how to update goals",
"action": "",
"actionIncomplete": false,
"parameters": {
@hackintoshrao
hackintoshrao / HR.csv
Created January 8, 2018 06:23
HR data
We can't make this file beautiful and searchable because it's too large.
satisfaction_level last_evaluation number_project average_montly_hours time_spend_company Work_accident left promotion_last_5years sales salary
0.38 0.53 2 157 3 0 1 0 sales low
0.8 0.86 5 262 6 0 1 0 sales medium
0.11 0.88 7 272 4 0 1 0 sales medium
0.72 0.87 5 223 5 0 1 0 sales low
0.37 0.52 2 159 3 0 1 0 sales low
0.41 0.5 2 153 3 0 1 0 sales low
0.1 0.77 6 247 4 0 1 0 sales low
0.92 0.85 5 259 5 0 1 0 sales low
0.89 1 5 224 5 0 1 0 sales low
@hackintoshrao
hackintoshrao / not_perceptron.py
Created December 21, 2017 00:04
NOT perceptron on input 2.
import pandas as pd
weight1 = 0.0
weight2 = -2.0
bias = 1.0
# DON'T CHANGE ANYTHING BELOW
# Inputs and outputs
@hackintoshrao
hackintoshrao / or_perceptron.py
Created December 20, 2017 23:46
OR perceptron implementation
import pandas as pd
# Set weight1, weight2, and bias so that only the inputs 1,1 falls into positive area
weight1 = 2.0
weight2 = 2.0
bias = -1
# Inputs and otutputs
test_inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]
@hackintoshrao
hackintoshrao / find_chess_corner.py
Created December 14, 2017 15:51
Find and draw chess board corners for camera caliberation using Opencv
import numpy as np
import cv2
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import glob
# prepare object points
#Enter the number of inside corners in x
nx = 9
#Enter the number of inside corners in y
@hackintoshrao
hackintoshrao / p_controller.py
Created December 14, 2017 09:28
Implementation of proportional controller.
# -----------
# User Instructions
#
# Implement a P controller by running 100 iterations
# of robot motion. The desired trajectory for the
# robot is the x-axis. The steering angle should be set
# by the parameter tau so that:
#
# steering = -tau * crosstrack_error
#
@hackintoshrao
hackintoshrao / cartpole-episode.py
Last active October 8, 2020 01:14
A sample episode through the Open AI gym cartpole environment taking random actions.
import gym
# Use the cartpole environment.
env = gym.make('CartPole-v0')
# environment has to be reset first.
env.reset()
# This flag to is used to represent the end of an episode.
# An episode ends when the pole falls down.
done = False
# counter to check the number of moves for which the balance of the pole
@hackintoshrao
hackintoshrao / simple_arm_arm.sh
Created November 30, 2017 00:52
ROS node using pyton ropspy package to send commands to topics in simple arm package to move the robotic joints.
import math
import rospy
from std_msgs.msg import Float64
def mover():
pub_j1 = rospy.Publisher('/simple_arm/joint_1_position_controller/command',
Float64, queue_size=10)
pub_j2 = rospy.Publisher('/simple_arm/joint_2_position_controller/command',
Float64, queue_size=10)
rospy.init_node('arm_mover')
def get_embedding_layer(vocab_index, learned_embeddings, max_words, embedding_dim, max_seq_len, do_train):
""""
Creates the Embedding layer using learned embedding and word indesx map of all
unique words in the text corpus.
||Params||
vocab_index : Map of all unique words in your text corpus as keys and their index as values
learned_embeddings: Learned embedding representation from GLove/Word2Vec.
max_words: Max words to be used from the vocab