import numpy as np
from keras.models import Sequential
from keras.layers import Dense, LSTM
# Input Sequence
data = np.array([77, 8, 31, 89, 13, 96, 53, 62, 99, 33, 91, 22, 62, 17, 82, 50, 66, 98, 26])
# Preprocessing Data
X = data[:-1].reshape(-1, 1, 1) # Input
Y = data[1:].reshape(-1, 1) # Output
# LSTM Model
model = Sequential()
model.add(LSTM(50, activation='relu', input_shape=(1, 1)))
model.add(Dense(1))
model.compile(optimizer='adam', loss='mse')
# Training
model.fit(X, Y, epochs=100, verbose=0)
# Prediction
new_sequence = np.array([62]).reshape(1, 1, 1)
predicted = model.predict(new_sequence)
print("Next Number Prediction:", predicted)
aW1wb3J0IG51bXB5IGFzIG5wCmZyb20ga2VyYXMubW9kZWxzIGltcG9ydCBTZXF1ZW50aWFsCmZyb20ga2VyYXMubGF5ZXJzIGltcG9ydCBEZW5zZSwgTFNUTQoKIyBJbnB1dCBTZXF1ZW5jZQpkYXRhID0gbnAuYXJyYXkoWzc3LCA4LCAzMSwgODksIDEzLCA5NiwgNTMsIDYyLCA5OSwgMzMsIDkxLCAyMiwgNjIsIDE3LCA4MiwgNTAsIDY2LCA5OCwgMjZdKQoKIyBQcmVwcm9jZXNzaW5nIERhdGEKWCA9IGRhdGFbOi0xXS5yZXNoYXBlKC0xLCAxLCAxKSAgIyBJbnB1dApZID0gZGF0YVsxOl0ucmVzaGFwZSgtMSwgMSkgICMgT3V0cHV0CgojIExTVE0gTW9kZWwKbW9kZWwgPSBTZXF1ZW50aWFsKCkKbW9kZWwuYWRkKExTVE0oNTAsIGFjdGl2YXRpb249J3JlbHUnLCBpbnB1dF9zaGFwZT0oMSwgMSkpKQptb2RlbC5hZGQoRGVuc2UoMSkpCm1vZGVsLmNvbXBpbGUob3B0aW1pemVyPSdhZGFtJywgbG9zcz0nbXNlJykKCiMgVHJhaW5pbmcKbW9kZWwuZml0KFgsIFksIGVwb2Nocz0xMDAsIHZlcmJvc2U9MCkKCiMgUHJlZGljdGlvbgpuZXdfc2VxdWVuY2UgPSBucC5hcnJheShbNjJdKS5yZXNoYXBlKDEsIDEsIDEpCnByZWRpY3RlZCA9IG1vZGVsLnByZWRpY3QobmV3X3NlcXVlbmNlKQpwcmludCgiTmV4dCBOdW1iZXIgUHJlZGljdGlvbjoiLCBwcmVkaWN0ZWQp