diff options
| author | bloodstalker <thabogre@gmail.com> | 2018-11-17 11:13:53 +0000 | 
|---|---|---|
| committer | bloodstalker <thabogre@gmail.com> | 2018-11-17 11:13:53 +0000 | 
| commit | 544f9d5289601a8ff2db4b92086d9cb7089128f5 (patch) | |
| tree | e399696b66c2237e2295a469fd2c7f28cbef9bb0 | |
| parent | update (diff) | |
| download | seer-544f9d5289601a8ff2db4b92086d9cb7089128f5.tar.gz seer-544f9d5289601a8ff2db4b92086d9cb7089128f5.zip | |
update
20 files changed, 94 insertions, 14 deletions
| diff --git a/dlstuff/four.py b/dlstuff/four.py index 983386a..90f58b9 100755 --- a/dlstuff/four.py +++ b/dlstuff/four.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!python  # _*_ coding=utf-8 _*_  import argparse @@ -48,6 +48,7 @@ def premain(argparser):      signal.signal(signal.SIGINT, SigHandler_SIGINT)      #here      (train_data, train_targets), (test_data, test_targets) = boston_housing.load_data() +    print(type(train_data))      mean = train_data.mean(axis=0)      train_data -= mean      std = train_data.std(axis=0) diff --git a/dlstuff/two.py b/dlstuff/two.py index 8287708..1d4a614 100755 --- a/dlstuff/two.py +++ b/dlstuff/two.py @@ -66,14 +66,12 @@ def premain(argparser):      x_test = vectorize_sequences(test_data)      y_train = np.asarray(train_labels).astype("float32")      y_test = np.asarray(test_labels).astype("float32") -      model = models.Sequential()      model.add(layers.Dense(16, kernel_regularizer=regularizers.l2(0.001), activation="relu", input_shape=(10000,)))      model.add(layers.Dropout(0.5))      model.add(layers.Dense(16, kernel_regularizer=regularizers.l2(0.001), activation="relu"))      model.add(layers.Dropout(0.5))      model.add(layers.Dense(1, activation="sigmoid")) -      x_val = x_train[:10000]      partial_x_train = x_train[10000:]      y_val = y_train[:10000] diff --git a/lstm-models/ethereum_model_randseed_775.h5 b/lstm-models/ethereum_model_randseed_775.h5Binary files differ index 27fc878..e58c5d7 100644 --- a/lstm-models/ethereum_model_randseed_775.h5 +++ b/lstm-models/ethereum_model_randseed_775.h5 diff --git a/lstm-models/ethereum_model_randseed_776.h5 b/lstm-models/ethereum_model_randseed_776.h5Binary files differ index e45229a..ab642c0 100644 --- a/lstm-models/ethereum_model_randseed_776.h5 +++ b/lstm-models/ethereum_model_randseed_776.h5 diff --git a/lstm-models/ethereum_model_randseed_777.h5 b/lstm-models/ethereum_model_randseed_777.h5Binary files differ index e341f72..d7c5276 100644 --- a/lstm-models/ethereum_model_randseed_777.h5 +++ b/lstm-models/ethereum_model_randseed_777.h5 diff --git a/lstm-models/ethereum_model_randseed_778.h5 b/lstm-models/ethereum_model_randseed_778.h5Binary files differ index a53d9bf..1d15190 100644 --- a/lstm-models/ethereum_model_randseed_778.h5 +++ b/lstm-models/ethereum_model_randseed_778.h5 diff --git a/lstm-models/ethereum_model_randseed_779.h5 b/lstm-models/ethereum_model_randseed_779.h5Binary files differ index 01a57f4..30ea4b4 100644 --- a/lstm-models/ethereum_model_randseed_779.h5 +++ b/lstm-models/ethereum_model_randseed_779.h5 diff --git a/lstm-models/ethereum_model_randseed_780.h5 b/lstm-models/ethereum_model_randseed_780.h5Binary files differ index 5882283..9973650 100644 --- a/lstm-models/ethereum_model_randseed_780.h5 +++ b/lstm-models/ethereum_model_randseed_780.h5 diff --git a/lstm-models/ethereum_model_randseed_781.h5 b/lstm-models/ethereum_model_randseed_781.h5Binary files differ index 4bda2c7..7ea593c 100644 --- a/lstm-models/ethereum_model_randseed_781.h5 +++ b/lstm-models/ethereum_model_randseed_781.h5 diff --git a/lstm-models/ethereum_model_randseed_782.h5 b/lstm-models/ethereum_model_randseed_782.h5Binary files differ index d6d2177..32b08ba 100644 --- a/lstm-models/ethereum_model_randseed_782.h5 +++ b/lstm-models/ethereum_model_randseed_782.h5 diff --git a/lstm-models/ethereum_model_randseed_783.h5 b/lstm-models/ethereum_model_randseed_783.h5Binary files differ index f52f6f9..13f3112 100644 --- a/lstm-models/ethereum_model_randseed_783.h5 +++ b/lstm-models/ethereum_model_randseed_783.h5 diff --git a/lstm-models/ethereum_model_randseed_784.h5 b/lstm-models/ethereum_model_randseed_784.h5Binary files differ index 6d9b7a5..024c70f 100644 --- a/lstm-models/ethereum_model_randseed_784.h5 +++ b/lstm-models/ethereum_model_randseed_784.h5 diff --git a/lstm-models/ethereum_model_randseed_785.h5 b/lstm-models/ethereum_model_randseed_785.h5Binary files differ index 370cb02..bd1ac60 100644 --- a/lstm-models/ethereum_model_randseed_785.h5 +++ b/lstm-models/ethereum_model_randseed_785.h5 diff --git a/lstm-models/ethereum_model_randseed_786.h5 b/lstm-models/ethereum_model_randseed_786.h5Binary files differ index 43153a1..748f4cf 100644 --- a/lstm-models/ethereum_model_randseed_786.h5 +++ b/lstm-models/ethereum_model_randseed_786.h5 diff --git a/lstm-models/ethereum_model_randseed_787.h5 b/lstm-models/ethereum_model_randseed_787.h5Binary files differ index 2bb8ddc..ad30e52 100644 --- a/lstm-models/ethereum_model_randseed_787.h5 +++ b/lstm-models/ethereum_model_randseed_787.h5 diff --git a/lstm-models/ethereum_model_randseed_788.h5 b/lstm-models/ethereum_model_randseed_788.h5Binary files differ index 74a5a8c..15eac0b 100644 --- a/lstm-models/ethereum_model_randseed_788.h5 +++ b/lstm-models/ethereum_model_randseed_788.h5 diff --git a/lstm-models/ethereum_model_randseed_789.h5 b/lstm-models/ethereum_model_randseed_789.h5Binary files differ index 4af9d00..14862c9 100644 --- a/lstm-models/ethereum_model_randseed_789.h5 +++ b/lstm-models/ethereum_model_randseed_789.h5 diff --git a/lstm-models/ethereum_model_randseed_790.h5 b/lstm-models/ethereum_model_randseed_790.h5Binary files differ index 45ba97b..cf56e88 100644 --- a/lstm-models/ethereum_model_randseed_790.h5 +++ b/lstm-models/ethereum_model_randseed_790.h5 @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!python  # _*_ coding=utf-8 _*_  #original source:https://github.com/dashee87/blogScripts/blob/master/Jupyter/2017-11-20-predicting-cryptocurrency-prices-with-deep-learning.ipynb @@ -22,7 +22,7 @@ from keras.layers import Dropout  from keras.models import load_model  window_len = 10 -split_date = "2017-06-01" +split_date = "2018-03-01"  def SigHandler_SIGINT(signum, frame):      print() @@ -37,22 +37,29 @@ class Argparser(object):          self.args = parser.parse_args()  def getData_CMC(crypto, crypto_short): -    market_info = pd.read_html("https://coinmarketcap.com/currencies/"+crypto+"/historical-data/?start=20130428&end="+time.strftime("%Y%m%d"))[0] +    market_info = pd.read_html("https://coinmarketcap.com/currencies/"+crypto+"/historical-data/?start=20160428&end="+time.strftime("%Y%m%d"))[0] +    print(type(market_info))      market_info =  market_info.assign(Date=pd.to_datetime(market_info['Date'])) -    if crypto == "ethereum": market_info.loc[market_info["Market Cap"]=="-","Market Cap"]=0 -    if crypto == "dogecoin": market_info.loc[market_info["Volume"]=="-","Volume"]=0 +    #print(market_info) +    #if crypto == "ethereum": market_info.loc[market_info["Market Cap"]=="-","Market Cap"]=0 +    #if crypto == "dogecoin": market_info.loc[market_info["Volume"]=="-","Volume"]=0      market_info["Volume"] = market_info["Volume"].astype("int64")      market_info.columns = market_info.columns.str.replace("*", "") -    print(type(market_info)) -    print(crypto + " head: ") -    print(market_info.head()) +    #print(type(market_info)) +    #print(crypto + " head: ") +    #print(market_info.head())      kwargs = {'close_off_high': lambda x: 2*(x['High']- x['Close'])/(x['High']-x['Low'])-1, 'volatility': lambda x: (x['High']- x['Low'])/(x['Open'])}      market_info = market_info.assign(**kwargs)      model_data = market_info[['Date']+[coin+metric for coin in [""] for metric in ['Close','Volume','close_off_high','volatility']]]      model_data = model_data.sort_values(by='Date') -    print(model_data.head()) +    #print(model_data.head()) +    print(type(model_data))      return model_data +def getData_Stock(name, period): +    info = pd.from_csv(path="./data/"+name+"/"+period+".csv") +    return info +  def get_sets(crypto, model_data):      training_set, test_set = model_data[model_data['Date']<split_date], model_data[model_data['Date']>=split_date]      training_set = training_set.drop('Date', 1) @@ -93,15 +100,26 @@ def lstm_type_1(crypto, crypto_short):      model_data = getData_CMC(crypto, crypto_short)      np.random.seed(202)      training_inputs, test_inputs, training_set, test_set = get_sets(crypto, model_data) -    model = build_model(training_inputs, output_size=1, neurons=20) +    model = build_model(training_inputs, output_size=1, neurons=20, loss="mse")      training_outputs = (training_set['Close'][window_len:].values/training_set['Close'][:-window_len].values)-1      history = model.fit(training_inputs, training_outputs, epochs=50, batch_size=1, verbose=2, shuffle=True) +def lstm_type_4(crypto, crypto_short, crypto2, crypto_short2): +    model_data = getData_CMC(crypto, crypto_short) +    model_data2 = getData_CMC(crypto2, crypto_short2) +    np.random.seed(202) +    training_inputs, test_inputs, training_set, test_set = get_sets(crypto, model_data) +    training_inputs2, test_inputs2, training_set2, test_set2 = get_sets(crypto2, model_data2) +    return +    model = build_model(training_inputs/training_inputs2, output_size=1, neurons=20, loss="mse") +    training_outputs = ((training_set['Close'][window_len:].values)/(training_set['Close'][:-window_len].values))-1 +    history = model.fit(training_inputs/training_inputs2, training_outputs, epochs=10, batch_size=1, verbose=2, shuffle=True) +  def lstm_type_2(crypto, crypto_short, pred_range, neuron_count):      model_data = getData_CMC(crypto, crypto_short)      np.random.seed(202)      training_inputs, test_inputs, training_set, test_set = get_sets(crypto, model_data) -    model = build_model(training_inputs, output_size=pred_range, neurons=neuron_count) +    model = build_model(training_inputs, output_size=pred_range, neurons=neuron_count, loss="mse")      training_outputs = (training_set['Close'][window_len:].values/training_set['Close'][:-window_len].values)-1      training_outputs = []      for i in range(window_len, len(training_set['Close'])-pred_range): @@ -139,6 +157,7 @@ def premain(argparser):      lstm_type_1("ethereum", "ether")      #lstm_type_2("ethereum", "ether", 5, 20)      #lstm_type_3("ethereum", "ether", 5, 20) +    #lstm_type_4("ethereum", "ether", "dogecoin", "doge")      #load_models("ethereum", "eth")  def main(): diff --git a/stock.py b/stock.py new file mode 100755 index 0000000..6ad60ed --- /dev/null +++ b/stock.py @@ -0,0 +1,62 @@ +#!python +# _*_ coding=utf-8 _*_ + +import argparse +import code +import readline +import signal +import sys +import pandas as pd +import numpy as np +import json +import os +import urllib3 +import time +from keras.models import Sequential +from keras.layers import Activation, Dense +from keras.layers import LSTM +from keras.layers import Dropout +from keras.models import load_model + +def SigHandler_SIGINT(signum, frame): +    print() +    sys.exit(0) + +class Argparser(object): +    def __init__(self): +        parser = argparse.ArgumentParser() +        parser.add_argument("--string", type=str, help="string") +        parser.add_argument("--bool", action="store_true", help="bool", default=False) +        parser.add_argument("--dbg", action="store_true", help="debug", default=False) +        self.args = parser.parse_args() + +def build_model(train_data): +    model = models.Sequential() +    model.add(layers.Dense(64, activation="relu", input_shape=(train_data.shape[1],))) +    model.add(layers.Dense(64, activation="relu")) +    model.add(layers.Dense(1)) +    model.compile(optimizer="rmsprop", loss="mse", metrics=["acc"]) +    return model + +# write code here +def premain(argparser): +    signal.signal(signal.SIGINT, SigHandler_SIGINT) +    #here + +def main(): +    argparser = Argparser() +    if argparser.args.dbg: +        try: +            premain(argparser) +        except Exception as e: +            print(e.__doc__) +            if e.message: print(e.message) +            variables = globals().copy() +            variables.update(locals()) +            shell = code.InteractiveConsole(variables) +            shell.interact(banner="DEBUG REPL") +    else: +        premain(argparser) + +if __name__ == "__main__": +    main() | 
