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 pandas as pd | |
import datetime | |
from datetime import datetime as dt | |
from dateutil.relativedelta import * | |
class TimeBasedCV(object): | |
''' | |
Parameters | |
---------- | |
train_period: int |
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 use TimeBasedCV | |
data_for_modeling=pd.read_csv('data.csv', parse_dates=['record_date']) | |
tscv = TimeBasedCV(train_period=30, | |
test_period=7, | |
freq='days') | |
for train_index, test_index in tscv.split(data_for_modeling, | |
validation_split_date=datetime.date(2019,2,1), date_column='record_date'): | |
print(train_index, test_index) | |
# get number of splits |
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/env python | |
# -*- coding: utf-8 -*- | |
# vim:fenc=utf-8 | |
# | |
# Copyright © 2019 Pi-Yueh Chuang <[email protected]> | |
# | |
# Distributed under terms of the MIT license. | |
"""An example of using tfp.optimizer.lbfgs_minimize to optimize a TensorFlow model. |
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
"""Checks if a set of TFRecords appear to be valid. | |
Specifically, this checks whether the provided record sizes are consistent and | |
that the file does not end in the middle of a record. It does not verify the | |
CRCs. | |
""" | |
import struct | |
import tensorflow as tf | |
from tensorflow import app |
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 tensorflow as tf | |
from tensorflow.python.framework import ops | |
from tensorflow.python.ops import math_ops | |
from tensorflow.python.eager import context | |
def cyclic_learning_rate(global_step, | |
learning_rate=0.01, | |
max_lr=0.1, | |
step_size=20., | |
gamma=0.99994, |
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 pandas as pd | |
import tensorflow as tf | |
import dask.dataframe as dd | |
from dask.distributed import Client, LocalCluster | |
from tensorflow.python.saved_model import loader | |
def encode_factory(sess, export_path:str): | |
"""Loads TF SavedModel and returns a callable""" | |
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
""" | |
(C) August 2013, Mathieu Blondel | |
# License: BSD 3 clause | |
This is a Numba-based reimplementation of the block coordinate descent solver | |
(without line search) described in the paper: | |
Block Coordinate Descent Algorithms for Large-scale Sparse Multiclass | |
Classification. Mathieu Blondel, Kazuhiro Seki, and Kuniaki Uehara. | |
Machine Learning, May 2013. |
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 pandas as pd | |
import numpy as np | |
import patsy | |
import tensorflow as tf | |
class SleepReg(tf.Module): | |
def __init__(self, sleepdata_path): | |
"""Initializing tensorflow variables and other necessary matrices""" | |
# These two TensorFlow variables show up in the trainable_variables |
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
# -*- coding: utf-8 -*- | |
""" | |
Created on Sun Oct 22 10:31:23 2017 | |
@author: SF | |
""" | |
import numpy as np | |
from keras.layers import Input | |
from keras.models import Model |
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/env python | |
""" | |
Example of using Keras to implement a 1D convolutional neural network (CNN) for timeseries prediction. | |
""" | |
from __future__ import print_function, division | |
import numpy as np | |
from keras.layers import Convolution1D, Dense, MaxPooling1D, Flatten | |
from keras.models import Sequential |
NewerOlder