Skip to content

Instantly share code, notes, and snippets.

View irishryoon's full-sized avatar

Iris Yoon irishryoon

View GitHub Profile
@irishryoon
irishryoon / build_graph.py
Created October 8, 2021 15:13
Code for building artist graph in BFS way.
def continue_building_graph(G, queue, visited, ID_artists, max_count, sp):
"""Builds a weighted graph G using BFS.
Given a (possibly empty) graph G and a (possibly empty) queue,
(1) create nodes for new artists,
(2) create edges for new collaborations,
(3) update the 'albums' attribute of an edge to keep track of all albums accounted for.
In the very last step, find the weight of each edge as the number of albums
in the 'albums' attribute.
Furthermore, update the dictionary of artist ID and names.
@irishryoon
irishryoon / covid19.ipynb
Created March 27, 2020 01:23
COVID19.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@irishryoon
irishryoon / fit_SIR_model.py
Last active March 26, 2020 20:07
an example SIR model fitting
from symfit import Parameter, variables, Fit, D, ODEModel
import numpy as np
# define number of susceptible population
n_susceptible = 195000
# Some data
data_I = np.array([1, 2, 11, 23, 36, 75, 104, 137, 166, 209, 313, 400, 496, 693, 914, 1635, 2391, 5213, 8054, 11293, 15157, 19938, 24336, 29010])
data_R = np.array([0, 0, 0, 0, 0, 1, 2, 5, 7, 11, 15, 21, 29, 39, 53, 71, 104, 152, 256, 417, 643, 946, 1345, 1831])
data_S = [n_susceptible - x - data_R[idx] for idx, x in enumerate(data_I)]