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
| 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
| # 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
| 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
| import numpy as np | |
| import pandas as pd | |
| #import lightgbm as lgb | |
| from optuna.integration import lightgbm as lgb | |
| from sklearn.model_selection import train_test_split | |
| from sklearn.utils import check_X_y, safe_sqr | |
| from sklearn.feature_selection.base import SelectorMixin | |
| from lightgbm import Booster |
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
| #! /usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # vim:fenc=utf-8 | |
| # | |
| # Copyright © 2019 Pi-Yueh Chuang <pychuang@gwu.edu> | |
| # | |
| # 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
| 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
| { | |
| "type" : "record", | |
| "name" : "TrainingExample", | |
| "namespace" : "com.linkedin.metronome.avro.generated", | |
| "fields" : [ { | |
| "name" : "uid", | |
| "type" : [ "null", "string", "long", "int" ], | |
| "doc" : "a unique id for the training event", | |
| "default" : null | |
| }, { |
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 -*- | |
| # | |
| # Author: Taylor G Smith | |
| # | |
| # Recommender system ranking metrics derived from Spark source for use with | |
| # Python-based recommender libraries (i.e., implicit, | |
| # http://github.com/benfred/implicit/). These metrics are derived from the | |
| # original Spark Scala source code for recommender metrics. | |
| # https://github.com/apache/spark/blob/master/mllib/src/main/scala/org/apache/spark/mllib/evaluation/RankingMetrics.scala |
NewerOlder