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
class LogReg(): | |
""" | |
Implementation of binary logistic regression | |
""" | |
def __init__(self,dataframe,y_column): | |
""" | |
Initialize LogReg class with a pandas dataframe and the name of the dependent variable column, y. | |
All other variable will be assumed to be independent variables, x. | |
""" |
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
class Node(object): | |
def __init__(self,val): | |
self.val = val | |
self.next = None | |
def get_data(self): | |
return self.val | |
def set_data(self,val): | |
self.val = val |
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
class GeneralTree(): | |
""" | |
Parameters: | |
@root: root node | |
@first_born: leftmost child of root node | |
@current_node: initalized as first born | |
@current-value: initialized as value of first born (current node) | |
@visited: Linked list of all values whichg have previously been visited | |
@path: FULL path, traversing siblings, from root to search value (LL) | |
@child_path: path, sibling traversal not captured, more closely resembles typical tree design/behavior (LL) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
class TweetGrabber(): | |
def __init__(self,myApi,sApi,at,sAt): | |
import tweepy | |
self.tweepy = tweepy | |
auth = tweepy.OAuthHandler(myApi, sApi) | |
auth.set_access_token(at, sAt) | |
self.api = tweepy.API(auth) | |
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
class RetweetParser(): | |
def __init__(self,data,user): | |
import ast | |
self.user = user | |
edge_list = [] | |
for idx,row in data.iterrows(): | |
if len(row[4]) > 5: |
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
class TweetGraph(): | |
def __init__(self,edge_list): | |
import igraph | |
import pandas as pd | |
data = pd.read_csv(edge_list).to_records(index=False) | |
self.graph = igraph.Graph.TupleList(data, weights=True, directed=False) | |
def e_centrality(self): | |
import operator |
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 random | |
def trial(): | |
sequence = [] | |
# dist = [0.140,0.140,0.140,0.125,0.105,0.090,0.075,0.060,0.045,0.030,0.020,0.015,0.010,0.005] | |
dist = [114,113,112,111,99,89,79,69,59,49,39,29,19,9,6,4] | |
pool = [idx+1 for idx,elem in enumerate(dist)] | |
# for i in range(4): | |
for i in range(5): | |
selected = random.choices(population=pool, weights=dist)[0] |
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
# SQL | |
import sqlite3 | |
conn = sqlite3.connect('acc1819.db') | |
c = conn.cursor() | |
# Get columns from game table | |
game_columns = c.execute(""" | |
PRAGMA table_info(games); | |
""").fetchall() | |
g_col = [game_columns[i][1] for i in range(len(game_columns))] |
OlderNewer