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://stackoverflow.com/a/28324562 | |
-- https://sqlperformance.com/2013/03/io-subsystem/chunk-deletes | |
DECLARE @Deleted_Rows INT; | |
SET @Deleted_Rows = 1; | |
WHILE (@Deleted_Rows > 0) | |
BEGIN | |
BEGIN TRANSACTION |
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
Source Data Set: https://console.cloud.google.com/bigquery?p=data-to-insights&d=ecommerce&t=web_analytics&page=table | |
## TRAIN | |
CREATE OR REPLACE MODEL `ecommerce.classification_model_2` | |
OPTIONS | |
(model_type='logistic_reg', labels = ['will_buy_on_return_visit']) AS | |
WITH all_visitor_stats AS ( |
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
#snippet for getting data to and from google drive while using google colab | |
!pip install -q tqdm | |
import tqdm | |
from google.colab import auth | |
from googleapiclient.discovery import build | |
import io | |
from googleapiclient.http import MediaIoBaseDownload | |
from googleapiclient.http import MediaFileUpload |
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
--last mod date for all tables | |
SELECT | |
t.name, | |
t.modify_date, | |
i.rowcnt | |
FROM sys.tables t | |
left outer join sysindexes i | |
ON t.object_id = i.id | |
WHERE i.indid < 2 |
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
"""" | |
uses policy/value iteration to solve the task | |
there's a 2 layer neural network that's responsible for estimating the future value of a state | |
and a linear weight model (wrapped in a softmax) to handle selecting the policy(acitons) | |
the policy model incorporates the value function, by adjusting the loss score by the difference between the observed reward and the expected reward | |
actions that perform much better than expected will have a lower "penalty" and thus have their weights less affected than actions where the | |
observed performance is much worse. | |
The other interesting component of this model is the exploration function, which ensures that the agent explores at a rate that's proportional |
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 gym | |
""" | |
Solved Frozen Lake: after 1100 steps. | |
Solved Taxi-v1: after 500 steps | |
Implementation of SARSA... |
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 gym | |
""" | |
Implementation of SARSA... | |
Using a relatively small learning rate, which causes convergence to take longer | |
Built as an object to allow for easy extensibility to other environments for quick benchmarking |
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 os | |
os.chdir('/Users/mwoods/Desktop') | |
# ----------------- | |
# User Instructions | |
# |
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
# Finite State Machine | |
# An Example of Finite State Machine Using Classes | |
# Responsed to: https://www.reddit.com/r/dailyprogrammer/comments/4cb7eh | |
class FiniteStateMachine: | |
def __init__(self): | |
self.states = set([]) | |
self.transitions = {} | |
self.current_state = None |
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 random | |
import os | |
random.seed(42) | |
F_PATH = "data.csv" | |
OUTPUT_PATH_TEMPLATE = "tmp_%d.csv" | |
CHUNK_SIZE = 5 |
NewerOlder