<jupyter_start><jupyter_text>Experimenting<jupyter_code>import numpy as np

from sklearn import metrics
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from dbtensorflow.models import UnsupervisedDBN

import tensorflow as tf
from tensorflow.keras.layers import LSTM , Dropout , Dense
from tensorflow.keras.models import Sequential

import pandas as pd 
df = pd.read_csv('./data/NSE50.csv')
df['Date'] = pd.to_datetime(df['Date'])
df.index = df['Date']
df.drop(df[df['High']==df['Low']].index , axis=0 , inplace=True)
data = df['Close'].copy()
# Training and testing data
train_size = len(data) - 66
train = data[:train_size]
test = data[train_size :]
scaler = MinMaxScaler(feature_range=(0,1))
scaled_train = scaler.fit_transform(np.array(train).reshape(-1,1))
backcheck = 60
X_train , y_train = [] , []
for i in range(backcheck , len(scaled_train)):
    X_train.append(scaled_train[i-backcheck : i ,0])
    y_train.append(scaled_train[i,0])
X_train = np.array(X_train)
y_train = np.array(y_train)
dbn = UnsupervisedDBN(hidden_layers_structure=[120],
                      batch_size=32,
                      learning_rate_rbm=0.001,
                      n_epochs_rbm=100,
                      activation_function='relu')
lstm = Sequential()
lstm.add(LSTM(50))
lstm.add(LSTM(50))
lstm.add(Dense(1))
model = Pipeline(steps=[('dbn', dbn),
                             ('lstm', lstm)])
model.fit(X_train , y_train)<jupyter_output>[START] Pre-training step:
WARNING:tensorflow:From /home/rahul/Desktop/dbn/dbtensorflow/models.py:149: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.cast` instead.
>> Epoch 1 finished 	RBM Reconstruction error 3.412181
>> Epoch 2 finished 	RBM Reconstruction error 0.209217
>> Epoch 3 finished 	RBM Reconstruction error 0.161272
>> Epoch 4 finished 	RBM Reconstruction error 0.128375
>> Epoch 5 finished 	RBM Reconstruction error 0.103169
>> Epoch 6 finished 	RBM Reconstruction error 0.083102
>> Epoch 7 finished 	RBM Reconstruction error 0.068103
>> Epoch 8 finished 	RBM Reconstruction error 0.056535
>> Epoch 9 finished 	RBM Reconstruction error 0.048111
>> Epoch 10 finished 	RBM Reconstruction error 0.041792
>> Epoch 11 finished 	RBM Reconstruction error 0.036997
>> Epoch 12 finished 	RBM Reconstruction error 0.033289
>> Epoch 13 finished 	RBM Reconstruction error 0.030441
>> Epoch 14 finished 	RBM [...]
{'fraction_non_alphanumeric': 0.10693069306930693, 'fraction_numerical': 0.056633663366336635, 'mean_word_length': 4.351694915254237, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '623439', 'license': 'MIT', 'n_tokens_mistral': 952, 'n_tokens_neox': 848, 'n_words': 221, 'path': 'PredictionModels/DBNLSTM.ipynb', 'repo_name': 'Rahul-singh98/CodeSure', 'size': '2525'}