Skip to content

Instantly share code, notes, and snippets.

Avatar
🌴
On vacation

Apara Venkat AparaV

🌴
On vacation
View GitHub Profile
View SIRSimulationsTestSuite.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View number-guessing-game.py
'''
Author: Aparajithan Venkateswaran
Companion Article: https://aparav.github.io/2018/01/08/the-number-guessing-game/
'''
from scipy.special import comb
def conditional_prob(i, k, n, m):
'''
Calculates the probability of event C conditioned on Ri
View nn_housing.py
import os
import csv
import numpy as np
import pandas as pd
import tensorflow as tf
train_size = np.shape(x_train)[0]
valid_size = np.shape(x_valid)[0]
test_size = np.shape(x_test)[0]
num_features = np.shape(x_train)[1]
View regression_housing_3.py
import tensorflow as tf
import numpy as np
def accuracy(prediction, labels):
return 0.5 * np.sqrt(((prediction - labels) ** 2).mean(axis=None))
train_size = np.shape(x_train)[0]
valid_size = np.shape(x_valid)[0]
test_size = np.shape(x_test)[0]
num_features = np.shape(x_train)[1]
View regression_housing_2.py
def split(train_dataset):
'''
Shuffle data and split into 3 datasets
1. Training - 60%
2. Validation - 20%
3. Testing - 20%
'''
# Shuffle data
train_dataset = train_dataset.sample(frac=1)
View regression_housing_1.py
import csv
import random
import numpy as np
import pandas as pd
def cleanup(df):
'''
Cleans data
1. Creates new features:
@AparaV
AparaV / sieve-eratosthenes-runtime-comparison.cpp
Last active Apr 8, 2017
Compare the runtime of the sieve against vectors and bool arrays
View sieve-eratosthenes-runtime-comparison.cpp
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
bool* boolPrimeSieveMemset(int64_t size) {
bool* prime = new bool[size + 1];
memset(prime, true, size + 1); //faster than loops and vectors
prime[0] = false;
@AparaV
AparaV / streamer.py
Last active Jul 22, 2021
Using the tweepy library to stream tweets has a catch. There is no built-in feature that allows you to stop streaming after a fixed time. To avoid manually terminating the stream, this code proposes a simple solution without any (complex) multi-threading.
View streamer.py
import os
import time
import tweepy
from tweepy import OAuthHandler
from tweepy import Stream
from tweepy import StreamListener
def authenticate():