Py学习  »  Python

Python 3-ValueError:找到了一个0个示例(shape=(0,11))的数组,而MinMaxScaler至少需要1个

Matt Wilson • 4 年前 • 2106 次点击  

我真的很难让我的这个项目启动和运行,但我保持弹性,我想我已经接近了!

我正在尝试自定义此项目以使用我自己的数据集:

https://github.com/notadamking/Bitcoin-Trader-RL

基本上,这个项目使用股票价格的OHLCV数据集来训练和交易,但是我有一个一天的tick数据集,我想用它来代替项目中提供的OHLCV.csv文件的更多列(我的包含Time、Open、Close、Last、LastSize、Bid、BidSize、Ask、AskSize、Volume)。它将.csv文件内容放入自己的数组中,然后使用MinMaxScaler将所有点转换为相对于所在列的值介于0-1之间的值。

我收到了下面的完整错误,我希望知道这里发生了什么的人能够发现我遗漏了什么:

Traceback (most recent call last):
  File "main.py", line 23, in <module>
    model.learn(total_timesteps=200000)
  File "c:\users\windowshopr\desktop\python scripts\all tools\stable-baselines-master\stable_baselines\a2c\a2c.py", line 231, in learn
    runner = A2CRunner(self.env, self, n_steps=self.n_steps, gamma=self.gamma)
  File "c:\users\windowshopr\desktop\python scripts\all tools\stable-baselines-master\stable_baselines\a2c\a2c.py", line 310, in __init__
    super(A2CRunner, self).__init__(env=env, model=model, n_steps=n_steps)
  File "c:\users\windowshopr\desktop\python scripts\all tools\stable-baselines-master\stable_baselines\common\runners.py", line 19, in __init__
    self.obs[:] = env.reset()
  File "c:\users\windowshopr\desktop\python scripts\all tools\stable-baselines-master\stable_baselines\common\vec_env\dummy_vec_env.py", line 45, in reset
    obs = self.envs[env_idx].reset()
  File "C:\Users\windowshopr\Desktop\Current Python Project\1 - Matt's Bitcoin Trader (level 1)\env\BitcoinTradingEnv.py", line 90, in reset
    return self._next_observation()
  File "C:\Users\windowshopr\Desktop\Current Python Project\1 - Matt's Bitcoin Trader (level 1)\env\BitcoinTradingEnv.py", line 38, in _next_observation
    scaled_df = self.scaler.fit_transform(scaled_df)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\base.py", line 518, in fit_transform
    return self.fit(X, **fit_params).transform(X)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\preprocessing\data.py", line 308, in fit
    return self.partial_fit(X, y)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\preprocessing\data.py", line 334, in partial_fit
    estimator=self, dtype=FLOAT_DTYPES)
  File "C:\Users\windowshopr\AppData\Local\Programs\Python\Python36\lib\site-packages\sklearn\utils\validation.py", line 431, in check_array
    context))
ValueError:Found array with 0 sample(s) (shape=(0, 11)) while a minimum of 1 is required by MinMaxScaler.

注意下面几行:

**文件“C:\Users\windowshopr\Desktop\Current Python Project\1-马特的比特币交易员(级别1)\env\BitcoinTradingEnv.py”,第90行,在reset中 返回自我。下一步观察()

文件“C:\Users\windowshopr\Desktop\Current Python Project\1-马特的比特币交易员(级别1)\env\BitcoinTradingEnv.py”,第38行,在下一个观察中 scaled_df=self.scaler.fit_变换(scaled_df)**

我已经看到另外两个问题了,但是其中一个没有回答,另一个没有解决问题,所以我不知所措。我知道我不应该按照SO的规则发布整个代码,但是,在这种情况下,我认为需要从回溯错误中获得它,所以我对此表示歉意,但我希望它能有所帮助我认为问题在于 下一步观察(自我): “功能:

import gym
import pandas as pd
import numpy as np
from gym import spaces
from sklearn import preprocessing

from render.BitcoinTradingGraph import BitcoinTradingGraph

MAX_TRADING_SESSION = 100000


