llSourcell / How-to-Predict-Stock-Prices-Easily-Demo

How to Predict Stock Prices Easily - Intro to Deep Learning #7 by Siraj Raval on Youtube
771 stars 590 forks source link

NameError: name 'xrange' is not defined #8

Closed zhivko closed 7 years ago

zhivko commented 7 years ago

Testing this on python3 and jupyter notebook, I get:


NameError Traceback (most recent call last)

in () 1 #Step 4 - Plot the predictions! ----> 2 predictions = lstm.predict_sequences_multiple(model, X_test, 50, 50) 3 lstm.plot_results_multiple(predictions, y_test, 50) ~\git\How-to-Predict-Stock-Prices-Easily-Demo\lstm.py in predict_sequences_multiple(model, data, window_size, prediction_len) 99 #Predict sequence of 50 steps before shifting prediction run forward by 50 steps 100 prediction_seqs = [] --> 101 for i in xrange(len(data)/prediction_len): 102 curr_frame = data[i*prediction_len] 103 predicted = [] NameError: name 'xrange' is not defined
zhivko commented 7 years ago

Replacing xrange with range for python3 I get this:


TypeError Traceback (most recent call last)

in () 1 #Step 4 - Plot the predictions! ----> 2 predictions = lstm.predict_sequences_multiple(model, X_test, 50, 50) 3 lstm.plot_results_multiple(predictions, y_test, 50) ~\git\How-to-Predict-Stock-Prices-Easily-Demo\lstm.py in predict_sequences_multiple(model, data, window_size, prediction_len) 99 #Predict sequence of 50 steps before shifting prediction run forward by 50 steps 100 prediction_seqs = [] --> 101 for i in range(len(data)/prediction_len): 102 curr_frame = data[i*prediction_len] 103 predicted = [] TypeError: 'float' object cannot be interpreted as an integer
zhivko commented 7 years ago

OK fixed it with int() function and range for usage in python3.

fleeaway commented 6 years ago

sorry, i don't understand,is for i in range(int(len(data)/prediction_len))??