Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MinMaxScaler not working in this example #1

Open
mfethe1 opened this issue Jan 13, 2020 · 2 comments
Open

MinMaxScaler not working in this example #1

mfethe1 opened this issue Jan 13, 2020 · 2 comments

Comments

@mfethe1
Copy link

mfethe1 commented Jan 13, 2020

Everything runs normally up until the MinMaxScaler is called in the for loop.

high_prices = df.loc[:,'High'].as_matrix()
low_prices = df.loc[:,'Low'].as_matrix()
mid_prices = (high_prices+low_prices)/2.0

print(mid_prices)
[20.25 19.865 20.34 ... 27.97 27.62 27.3425]
main:1: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.
main:2: FutureWarning: Method .as_matrix will be removed in a future version. Use .values instead.

smoothing_window_size = 2500
for di in range(0,10000,smoothing_window_size):
scaler.fit(train_data[di:di+smoothing_window_size,:])
train_data[di:di+smoothing_window_size,:] = scaler.transform(train_data[di:di+smoothing_window_size,:])

You normalize the last bit of remaining data

scaler.fit(train_data[di+smoothing_window_size:,:])
train_data[di+smoothing_window_size:,:] = scaler.transform(train_data[di+smoothing_window_size:,:])
Traceback (most recent call last):

File "", line 3, in
scaler.fit(train_data[di:di+smoothing_window_size,:])

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py", line 325, in fit
return self.partial_fit(X, y)

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\preprocessing\data.py", line 353, in partial_fit
force_all_finite="allow-nan")

File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 550, in check_array
context))

ValueError: Found array with 0 sample(s) (shape=(0, 1)) while a minimum of 1 is required by MinMaxScaler.

@lefig
Copy link

lefig commented Feb 14, 2020

Me too. I have same problem. Pity

@heisendelta
Copy link

This is probably because you aren't using as many data points as the tutorial. To fix this, simply lower the smoothing_window_size variable. The end of the for loop in the next line should be smaller than the length of your test data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants