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
@numba.njit | |
def ln_ramanujan(n): | |
""" | |
Ramanujan's approximation to take the ln of the factorial of a number | |
""" | |
return n * np.log(n) - n + np.log(n * (1 + 4 * n * (1 + 2 * n)))/6. + np.log(pi)/2 | |
@numba.njit | |
def n_choose_k(n, k): | |
""" |
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 replace_str_cols(df): | |
""" | |
replace all columns with string labels with numeric values | |
""" | |
new_df = df.copy() | |
dd = defaultdict(LabelEncoder) | |
# create the encoded dataframe | |
edf = new_df.apply(lambda x: dd[x.name].fit_transform(x)) | |
for c in new_df.columns: | |
if new_df[c].dtype == np.object: |
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 string | |
def enumerate_letters(count): | |
""" | |
Generates a list of unique capital letter strings accordingly | |
eg. ['A', 'B', ... , 'AA', 'BB', 'CC', ...] | |
:param df: number of unique letter strings to return | |
:returns: list <str>: list of capital letter strings | |
""" |
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 _all_vars_are_numeric(df, *args): | |
""" | |
Check if all variables in a dataframe are numeric | |
:param df: pandas dataframe | |
:param *args: n dataframe columns names | |
:returns: bool_: True if all are numeric | |
""" | |
return np.issubdtype(df[list(args)].dtypes.unique()[0], np.number) |
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
""" | |
USAGE: | |
>>> replace_with_rank_indexes(dataframe, column_name) | |
or | |
>>> df.pipe(replace_with_rank_indexes, column='column_name') | |
Returns a copy of the dataframe with the designated column replaced by |
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 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
(venv) ubuntu@ip-10-30-254-4:/ops/mbdevops$ python deploy_stack.py emea master master | |
Region: eu-central-1 | |
Stack: emea | |
Portal branch: master | |
Solver branch: master | |
packer build -var-file=packer/aws/vars/eu-central-1/emea/worker.json -var 'region=eu-central-1' -var 'stack=emea' -var 'portal_branch=master' | |
-var 'solver_branch=master' -var 'mode=worker' packer/aws/mb-app.json | |
packer build -var-file=packer/aws/vars/eu-central-1/emea/portal.json -var 'region=eu-central-1' -var 'stack=emea' -var 'portal_branch=master' | |
-var 'solver_branch=master' -var 'mode=portal' packer/aws/mb-app.json | |
amazon-ebs output will be in this color. |
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
from timeit import default_timer as time | |
import numpy as np | |
from numba import cuda | |
import os | |
os.environ['NUMBAPRO_LIBDEVICE']='/usr/lib/nvidia-cuda-toolkit/libdevice/' | |
os.environ['NUMBAPRO_NVVM']='/usr/lib/x86_64-linux-gnu/libnvvm.so.3.1.0' | |
import numpy | |
import torch | |
import ctypes |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
NewerOlder