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
# how to pool processes for arima | |
# given chunked data from data_chunker.py | |
# https://gist.github.com/justinhchae/13d246e8e2e2d521a8d2cce20eb09a09 | |
# given arima function from run_arima.py | |
# https://gist.github.com/justinhchae/d2a2dc8b71b5f5fbbb0f7eabf68b6850 | |
# dependencies | |
from tqdm import tqdm |
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 fbprophet import Prophet | |
import pandas as pd | |
import os | |
# https://stackoverflow.com/questions/2125702/how-to-suppress-console-output-in-python | |
# https://medium.com/spikelab/forecasting-multiples-time-series-using-prophet-in-parallel-2515abd1a245 | |
# https://facebook.github.io/prophet/docs/quick_start.html#python-api | |
class suppress_stdout_stderr(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
# how to pool processes for prophet | |
# given chunked data from data_chunker.py | |
# https://gist.github.com/justinhchae/13d246e8e2e2d521a8d2cce20eb09a09 | |
# given prophet function wrapper | |
# https://gist.github.com/justinhchae/8ef78743f13f50051ad1aca2106eaa1a | |
# dependencies | |
from tqdm import tqdm |
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
# solution reference: | |
# https://stackoverflow.com/questions/41707229/tqdm-printing-to-newline | |
def fc(x, param): | |
# inject some waiting to see progress unfold | |
time.sleep(1) | |
# set up pbar | |
pbar = tqdm(x.items(), desc='Exp:', position=0) | |
# init a variable for output | |
yhat = 0 |
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
# given a function from fc.py | |
# https://gist.github.com/justinhchae/a2efee420330a985286e7b88fd049ce5 | |
# in a file called main.py | |
import pandas as pd | |
# using the pytorch version of mp | |
import torch.multiprocessing as mp | |
# we need partial | |
from functools import partial | |
# progress bar |
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 get_vars_main(filename): | |
""" | |
a helper function for creating the code for the main table of an sql alchemy schema | |
bases on a csv file, extract necessary column names and tables and print the code to terminal | |
copy and paste the code into the schema section | |
""" | |
logging.info('get_vars_main() Producing code to make main data table in alchemy.') | |
class_name = f'class {db_table_name.title()}({db_class_name}):' | |
full_path = os.sep.join([data_folder, filename]) |
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
class Budget2021(BudgetDB.base): | |
__tablename__ = "budget2021" | |
# uncomment the following line to print out this class as text | |
# df = get_vars_main('budget_main.csv') | |
id = Column(Integer, primary_key=True) | |
fund_type = Column(String) | |
# the code is a value like 4355 that means "Department A" -> F key to the table the name of the dept. | |
department_code = Column(Integer, ForeignKey("departmentDescription.department_code")) | |
fund_code = Column(String, ForeignKey("fundDescription.fund_code")) | |
organization_code = Column(Integer) |
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
'''https://numpy.org/doc/stable/reference/generated/numpy.savez_compressed.html#numpy.savez_compressed | |
''' | |
import numpy as np | |
import os | |
# number of points in the point cloud | |
num_points = 10 |
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
# install direct from our forked repository: https://github.com/Esri/pytorch3d/tree/multitexture-obj-high-precision | |
!pip install 'git+https://github.com/Esri/pytorch3d.git@multitexture-obj-high-precision' | |
# import the forked pytorch3d library and new functions | |
from pytorch3d.io import load_obj | |
from pytorch3d.ops import sample_points_from_obj | |
from pytorch3d.io import subset_obj, save_obj |
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
# install direct from our forked repository: https://github.com/Esri/pytorch3d/tree/multitexture-obj-high-precision | |
!pip install 'git+https://github.com/Esri/pytorch3d.git@multitexture-obj-high-precision' | |
from pytorch3d.io import load_obj | |
# the current pytorch3d API for load_obj | |
obj = load_obj( | |
path_to_obj_file, | |
load_textures=True, | |
) |