资源简介
利用深度学习预测比特币价格
代码片段和文件信息
import os
import shutil
import sys
from time import time
from uuid import uuid4
import numpy as np
import pandas as pd
from data_manager import file_processor
from returns_quantization import add_returns_in_place
from utils import *
np.set_printoptions(threshold=np.nan)
pd.set_option(‘display.max_rows‘ 500)
pd.set_option(‘display.max_columns‘ 500)
pd.set_option(‘display.width‘ 1000)
def generate_quantiles(data_folder bitcoin_file):
def get_label(btc_df btc_slice i slice_size):
class_name = str(btc_df[i + slice_size:i + slice_size + 1][‘close_price_returns_labels‘].values[0])
return class_name
return generate_cnn_dataset(data_folder bitcoin_file get_label)
def generate_up_down(data_folder bitcoin_file):
def get_price_direction(btc_df btc_slice i slice_size):
# last_price = btc_slice[-2:-1][‘price_close‘].values[0] #this is actually the second last price
last_price = btc_slice[-1:][‘price_close‘].values[0] #one option to get the correct last price
# last_price = btc_df[i + slice_size - 1:i + slice_size][‘price_close‘].values[0] #another option to get the correct last price
next_price = btc_df[i + slice_size:i + slice_size + 1][‘price_close‘].values[0]
if last_price < next_price:
class_name = ‘UP‘
else:
class_name = ‘DOWN‘
return class_name
return generate_cnn_dataset(data_folder bitcoin_file get_price_direction)
def generate_cnn_dataset(data_folder bitcoin_file get_class_name):
btc_df = file_processor(bitcoin_file)
btc_df levels = add_returns_in_place(btc_df)
print(‘-‘ * 80)
print(‘Those values should be roughly equal to 1/len(levels):‘)
for ii in range(len(levels)):
print(ii np.mean((btc_df[‘close_price_returns_labels‘] == ii).values))
print(levels)
print(‘-‘ * 80)
slice_size = 40
test_every_steps = 10
n = len(btc_df) - slice_size
shutil.rmtree(data_folder ignore_errors=True)
for epoch in range(int(1e6)):
st = time()
i = np.random.choice(n)
btc_slice = btc_df[i:i + slice_size]
if btc_slice.isnull().values.any():
# sometimes prices are discontinuous and nothing happened in one 5min bucket.
# in that case we consider this slice as wrong and we raise an exception.
# it‘s likely to happen at the beginning of the data set where the volumes are low.
raise Exception(‘NaN values detected. Please remove them.‘)
class_name = get_class_name(btc_df btc_slice i slice_size)
save_dir = os.path.join(data_folder ‘train‘ class_name)
if epoch % test_every_steps == 0:
save_dir = os.path.join(data_folder ‘test‘ class_name)
mkdir_p(save_dir)
filename = save_dir + ‘/‘ + str(uuid4()) + ‘.png‘
save_to_file(btc_slice filename=filename)
print(‘epoch = {0} time = {1:.3f} filename = {2}‘.format(str(epoch).zfill(8) ti
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-07-27 06:53 deep-learning-bitcoin-master\
文件 1181 2018-07-27 06:53 deep-learning-bitcoin-master\.gitignore
文件 394 2018-07-27 06:53 deep-learning-bitcoin-master\Dockerfile
文件 11357 2018-07-27 06:53 deep-learning-bitcoin-master\LICENSE
文件 3959 2018-07-27 06:53 deep-learning-bitcoin-master\README.md
目录 0 2018-07-27 06:53 deep-learning-bitcoin-master\assets\
文件 151782 2018-07-27 06:53 deep-learning-bitcoin-master\assets\1.png
文件 405816 2018-07-27 06:53 deep-learning-bitcoin-master\assets\2.png
文件 119 2018-07-27 06:53 deep-learning-bitcoin-master\data_download.sh
文件 3528 2018-07-27 06:53 deep-learning-bitcoin-master\data_generator.py
文件 952 2018-07-27 06:53 deep-learning-bitcoin-master\data_manager.py
文件 24 2018-07-27 06:53 deep-learning-bitcoin-master\requirements.txt
文件 924 2018-07-27 06:53 deep-learning-bitcoin-master\returns_quantization.py
文件 1546 2018-07-27 06:53 deep-learning-bitcoin-master\utils.py
相关资源
- Python-DeepMoji模型的pyTorch实现
- Python-使用DeepFakes实现YouTube视频自动换
- Python-一系列高品质的动漫人脸数据集
- Python-Insightface人脸检测识别的最小化
- Python-自然场景文本检测PSENet的一个
- Python-在特征金字塔网络FPN的Pytorch实现
- Python-PyTorch实时多人姿态估计项目的实
- Python-用PyTorch10实现FasterRCNN和MaskRCNN比
- Python-心脏核磁共振MRI图像分割
- Python-基于YOLOv3的行人检测
- Python-RLSeq2Seq用于SequencetoSequence模型的
- Python-PyTorch对卷积CRF的参考实现
- Python-高效准确的EAST文本检测器的一个
- Python-pytorch实现的人脸检测和人脸识别
- Python-UNet用于医学图像分割的嵌套UN
- Python-TensorFlow弱监督图像分割
- Python-基于tensorflow实现的用textcnn方法
- Python-Keras实现Inceptionv4InceptionResnetv1和
- Python-pytorch中文手册
- Python-FastSCNN的PyTorch实现快速语义分割
- Python-滑动窗口高分辨率显微镜图像分
- Python-使用MovieLens数据集训练的电影推
- Python-机器学习驱动的Web应用程序防火
- Python-subpixel利用Tensorflow的一个子像素
-
Python-汉字的神经风格转移Neuralst
y - Python-神经网络模型能够从音频演讲中
- Python-深度增强学习算法的PyTorch实现策
- Python-基于深度学习的语音增强使用
- Python-基于知识图谱的红楼梦人物关系
- Python-STGAN用于图像合成的空间变换生
评论
共有 条评论