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
library(geepack) # Run install.packages("geepack") if necessary | |
library(tidyr) # Run install.packages("tidyr") if necessary | |
### Generate synthetic data | |
### For demonstration purposes only. | |
### You do not need to understand how this section works. | |
### Please see line 43 for format of data frame and line 58 for fitting model. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
''' | |
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 |
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
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] |
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
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] |
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 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) |
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
import csv | |
import random | |
import numpy as np | |
import pandas as pd | |
def cleanup(df): | |
''' | |
Cleans data | |
1. Creates new features: |
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
#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; |
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
import os | |
import time | |
import tweepy | |
from tweepy import OAuthHandler | |
from tweepy import Stream | |
from tweepy import StreamListener | |
def authenticate(): |