class BitcoinTradingEnv(gym.Env):
    """A Bitcoin trading environment for OpenAI gym"""
    metadata = {'render.modes': ['human', 'system', 'none']}
    scaler = preprocessing.MinMaxScaler()
    viewer = None

    def __init__(self, df, lookback_window_size=40, initial_balance=10000, commission=0.005, serial=False):
        super(BitcoinTradingEnv, self).__init__()

        self.df = df.dropna().reset_index()
        self.lookback_window_size = lookback_window_size
        self.initial_balance = initial_balance
        self.commission = commission
        self.serial = serial

        # Actions of the format Buy 1/10, Sell 3/10, Hold (amount ignored), etc.
        self.action_space = spaces.MultiDiscrete([3, 10])

        # Observes the OHCLV values, net worth, and trade history
        self.observation_space = spaces.Box(
            low=0, high=1, shape=(10, lookback_window_size + 1), dtype=np.float16)

    def _next_observation(self):
        end = self.current_step + self.lookback_window_size + 1

        scaled_df = self.active_df.values[:end].astype('float64')
        scaled_df = self.scaler.fit_transform(scaled_df)
        scaled_df = pd.DataFrame(scaled_df, columns=self.df.columns)

        obs = np.array([
            scaled_df['Open'].values[self.current_step:end],
            scaled_df['Close'].values[self.current_step:end],
            scaled_df['Last'].values[self.current_step:end],
            scaled_df['LastSize'].values[self.current_step:end],
            scaled_df['Bid'].values[self.current_step:end],
            scaled_df['BiSize'].values[self.current_step:end],
            scaled_df['Ask'].values[self.current_step:end],
            scaled_df['AskSize'].values[self.current_step:end],
            scaled_df['Volume'].values[self.current_step:end],
        ])

        scaled_history = self.scaler.fit_transform(self.account_history)

        obs = np.append(
            obs, scaled_history[:, -(self.lookback_window_size + 1):], axis=0)

        return obs

    def _reset_session(self):
        self.current_step = 0

        if self.serial:
            self.steps_left = len(self.df) - self.lookback_window_size - 1
            self.frame_start = self.lookback_window_size
        else:
            self.steps_left = np.random.randint(1, MAX_TRADING_SESSION)
            self.frame_start = np.random.randint(
                self.lookback_window_size, len(self.df) - self.steps_left)

        self.active_df = self.df[self.frame_start - self.lookback_window_size:
                                 self.frame_start + self.steps_left]

    def reset(self):
        self.balance = self.initial_balance
        self.net_worth = self.initial_balance
        self.btc_held = 0

        self._reset_session()

        self.account_history = np.repeat([
            [self.balance],
            [0],
            [0],
            [0],
            [0]
        ], self.lookback_window_size + 1, axis=1)
        self.trades = []

        return self._next_observation()

    def _get_current_price(self):
        return self.df['Last'].values[self.frame_start + self.current_step]

    def _get_ask_price(self):
        return self.df['Ask'].values[self.frame_start + self.current_step]

    def _get_bid_price(self):
        return self.df['Bid'].values[self.frame_start + self.current_step]

    def _take_action(self, action, current_price, buy_price, sell_price):
        action_type = action[0]
        amount = action[1] / 10

        btc_bought = 0
        btc_sold = 0
        cost = 0
        sales = 0

        if action_type < 1:
            btc_bought = self.balance / buy_price * amount
            cost = btc_bought * buy_price * (1 + self.commission)

            self.btc_held += btc_bought
            self.balance -= cost

        elif action_type < 2:
            btc_sold = self.btc_held * amount
            sales = btc_sold * sell_price * (1 - self.commission)

            self.btc_held -= btc_sold
            self.balance += sales

        if btc_sold > 0 or btc_bought > 0:
            self.trades.append({'step': self.frame_start + self.current_step,
                                'amount': btc_sold if btc_sold > 0 else btc_bought, 'total': sales if btc_sold > 0 else cost,
                                'type': "sell" if btc_sold > 0 else "buy"})

        self.net_worth = self.balance + self.btc_held * sell_price

        self.account_history = np.append(self.account_history, [
            [self.balance],
            [btc_bought],
            [cost],
            [btc_sold],
            [sales]
        ], axis=1)

    def step(self, action):
        current_price = self._get_current_price()
        buy_price = self._get_ask_price()
        sell_price = self._get_bid_price()

        prev_net_worth = self.net_worth

        self._take_action(action, current_price, buy_price, sell_price)

        self.steps_left -= 1
        self.current_step += 1

        if self.steps_left == 0:
            self.balance += self.btc_held * sell_price
            self.btc_held = 0

            self._reset_session()

        obs = self._next_observation()
        reward = self.net_worth - prev_net_worth
        done = self.net_worth <= 0

        return obs, reward, done, {}

    def render(self, mode='human', **kwargs):
        if mode == 'system':
            print('Price: ' + str(self._get_current_price()))
            print(
                'Bought: ' + str(self.account_history[2][self.current_step + self.frame_start]))
            print(
                'Sold: ' + str(self.account_history[4][self.current_step + self.frame_start]))
            print('Net worth: ' + str(self.net_worth))

        elif mode == 'human':
            if self.viewer is None:
                self.viewer = BitcoinTradingGraph(
                    self.df, kwargs.get('title', None))

            self.viewer.render(self.frame_start + self.current_step,
                               self.net_worth,
                               self.trades,
                               window_size=self.lookback_window_size)

     def close(self):
        if self.viewer is not None:
            self.viewer.close()
            self.viewer = None

