This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import packages | |
import pandas as pd | |
import numpy as np | |
import keras | |
import matplotlib.pyplot as plt | |
from sklearn.preprocessing import MinMaxScaler | |
from pandas.plotting import register_matplotlib_converters | |
register_matplotlib_converters() | |
from keras.preprocessing.sequence import TimeseriesGenerator | |
from keras.models import Sequential |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import packages | |
import pandas as pd | |
import numpy as np | |
import keras | |
import matplotlib.pyplot as plt | |
from sklearn.preprocessing import MinMaxScaler | |
from pandas.plotting import register_matplotlib_converters | |
register_matplotlib_converters() | |
from keras.preprocessing.sequence import TimeseriesGenerator | |
from keras.models import Sequential |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
df = pd.read_pickle(r'C:\..........\data.pkl') # read data | |
y_col='y' # define y variable, i.e., what we want to predict | |
print(df.shape) # print the number of rows anc columns | |
df.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.figure(figsize=(50,4)) | |
plt.plot(range(len(df)),df[y_col]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test_size = int(len(df) * 0.1) # the test data will be 10% (0.1) of the entire data | |
train = df.iloc[:-test_size,:].copy() | |
# the copy() here is important, it will prevent us from getting: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_index,col_indexer] = value instead | |
test = df.iloc[-test_size:,:].copy() | |
print(train.shape, test.shape) | |
>>> ((28916, 4), (3212, 4)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plt.figure(figsize=(50,4)) | |
plt.plot(train.index,train[y_col],label='Train'); | |
plt.plot(test.index,test[y_col],label='test') | |
plt.legend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#separate X and y only for the train data (for now) | |
X_train = train.drop(y_col,axis=1).copy() | |
y_train = train[[y_col]].copy() # the double brakets here are to keep the y in a dataframe format, otherwise it will be pandas Series | |
print(X_train.shape, y_train.shape) | |
>>> (28916, 3) (28916, 1) |
OlderNewer