This file contains hidden or 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
# found in the LICENSE file. | |
import os | |
import argparse | |
import re | |
import atexit | |
import signal | |
import yaml | |
import datetime | |
import subprocess | |
from functools import partial |
This file contains hidden or 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 re | |
import os | |
def read_content(filepath): | |
with open(filepath, "r") as f: | |
return f.read() | |
ebuild_special_chars = ["*", "?", "+", "(", ")", "[", "]", ":", "=", ">", "<", "-",".","_","/"] | |
def compose_regex(parts=[], group="", compile=True): |
This file contains hidden or 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
#!/usr/bin/python3 | |
import sys | |
import os | |
import re | |
import psutil | |
import subprocess | |
import socket | |
from dotenv import load_dotenv | |
from twilio.rest import Client |
This file contains hidden or 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
# this was a rough cut that I used in a small project, but thought it would be useful to have in case I need to refer back | |
# to a keras version of this. I've since switched to pytorch | |
# define the model object (subclass model) | |
# initial params | |
window = 30 | |
num_cells_lstm = 32 | |
learning_rate = 1e-6 | |
layer_dropout = 0.5 | |
cell_dropout = 0.2 | |
batch_size = 16 |
This file contains hidden or 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
# I have since lost the original author of this -> but I've made a few edits | |
def weighted_categorical_crossentropy(weights): | |
""" | |
A weighted version of keras.objectives.categorical_crossentropy | |
Variables: | |
weights: numpy array of shape (C,) where C is the number of classes | |
This file contains hidden or 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 circular_time(ts, start_cycle=None, end_cycle=None, interval='s', as_series=True): | |
""" | |
returns a tuple (sin,cos) representing the timestamp as a coordinate in a unit circle | |
the calculation is 2*pi*(ratio of interest) | |
e.g. for a time on a 24hour clock, you have 2*pi*(seconds since midnight/seconds in day) | |
this cycle can be abstracted to days by using (days elapsed /days in year) | |
or custom cycles such as (days elapsed since start of cycle / days in cycle) | |
:param ts: a pandas datetime object representing the time in a 24 hour clock | |
""" |
This file contains hidden or 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
""" | |
this is a really rough function that I use to organize applying multiple calculations to a df - it caches in a way, | |
in that it doesn't recalculate the measure if it exists. It also can be used in the case of dependencies. | |
I think there are better libraries that exist for this now - but it's handy just in case | |
""" | |
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder