0

:2: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray x_train, y_train = np.array(x_train), np.array(y_train)

What does this mean and how can I solve it? This is the code I am running:

    #import libraries:
    import math
    import time
    import pandas as pd
    import datetime
    import numpy as np
    import streamlit as st
    import matplotlib.pyplot as plt
    import pandas_datareader as web
    from tensorflow.keras.models import Sequential
    from sklearn.preprocessing import MinMaxScaler
    from tensorflow.keras.layers import Dense, Dropout, LSTM
    plt.style.use('fivethirtyeight')
    import tensorflow.compat.v2 as tf
    
    #Scale the data:
    scaler = MinMaxScaler(feature_range=(0,1))
    scaled_data = scaler.fit_transform(dataset)
    scaled_data

    #Create the training dataset:
    #Create the scaled training dataset:
    train_data = scaled_data[0:training_data_len, :]
    #Split the data into x_train and y_train datasets:
    x_train = []
    y_train = []

    for i in range(60, len(train_data)):
        x_train.append(train_data[i-60:, 0])
        y_train.append(train_data[1,0])
        if i <= 61:
             print(x_train)
             print(y_train)
             print()

    #Convert the x_train and y_train to numpy arrays:
    x_train, y_train = np.array(x_train), np.array(y_train)
Black040
  • 3
  • 2
  • 5
  • It is just a warning. For further study seek on [SO](https://stackoverflow.com/questions/63097829/debugging-numpy-visibledeprecationwarning-ndarray-from-ragged-nested-sequences). – Ali_Sh Sep 10 '21 at 17:06
  • 2
    Does this answer your question? [Debugging Numpy VisibleDeprecationWarning (ndarray from ragged nested sequences)](https://stackoverflow.com/questions/63097829/debugging-numpy-visibledeprecationwarning-ndarray-from-ragged-nested-sequences) – Félix Adriyel Gagnon-Grenier Sep 16 '21 at 18:46

0 Answers0