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 series_to_supervised(df, n_in=1, n_out=1, targets=[], dropnan=True): | |
""" | |
Converts a time series Pandas DataFrame into a supervised learning problem | |
returns: X(t-n_in+1,...,t), y(t+1,....,t+n_out) | |
""" | |
assert n_in > 0 and n_out > 0 | |
assert all([t in df.columns for t in targets]) | |
n_vars = len(df.columns) | |
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
word_list = [doc.words for doc in docs] | |
bigram = gensim.models.Phrases(word_list) | |
bigram_phr = gensim.models.phrases.Phraser(bigram) | |
bi_docs = [] | |
for doc in docs: | |
words = bigram_phr[doc.words] | |
tags = doc.tags |
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 gensim.models import Doc2Vec | |
import pickle | |
with open('./docs_proc.pkl', 'rb') as file: | |
docs = pickle.load(file) | |
model = Doc2Vec(docs, vector_size = 500, window = 9, min_count = 20, workers=8, dm=0) | |
with open('./d2v_model.pkl', 'wb') as file: | |
pickle.dump(model, file) | |
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 time | |
import sys | |
print("## Checking Keras\n\n") | |
import keras.backend as K | |
backend = K.backend() | |
vlen = 10 * 30 * 768 | |
iters = 1000 |
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 gym | |
import time | |
from gym import envs | |
print(envs.registry.all()) | |
env = gym.make('CartPole-v0') | |
env.reset() | |
t = 0 |
NewerOlder