-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvisualize.py
56 lines (43 loc) · 1.35 KB
/
visualize.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# INDIAN CURRENCY VALUE PREDICTION
# DEVELOPED BY:
# MOULISHANKAR M R
# IMPORTING MODULES
import numpy as np
import pandas as pd
from datetime import date
from tensorflow import keras
from tensorflow.keras.models import load_model
from sklearn.preprocessing import MinMaxScaler
# IMPORTING DATA
data = pd.read_csv("price.csv")
# PREPROCESSING DATA
x = []
initial_str = data["Date"][0]
initial = date(int(initial_str[-4:]),int(initial_str[3:5]),int(initial_str[:2]))
for i in range(len(data["Date"])):
final_str = data["Date"][i]
final = date(int(final_str[-4:]),int(final_str[3:5]),int(final_str[:2]))
diff = (final - initial).days
x.append(diff)
y = data["Price"].values
# RESHAPING THE DATA
x = np.reshape(x, (-1,1))
y = np.reshape(y, (-1,1))
# SCALING THE DATA
scaler_x = MinMaxScaler()
scaler_y = MinMaxScaler()
x_scaled = scaler_x.fit_transform(x)
y_scaled = scaler_y.fit_transform(y)
# LOADING THE TRAINED MODEL
model = load_model("model/model",custom_objects=None,compile=True)
# PREDICTING THE MODEL
y_est = model.predict(x_scaled)
y_est = scaler_y.inverse_transform(y_est)
# VISUALISING THE MODEL PERFORMANCE
plt.plot(x,y, color = 'blue')
plt.plot(x,y_est, color = 'red')
plt.title('Gold Price Prediction - MODEL PERFORMANCE')
plt.xlabel('Date')
plt.ylabel('Price')
plt.legend(['Actual Data', 'Predicted Data'], loc='upper left')
plt.show()