Skip to content

Instantly share code, notes, and snippets.

View kavya006's full-sized avatar

kavya006 kavya006

View GitHub Profile
@kavya006
kavya006 / t1.py
Created February 5, 2023 16:50
Starter code for t1.py
from project.pkg2.t2 import print_t2
print_t2("t1")
@kavya006
kavya006 / t2.py
Created February 5, 2023 16:47
Starting code in t2.py
def print_t2(x="t2"):
print(f"{x} called")
@kavya006
kavya006 / multi_series_window_generator_make_dataset.py
Last active June 20, 2022 09:49
updated make_dataset method for Multi Series Window Generator
"""
Reference code from https://stackoverflow.com/questions/49994496/mixing-multiple-tf-data-dataset
"""
def stack_windows(*windows):
features = tf.concat([window[0] for window in windows], 0)
labels = tf.concat([window[1] for window in windows], 0)
return (features, labels)
def make_dataset(self:MultiSeriesWindowGenerator, data:tf.Tensor) -> tf.data.Dataset:
@kavya006
kavya006 / multi_series_window_generator_update_datasets.py
Last active June 20, 2022 09:24
updating the datasets in the multi series window object
def preprocess_dataset(self:MultiSeriesWindowGenerator, data:pd.DataFrame):
try:
if np.vstack(data.index).shape[1] != 1:
data = data.reset_index()
by = self.GROUPBY + [DATE]
labels = self.label_columns + self.regressor_columns + self.static_columns
data = data.set_index(by).unstack(-1)
data = tf.stack([data[label] for label in labels], axis=-1)
@kavya006
kavya006 / multi_series_window_generator_constructor.py
Last active June 20, 2022 09:16
WindowGenerator for multiple time series
class MultiSeriesWindowGenerator():
def __init__(self,
input_width, label_width, shift, batch_size,
label_columns=[], GROUPBY=None, regressor_columns=[], static_columns=[]
):
self.batch_size = batch_size
# Work out the label column indices.
self.label_columns = label_columns