非常感谢,如果我还需要什么,请告诉我。

更新

有人吗?

如果有帮助,请在上面的Github链接下载完整的项目,更新BitcoinTradingEnv.py文件以匹配我在这里发布的文件,并将数据文件夹中的.csv文件更新为此部分文件(每个文件都在其自己的列中):




    





    
Time    Open    Close   Last    LastSize    Bid BidSize Ask AskSize Volume
1   0.01    3.38    3.38    285 3.95    11  3.99    1   460600
2   0.01    3.38    3.38    285 3.95    11  4.00    5   460600
3   0.01    3.38    3.38    285 3.93    2   4.00    5   463936
4   0.01    3.38    3.38    285 3.93    8   3.95    1   463936
5   0.01    3.38    3.38    285 3.95    4   4.00    5   464136
6   0.01    3.38    3.38    285 3.95    4   4.00    6   464136
7   0.01    3.38    3.38    285 3.95    4   4.00    6   464146
8   0.01    3.38    3.38    285 3.93    8   4.00    6   464586
9   0.01    3.38    3.38    285 3.93    8   3.99    1   464586
10  0.01    3.38    3.38    285 3.93    8   3.99    4   464586
11  0.01    3.38    3.38    285 3.94    13  3.99    4   464586
12  0.01    3.38    3.38    285 3.94    13  3.99    4   464590
13  0.01    3.38    3.38    285 3.94    13  3.99    4   464661
14  0.01    3.38    3.38    285 3.95    5   3.99    4   464661
15  0.01    3.38    3.38    285 3.95    5   3.99    3   465261
16  0.01    3.38    3.38    285 3.94    13  3.98    1   465265
17  0.01    3.38    3.38    285 3.94    13  3.98    1   467544
18  0.01    3.38    3.38    285 3.96    5   3.98    1   468544
19  0.01    3.38    3.38    285 3.96    5   3.98    1   468602
20  0.01    3.38    3.38    285 3.96    5   3.99    3   468802
21  0.01    3.38    3.38    285 3.96    4   3.99    2   470247
22  0.01    3.38    3.38    285 3.96    4   3.99    2   470747
23  0.01    3.38    3.38    285 3.96    4   3.97    5   470747
24  0.01    3.38    3.38    285 3.95    1   3.97    5   471747
25  0.01    3.38    3.38    285 3.95    1   3.97    5   471948
26  0.01    3.38    3.38    285 3.95    1   3.97    5   471958
27  0.01    3.38    3.38    285 3.95    1   3.99    2   472958
28  0.01    3.38    3.38    285 3.95    2   3.97    3   472958
29  0.01    3.38    3.38    285 3.95    1   3.97    3   473033
30  0.01    3.38    3.38    285 3.95    1   3.97    2   473117
31  0.01    3.38    3.38    285 3.96    2   3.97    2   473117
32  0.01    3.38    3.38    285 3.96    2   3.97    2   473127
33  0.01    3.38    3.38    285 3.96    2   3.99    2   473327
34  0.01    3.38    3.38    285 3.96    2   3.99    2   473343
35  0.01    3.38    3.38    285 3.97    1   3.99    2   473343
36  0.01    3.38    3.38    285 3.99    1   4.00    13  473818
37  0.01    3.38    3.38    285 3.99    1   4.00    1   476618
38  0.01    3.38    3.38    285 3.99    1   4.00    3   477918
39  0.01    3.38    3.38    285 3.99    5   4.00    1   478425
40  0.01    3.38    3.38    285 3.99    5   4.00    1   479686
41  0.01    3.38    3.38    285 3.99    4   4.00    1   479686
42  0.01    3.38    3.38    285 3.99    4   4.00    1   480366
43  0.01    3.38    3.38    285 3.95    6   3.97    1   481115
44  0.01    3.38    3.38    285 3.95    6   4.00    1   481162
45  0.01    3.38    3.38    285 3.95    6   4.00    8   481162
46  0.01    3.38    3.38    285 3.95    6   3.99    5   481226
47  0.01    3.38    3.38    285 3.98    1   3.99    5   481279
48  0.01    3.38    3.38    285 3.95    6   3.99    5   481929
49  0.01    3.38    3.38    285 3.95    6   3.98    1   481929
50  0.01    3.38    3.38    285 3.95    6   3.98    1   482041
51  0.01    3.38    3.38    285 3.96    6   3.98    1   482041
52  0.01    3.38    3.38    285 3.96    6   3.98    1   482066
53  0.01    3.38    3.38    285 3.96    6   3.98    1   482093
54  0.01    3.38    3.38    285 3.96    6   3.98    1   482137
55  0.01    3.38    3.38    285 3.96    6   3.98    1   484512
56  0.01    3.38    3.38    285 3.96    6   3.98    1   484541
57  0.01    3.38    3.38    285 3.96    6   3.98    4   484541
58  0.01    3.38    3.38    285 3.96    6   3.98    4   488541
59  0.01    3.38    3.38    285 3.96    6   3.98    1   488541
60  0.01    3.38    3.38    285 3.96    6   3.98    1   489541
61  0.01    3.38    3.38    285 3.95    12  3.96    3   490171
62  0.01    3.38    3.38    285 3.95    12  3.96    5   490171
63  0.01    3.38    3.38    285 3.92    10  3.95    56  492046
64  0.01    3.38    3.38    285 3.92    10  3.95    60  492046
65  0.01    3.38    3.38    285 3.92    10  3.95    60  502046
66  0.01    3.38    3.38    285 3.92    10  3.95    56  502046
67  0.01    3.38    3.38    285 3.92    8   3.95    56  503418
68  0.01    3.38    3.38    285 3.92    8   3.95    56  503427
69  0.01    3.38    3.38    285 3.92    8   3.95    54  503617
70  0.01    3.38    3.38    285 3.92    8   3.95    54  503817
71  0.01    3.38    3.38    285 3.92    6   3.95    54  505167
72  0.01    3.38    3.38    285 3.91    62  3.92    7   505727
73  0.01    3.38    3.38    285 3.92    7   3.95    54  506517
74  0.01    3.38    3.38    285 3.92    7   3.95    54  506867
75  0.01    3.38    3.38    285 3.92    7   3.95    54  506877
76  0.01    3.38    3.38    285 3.94    4   3.95    54  506877
77  0.01    3.38    3.38    285 3.94    2   3.95    54  507572
78  0.01    3.38    3.38    285 3.94    3   3.95    54  507572
79  0.01    3.38    3.38    285 3.94    3   3.95    54  507972
80  0.01    3.38    3.38    285 3.92    8   3.94    9   508592
81  0.01    3.38    3.38    285 3.91    62  3.92    50  509192
82  0.01    3.38    3.38    285 3.91    16  3.91    1   514523
83  0.01    3.38    3.38    285 3.91    1   3.91    1   516023
84  0.01    3.38    3.38    285 3.89    16  3.90    17  518826
85  0.01    3.38    3.38    285 3.89    12  3.90    17  520025
86  0.01    3.38    3.38    285 3.86    21  3.87    7   522335
87  0.01    3.38    3.38    285 3.86    21  3.87    7   522355
88  0.01    3.38    3.38    285 3.86    21  3.87    4   522655
89  0.01    3.38    3.38    285 3.86    3   3.87    1   524452
90  0.01    3.38    3.38    285 3.85    5   3.87    1   525652
91  0.01    3.38    3.38    285 3.83    6   3.86    1   526575
92  0.01    3.38    3.38    285 3.84    1   3.86    1   526675
93  0.01    3.38    3.38    285 3.84    6   3.85    4   526675
94  0.01    3.38    3.38    285 3.85    1   3.86    1   527575
95  0.01    3.38    3.38    285 3.85    15  3.87    1   528175
96  0.01    3.38    3.38    285 3.87    4   3.90    2   529300
97  0.01    3.38    3.38    285 3.87    2   3.88    1   531300
98  0.01    3.38    3.38    285 3.87    2   3.90    2   531325
99  0.01    3.38    3.38    285 3.87    8   3.90    2   531325
100 0.01    3.38    3.38    285 3.87    8   3.90    2   531625
101 0.01    3.38    3.38    285 3.90    2   3.91    6   532475
102 0.01    3.38    3.38    285 3.87    8   3.91    6   532675
103 0.01    3.38    3.38    285 3.88    2   3.91    6   532675
104 0.01    3.38    3.38    285 3.88    2   3.92    1   534590
105 0.01    3.38    3.38    285 3.88    2   3.92    1   534670
106 0.01    3.38    3.38    285 3.90    1   3.92    1   534720
107 0.01    3.38    3.38    285 3.90    1   3.92    1   535223
108 0.01    3.38    3.38    285 3.90    1   3.92    3   535723
109 0.01    3.38    3.38    285 3.90    1   3.91    4   535778
110 0.01    3.38    3.38    285 3.87    9   3.90    4   535939
111 0.01    3.38    3.38    285 3.88    2   3.90    2   535939
112 0.01    3.38    3.38    285 3.88    2   3.90    2   536440
113 0.01    3.38    3.38    285 3.88    1   3.90    2   536470
114 0.01    3.38    3.38    285 3.87    9   3.91    3   536710
115 0.01    3.38    3.38    285 3.87    8   3.91    3   536780
116 0.01    3.38    3.38    285 3.87    8   3.91    2   536780
117 0.01    3.38    3.38    285 3.88    1   3.91    2   536780
118 0.01    3.38    3.38    285 3.88    5   3.91    2   536780
119 0.01    3.38    3.38    285 3.88    5   3.91    2   536795
120 0.01    3.38    3.38    285 3.89    1   3.91    2   536795
121 0.01    3.38    3.38    285 3.89    1   3.89    2   536945
122 0.01    3.38    3.38    285 3.88    3   3.89    2   537495
123 0.01    3.38    3.38    285 3.88    3   3.89    2   538495
124 0.01    3.38    3.38    285 3.88    3   3.91    2   538495
125 0.01    3.38    3.38    285 3.88    3   3.90    2   538495
126 0.01    3.38    3.38    285 3.88    3   3.91    2   538645
127 0.01    3.38    3.38    285 3.88    4   3.91    2   538645
128 0.01    3.38    3.38    285 3.88    5   3.91    2   538645
129 0.01    3.38    3.38    285 3.89    1   3.91    2   538645
130 0.01    3.38    3.38    285 3.89    1   3.91    2   538645
131 0.01    3.38    3.38    285 3.87    7   3.88    48  539326
132 0.01    3.38    3.38    285 3.87    4   3.88    48  539868
133 0.01    3.38    3.38    285 3.87    4   3.88    48  540368
134 0.01    3.38    3.38    285 3.86    6   3.87    1   541081
135 0.01    3.38    3.38    285 3.86    2   3.87    1   541581
136 0.01    3.38    3.38    285 3.86    2   3.87    6   541581
137 0.01    3.38    3.38    285 3.86    2   3.87    6   541608
138 0.01    3.38    3.38    285 3.86    2   3.87    11  541608
139 0.01    3.38    3.38    285 3.85    2   3.86    2   542708
140 0.01    3.38    3.38    285 3.85    2   3.86    2   542792
141 0.01    3.38    3.38    285 3.83    6   3.85    1   543176
142 0.01    3.38    3.38    285 3.83    6   3.85    1   543226
143 0.01    3.38    3.38    285 3.83    6   3.87    5   543226
144 0.01    3.38    3.38    285 3.82    11  3.83    19  543931
145 0.01    3.38    3.38    285 3.82    2   3.83    18  545396
146 0.01    3.38    3.38    285 3.82    1   3.82    1   545896
147 0.01    3.38    3.38    285 3.82    1   3.82    1   546896
148 0.01    3.38    3.38    285 3.82    1   3.83    18  546896
149 0.01    3.38    3.38    285 3.83    6   3.84    1   548771
150 0.01    3.38    3.38    285 3.83    6   3.87    18  549021
151 0.01    3.38    3.38    285 3.83    5   3.87    18  549121
152 0.01    3.38    3.38    285 3.83    10  3.87    18  549121
153 0.01    3.38    3.38    285 3.84    3   3.85    8   549121
154 0.01    3.38    3.38    285 3.84    2   3.85    8   549221
155 0.01    3.38    3.38    285 3.84    3   3.88    49  549421
156 0.01    3.38    3.38    285 3.84    4   3.88    49  549771
157 0.01    3.38    3.38    285 3.84    3   3.85    7   549771
158 0.01    3.38    3.38    285 3.84    3   3.85    7   549801
159 0.01    3.38    3.38    285 3.84    3   3.85    6   549901
160 0.01    3.38    3.38    285 3.83    10  3.84    6   550231
161 0.01    3.38    3.38    285 3.83    5   3.84    6   550231
162 0.01    3.38    3.38    285 3.82    12  3.84    6   550231
163 0.01    3.38    3.38    285 3.83    1   3.84    6   550231
164 0.01    3.38    3.38    285 3.84    4   3.85    6   551021
165 0.01    3.38    3.38    285 3.84    4   3.85    6   552294
166 0.01    3.38    3.38    285 3.84    4   3.85    4   552509
167 0.01    3.38    3.38    285 3.84    4   3.85    4   553509
168 0.01    3.38    3.38    285 3.84    4   3.85    4   553524
169 0.01    3.38    3.38    285 3.84    4   3.85    4   553529
170 0.01    3.38    3.38    285 3.84    4   3.85    4   553579
171 0.01    3.38    3.38    285 3.84    4   3.85    4   553679
172 0.01    3.38    3.38    285 3.83    1   3.84    2   554159
173 0.01    3.38    3.38    285 3.83    1   3.84    1   554167
174 0.01    3.38    3.38    285 3.83    1   3.84    2   554167
175 0.01    3.38    3.38    285 3.82    12  3.83    2   554267
176 0.01    3.38    3.38    285 3.82    12  3.83    1   554267
177 0.01    3.38    3.38    285 3.82    12  3.84    2   554267
178 0.01    3.38    3.38    285 3.82    12  3.84    2   555277
179 0.01    3.38    3.38    285 3.82    2   3.82    1   557459
180 0.01    3.38    3.38    285 3.82    1   3.83    2   557599
181 0.01    3.38    3.38    285 3.82    1   3.83    2   558099
182 0.01    3.38    3.38    285 3.82    1   3.84    2   558099
183 0.01    3.38    3.38    285 3.82    1   3.84    2   558599
184 0.01    3.38    3.38    285 3.80    1   3.82    2   561599
185 0.01    3.38    3.38    285 3.80    1   3.08    1   563050
186 0.01    3.38    3.38    285 3.80    6   3.81    1   563081
187 0.01    3.38    3.38    285 3.79    2   3.80    13  563732
188 0.01    3.38    3.38    285 3.79    1   3.80    13  564882
189 0.01    3.38    3.38    285 3.79    1   3.80    13  564898
190 0.01    3.38    3.38    285 3.78    2   3.79    1   565741
191 0.01    3.38    3.38    285 3.79    1   3.80    13  566241
192 0.01    3.38    3.38    285 3.77    6   3.78    4   566936
193 0.01    3.38    3.38    285 3.77    6   3.78    4   567036
194 0.01    3.38    3.38    285 3.75    2   3.77    11  569674
195 0.01    3.38    3.38    285 3.75    2   3.77    11  570324
196 0.01    3.38    3.38    285 3.75    7   3.77    5   571666
197 0.01    3.38    3.38    285 3.75    6   3.76    7   571766
198 0.01    3.38    3.38    285 3.73    10  3.75    5   573668
199 0.01    3.38    3.38    285 3.72    2   3.73    6   574993
200 0.01    3.38    3.38    285 3.73    16  3.75    6   575668
201 0.01    3.38    3.38    285 3.72    17  3.75    1   576518
202 0.01    3.38    3.38    285 3.72    12  3.76    7   577018
203 0.01    3.38    3.38    285 3.72    7   3.76    7   578336
204 0.01    3.38    3.38    285 3.70    20  3.72    13  579111
205 0.01    3.38    3.38    285 3.70    20  3.72    16  579511
206 0.01    3.38    3.38    285 3.07    17  3.72    16  579761
207 0.01    3.38    3.38    285 3.72    3   3.74    1   582000
208 0.01    3.38    3.38    285 3.72    3   3.74    1   584810
209 0.01    3.38    3.38    285 3.70    3   3.72    1   591186
210 0.01    3.38    3.38    285 3.69    5   3.72    1   592342
211 0.01    3.38    3.38    285 3.69    5   3.73    2   592498
212 0.01    3.38    3.38    285 3.70    3   3.73    2   592798
213 0.01    3.38    3.38    285 3.72    19  3.73    2   593674
214 0.01    3.38    3.38    285 3.73    1   3.76    15  595947
215 0.01    3.38    3.38    285 3.73    1   3.76    5   597082
216 0.01    3.38    3.38    285 3.73    9   3.75    1   597582
217 0.01    3.38    3.38    285 3.73    6   3.75    1   597583
218 0.01    3.38    3.38    285 3.73    6   3.76    17  597583
219 0.01    3.38    3.38    285 3.73    6   3.75    2   597583
220 0.01    3.38    3.38    285 3.73    6   3.75    2   598583
221 0.01    3.38    3.38    285 3.75    3   3.76    17  598783
222 0.01    3.38    3.38    285 3.74    5   3.75    2   599760
223 0.01    3.38    3.38    285 3.75    2   3.76    17  600055
224 0.01    3.38    3.38    285 3.75    2   3.76    3   600055
225 0.01    3.38    3.38    285 3.75    10  3.77    14  601955
226 0.01    3.38    3.38    285 3.75    12  3.77    14  601980
227 0.01    3.38    3.38    285 3.76    5   3.77    13  602222
228 0.01    3.38    3.38    285 3.76    5   3.77    2   603252
229 0.01    3.38    3.38    285 3.76    5   3.79    7   603252
230 0.01    3.38    3.38    285 3.77    2   3.79    7   603252
231 0.01    3.38    3.38    285 3.80    2   3.84    7   603972
232 0.01    3.38    3.38    285 3.80    2   3.84    7   604508
233 0.01    3.38    3.38    285 3.80    5   3.84    7   604508
234 0.01    3.38    3.38    285 3.80    26  3.84    7   609508
235 0.01    3.38    3.38    285 3.80    26  3.84    7   609508
236 0.01    3.38    3.38    285 3.80    25  3.84    7   610508
237 0.01    3.38    3.38    285 3.80    26  3.84    7   610508
238 0.01    3.38    3.38    285 3.81    5   3.84    7   610509
239 0.01    3.38    3.38    285 3.81    5   3.84    7   611000
240 0.01    3.38    3.38    285 3.81    4   3.84    7   612060
241 0.01    3.38    3.38    285 3.80    25  3.84    7   613779
242 0.01    3.38    3.38    285 3.80    25  3.83    5   613979
243 0.01    3.38    3.38    285 3.80    13  3.83    5   615519
244 0.01    3.38    3.38    285 3.77    1   3.8 3   616972
245 0.01    3.38    3.38    285 3.77    1   3.83    16  616972
246 0.01    3.38    3.38    285 3.77    1   3.83    16  617472
247 0.01    3.38    3.38    285 3.77    1   3.83    11  617472
248 0.01    3.38    3.38    285 3.77    1   3.83    11  617522
249 0.01    3.38    3.38    285 3.80    4   3.83    11  617522
250 0.01    3.38    3.38    285 3.81    9   3.83    11  617822
251 0.01    3.38    3.38    285 3.81    5   3.83    11  618222
252 0.01    3.38    3.38    285 3.81    5   3.83    11  618422
253 0.01    3.38    3.38    285 3.80    4   3.84    2   618922
254 0.01    3.38    3.38    285 3.80    4   3.84    13  618922
255 0.01    3.38    3.38    285 3.83    3   3.84    13  618922
256 0.01    3.38    3.38    285 3.77    1   3.8 3   623682
257 0.01    3.38    3.38    285 3.77    1   3.84    14  623982
258 0.01    3.38    3.38    285 3.78    2   3.84    14  623982
259 0.01    3.38    3.38    285 3.80    3   3.84    14  624002
260 0.01    3.38    3.38    285 3.80    4   3.84    14  624002
261 0.01    3.38    3.38    285 3.80    1   3.84    14  624002
262 0.01    3.38    3.38    285 3.80    2   3.84    14  624002
263 0.01    3.38    3.38    285 3.80    2   3.83    6   624097
264 0.01    3.38    3.38    285 3.81    2   3.83    6   624097
265 0.01    3.38    3.38    285 3.81    1   3.83    6   624297
266 0.01    3.38    3.38    285 3.81    1   3.82    5   625297
267 0.01    3.38    3.38    285 3.81    1   3.82    5   625667
268 0.01    3.38    3.38    285 3.81    1   3.82    5   625767
269 0.01    3.38    3.38    285 3.81    1   3.83    6   625767
270 0.01    3.38    3.38    285 3.81    1   3.83    6   625787
271 0.01    3.38    3.38    285 3.81    1   3.83    6   625802
272 0.01    3.38    3.38    285 3.81    1   3.83    6   625902
273 0.01    3.38    3.38    285 3.81    4   3.82    2   625990
274 0.01    3.38    3.38    285 3.82    12  3.83    6   626240
275 0.01    3.38    3.38    285 3.82    2   3.83    2   628039
276 0.01    3.38    3.38    285 3.82    2   3.83    2   628039
277 0.01    3.38    3.38    285 3.82    2   3.83    2   628339
278 0.01    3.38    3.38    285 3.82    21  3.83    2   628339
279 0.01    3.38    3.38    285 3.82    21  3.83    2   628339
280 0.01    3.38    3.38    285 3.83    2   3.84    2   628589
281 0.01    3.38    3.38    285 3.83    17  3.84    2   628589
282 0.01    3.38    3.38    285 3.83    20  3.84    5   628589
283 0.01    3.38    3.38    285 3.84    1   3.85    4   629169
284 0.01    3.38    3.38    285 3.83    14  3.84    1   629569
285 0.01    3.38    3.38    285 3.84    4   3.85    2   630204
286 0.01    3.38    3.38    285 3.84    4   3.85    2   630254
287 0.01    3.38    3.38    285 3.84    4   3.85    2   630396
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/49247
 
2106 次点击  
文章 [ 1 ]  |  最新文章 4 年前
Matt Wilson
Reply   •   1 楼
Matt Wilson    4 年前

我找到了答案。

我改了行:

scaled_df = pd.DataFrame(end, columns=self.df.columns)

…阅读:

scaled_df = pd.DataFrame(data=scaled_df, columns=self.df.columns)

…然后改变:

self.observation_space = spaces.Box(
            low=0, high=1, shape=(10, lookback_window_size + 1), dtype=np.float16)

…有一个 14 而不是 10 ,并且它起作用。谢谢大家。