wchynto commited on
Commit
91bea57
Β·
verified Β·
1 Parent(s): 44977bb

Upload 13 files

Browse files
README.md CHANGED
@@ -1,8 +1,8 @@
1
  ---
2
- title: Saham Bbca Multivariate
3
- emoji: πŸ†
4
- colorFrom: purple
5
- colorTo: gray
6
  sdk: docker
7
  pinned: false
8
  ---
 
1
  ---
2
+ title: Cardano Forecasting
3
+ emoji: πŸ“Š
4
+ colorFrom: green
5
+ colorTo: pink
6
  sdk: docker
7
  pinned: false
8
  ---
app.py CHANGED
@@ -1,100 +1,151 @@
1
- from flask import Flask, render_template
2
  import pandas as pd
 
 
3
  import matplotlib.pyplot as plt
4
- import datetime
 
 
5
  from sklearn.model_selection import train_test_split
6
- from sklearn.metrics import mean_squared_error, mean_absolute_percentage_error, r2_score, mean_absolute_error
7
- from sklearn.linear_model import LinearRegression
8
  import os
 
9
 
10
  app = Flask(__name__)
11
 
12
- def create_lagged_features(data, lags):
13
- features = pd.DataFrame()
14
- for lag in range(1, lags + 1):
15
- features[f'Lag_{lag}'] = data.shift(lag)
16
- return features
17
-
18
- df = pd.read_csv('./dataset/BBCA-History.csv')
19
- df = df = df.reindex(index=df.index[::-1])
20
 
21
- df_display = df
 
 
 
 
 
 
 
22
 
23
- df['Tanggal'] = pd.to_datetime(df['Tanggal'], dayfirst=True)
24
- df['Perubahan%'] = df['Perubahan%'].str.replace('%', '').str.replace(',', '.').astype(float)
25
- df['Perubahan%'] = df['Perubahan%'].astype(float)
26
- df['Vol.'] = df['Vol.'].str.replace('M', 'e6').str.replace('B', 'e9').str.replace(',', '.').astype(float)
27
 
28
  # Calculate 30-day moving average
29
- df['MA30'] = df['Terakhir'].rolling(window=30).mean()
30
 
31
- # Generate the plot
32
  plt.figure(figsize=(10, 6))
33
- plt.plot(df['Tanggal'], df['Pembukaan'], label='Harga Pembukaan')
34
- plt.plot(df['Tanggal'], df['Terakhir'], label='Harga Terakhir')
35
- plt.plot(df['Tanggal'], df['MA30'], label='MA 30', linestyle='--', color='red')
36
  plt.xlabel('Tanggal')
37
  plt.ylabel('Harga')
38
  plt.title('Pergerakan Harga Pembukaan dan Terakhir dengan MA 30')
39
  plt.legend()
40
 
41
- # Save the plot to a static file
42
- plot_path = os.path.join('static', 'plot.png')
43
- plt.savefig(plot_path)
44
  plt.close()
45
 
46
- selected_features = ['Tanggal', 'Pembukaan']
47
- df = df[selected_features]
48
-
49
- df.set_index('Tanggal', inplace=True)
50
-
51
- lags = 90
52
- lagged_features = create_lagged_features(df['Pembukaan'], lags)
53
- df_with_lags = pd.concat([df, lagged_features], axis=1).dropna()
54
-
55
- X = df_with_lags[[f'Lag_{i}' for i in range(1, lags + 1)]]
56
- y = df_with_lags['Pembukaan']
57
- X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, shuffle=False)
58
-
59
- model = LinearRegression()
60
- model.fit(X_train, y_train)
61
-
62
- y_pred = model.predict(X_test)
63
 
64
  plt.figure(figsize=(10, 6))
65
- plt.plot(y_test.index, y_test, label='Actual Values')
66
- plt.plot(y_test.index, y_pred, label='Predicted Values', linestyle='--')
 
67
  plt.xlabel('Tanggal')
68
- plt.ylabel('Harga Pembukaan')
69
- plt.title('Actual vs Predicted Values')
70
  plt.legend()
71
 
72
- # Save the plot to a static file
73
- plot_training_path = os.path.join('static', 'plot_training.png')
74
- plt.savefig(plot_training_path)
75
  plt.close()
76
 
77
- mse = mean_squared_error(y_test, y_pred)
78
- mae = mean_absolute_error(y_test, y_pred)
79
- mape = mean_absolute_percentage_error(y_test, y_pred)
80
- r2 = r2_score(y_test, y_pred)
81
 
82
- last_date = y_test.index[-1]
83
- next_date = last_date + datetime.timedelta(days=1)
84
-
85
- latest_lags = X.iloc[-1].values.reshape(1, -1)
86
- next_value = model.predict(latest_lags)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  @app.route('/')
89
  def index():
90
- table_html = df_display.to_html(classes='table table-striped', index=False)
91
 
92
- return render_template('index.html', table=table_html, plot_url=plot_path)
93
 
94
- @app.route('/predict')
95
  def predict():
96
-
97
- return render_template('predict.html', plot_training_url=plot_training_path, next_date=next_date.date(), next_value=next_value[0], mse=mse, mae=mae, mape=mape, r2=r2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
 
99
  if __name__ == '__main__':
100
  app.run(debug=True)
 
1
+ from flask import Flask, render_template, request, redirect, url_for
2
  import pandas as pd
3
+ import numpy as np
4
+ import seaborn as sns
5
  import matplotlib.pyplot as plt
6
+ import joblib
7
+ from sklearn.preprocessing import MinMaxScaler
8
+ from sklearn.neighbors import LocalOutlierFactor
9
  from sklearn.model_selection import train_test_split
10
+ from sklearn.ensemble import RandomForestRegressor
 
11
  import os
12
+ from sklearn.metrics import mean_squared_error, mean_absolute_percentage_error, r2_score, mean_absolute_error
13
 
14
  app = Flask(__name__)
15
 
16
+ history_data = pd.read_csv('./datasets/HistoricalCardano.csv')
17
+ history_data = history_data.reindex(index=history_data.index[::-1])
18
+ history_data = history_data.reset_index(drop=True)
 
 
 
 
 
19
 
20
+ history_data['Tanggal'] = pd.to_datetime(history_data['Tanggal'], dayfirst=True)
21
+ history_data['Perubahan%'] = history_data['Perubahan%'].str.replace('%', '').str.replace(',', '.').astype(float)
22
+ history_data['Perubahan%'] = history_data['Perubahan%'].astype(float)
23
+ history_data['Vol.'] = history_data['Vol.'].str.replace('M', 'e6').str.replace('B', 'e9').str.replace(',', '.').astype(float)
24
+ history_data['Terakhir'] = history_data['Terakhir'].str.replace(',', '.').astype(float)
25
+ history_data['Pembukaan'] = history_data['Pembukaan'].str.replace(',', '.').astype(float)
26
+ history_data['Tertinggi'] = history_data['Tertinggi'].str.replace(',', '.').astype(float)
27
+ history_data['Terendah'] = history_data['Terendah'].str.replace(',', '.').astype(float)
28
 
29
+ history_data = history_data.set_index('Tanggal')
 
 
 
30
 
31
  # Calculate 30-day moving average
32
+ history_data['MA30'] = history_data['Terakhir'].rolling(window=30).mean()
33
 
 
34
  plt.figure(figsize=(10, 6))
35
+ plt.plot(history_data['Pembukaan'], label='Harga Pembukaan')
36
+ plt.plot(history_data['Terakhir'], label='Harga Terakhir')
37
+ plt.plot(history_data['MA30'], label='MA 30', linestyle='--', color='red')
38
  plt.xlabel('Tanggal')
39
  plt.ylabel('Harga')
40
  plt.title('Pergerakan Harga Pembukaan dan Terakhir dengan MA 30')
41
  plt.legend()
42
 
43
+ plot_ma_a = os.path.join('static', 'ma_a.png')
44
+ plt.savefig(plot_ma_a)
 
45
  plt.close()
46
 
47
+ # Calculate 30-day moving average
48
+ history_data['MA30'] = history_data['Terakhir'].rolling(window=30).mean()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
  plt.figure(figsize=(10, 6))
51
+ plt.plot(history_data['Tertinggi'], label='Harga Tertinggi')
52
+ plt.plot(history_data['Terendah'], label='Harga Terendah')
53
+ plt.plot(history_data['MA30'], label='MA 30', linestyle='--', color='red')
54
  plt.xlabel('Tanggal')
55
+ plt.ylabel('Harga')
56
+ plt.title('Pergerakan Harga Tertinggi dan Terendah dengan MA 30')
57
  plt.legend()
58
 
59
+ plot_ma_b = os.path.join('static', 'ma_b.png')
60
+ plt.savefig(plot_ma_b)
 
61
  plt.close()
62
 
63
+ history_data = history_data.drop(columns=['MA30'])
 
 
 
64
 
65
+ def create_lagged_features(data, lags=3):
66
+ lagged_data = data.copy()
67
+ for lag in range(1, lags + 1):
68
+ lagged_data[[f"{col}_lag{lag}" for col in data.columns]] = data.shift(lag)
69
+ lagged_data.dropna(inplace=True)
70
+ return lagged_data
71
+
72
+ lags = 30 * 24
73
+
74
+ # Load the model
75
+ model = joblib.load('./models/random_forest_model.pkl')
76
+ lagged_data = create_lagged_features(history_data.drop(['Vol.', 'Perubahan%'], axis=1), lags)
77
+
78
+ X = lagged_data.drop(columns=['Pembukaan', 'Terakhir', 'Tertinggi', 'Terendah'])
79
+ y = lagged_data["Pembukaan"]
80
+
81
+ def multistep_forecast(model, data, n_steps):
82
+ forecast = []
83
+ last_observation = data.iloc[-1].values.reshape(1, -1)
84
+
85
+ for _ in range(n_steps):
86
+ next_step = model.predict(last_observation)
87
+ forecast.append(next_step[0])
88
+
89
+ # Update the last observation with the new prediction
90
+ last_observation = np.roll(last_observation, -1)
91
+ last_observation[0, -1] = next_step[0]
92
+
93
+ return forecast
94
 
95
  @app.route('/')
96
  def index():
97
+ table_html = history_data.to_html(classes='table table-striped', index=True)
98
 
99
+ return render_template('index.html', table_html=table_html, plot_ma_a=plot_ma_a, plot_ma_b=plot_ma_b)
100
 
101
+ @app.route('/predict', methods=['GET', 'POST'])
102
  def predict():
103
+ n_steps = 0
104
+
105
+ if request.method == 'POST':
106
+ if request.form['waktu'] == '1 bulan':
107
+ n_steps = 30
108
+ elif request.form['waktu'] == '3 bulan':
109
+ n_steps = 30 * 3
110
+ elif request.form['waktu'] == '6 bulan':
111
+ n_steps = 30 * 6
112
+ elif request.form['waktu'] == '1 tahun':
113
+ n_steps = 30 * 12
114
+ elif request.form['waktu'] == '2 tahun':
115
+ n_steps = 30 * 24
116
+
117
+ # Perform the forecast
118
+ forecasted_values = multistep_forecast(model, X, n_steps)
119
+
120
+ # Combine past and forecasted values
121
+ combined_values = np.concatenate([y.values, forecasted_values])
122
+
123
+ # Create a time index for the combined values
124
+ time_index = pd.date_range(start=y.index[0], periods=len(combined_values), freq='D')
125
+
126
+ plt.figure(figsize=(12, 6))
127
+ plt.plot(history_data.index, history_data['Pembukaan'], label="Past Data", linestyle="-", color="blue")
128
+ plt.plot(time_index[len(y):], forecasted_values, label="Forecasted Values", linestyle="-", color="green")
129
+ plt.title("All Past Data and Forecasted Future Values")
130
+ plt.xlabel("Date")
131
+ plt.ylabel("Values")
132
+ plt.legend()
133
+ plt.grid()
134
+
135
+ result_img = os.path.join('static', 'result.png')
136
+ plt.savefig(result_img)
137
+ plt.close()
138
+
139
+ forecasted_df = pd.DataFrame({
140
+ 'Tanggal': time_index[len(y):],
141
+ 'Forecasted_Pembukaan': forecasted_values
142
+ })
143
+
144
+ forecasted_df.to_csv('./datasets/forecasted_values.csv', index=False)
145
+
146
+ return render_template('predict.html', result_img=result_img, forecasted_table=forecasted_df.to_html(classes='table table-striped', index=False))
147
+ else:
148
+ return redirect(url_for('index'))
149
 
150
  if __name__ == '__main__':
151
  app.run(debug=True)
datasets/HistoricalCardano.csv ADDED
The diff for this file is too large to render. See raw diff
 
datasets/forecasted_values.csv ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Tanggal,Forecasted_Pembukaan
2
+ 2024-10-01,0.40139400000000003
3
+ 2024-10-02,0.40513499999999975
4
+ 2024-10-03,0.40849299999999994
5
+ 2024-10-04,0.3959179999999998
6
+ 2024-10-05,0.4050889999999998
7
+ 2024-10-06,0.40602899999999986
8
+ 2024-10-07,0.409478
9
+ 2024-10-08,0.39236799999999983
10
+ 2024-10-09,0.40253599999999984
11
+ 2024-10-10,0.4060509999999999
12
+ 2024-10-11,0.41532900000000017
13
+ 2024-10-12,0.3997899999999997
14
+ 2024-10-13,0.40253299999999986
15
+ 2024-10-14,0.3848709999999999
16
+ 2024-10-15,0.40508199999999994
17
+ 2024-10-16,0.3784180000000001
18
+ 2024-10-17,0.3812949999999999
19
+ 2024-10-18,0.3871420000000002
20
+ 2024-10-19,0.3940159999999998
21
+ 2024-10-20,0.3786769999999999
22
+ 2024-10-21,0.38716600000000023
23
+ 2024-10-22,0.3640600000000001
24
+ 2024-10-23,0.39207000000000003
25
+ 2024-10-24,0.35764399999999996
26
+ 2024-10-25,0.36391700000000016
27
+ 2024-10-26,0.3508319999999998
28
+ 2024-10-27,0.36564900000000017
29
+ 2024-10-28,0.3439839999999998
30
+ 2024-10-29,0.3509899999999998
31
+ 2024-10-30,0.3574809999999999
32
+ 2024-10-31,0.35876999999999987
33
+ 2024-11-01,0.34257199999999977
34
+ 2024-11-02,0.35742999999999986
35
+ 2024-11-03,0.3511939999999998
36
+ 2024-11-04,0.3592849999999999
37
+ 2024-11-05,0.3504139999999997
38
+ 2024-11-06,0.35118699999999975
39
+ 2024-11-07,0.3508149999999997
40
+ 2024-11-08,0.3614750000000001
41
+ 2024-11-09,0.3497109999999997
42
+ 2024-11-10,0.3508309999999997
43
+ 2024-11-11,0.34209599999999973
44
+ 2024-11-12,0.3565669999999998
45
+ 2024-11-13,0.3420869999999997
46
+ 2024-11-14,0.34203599999999973
47
+ 2024-11-15,0.3328820000000001
48
+ 2024-11-16,0.3420559999999997
49
+ 2024-11-17,0.328207
50
+ 2024-11-18,0.3329300000000001
51
+ 2024-11-19,0.3309120000000001
52
+ 2024-11-20,0.34207299999999974
53
+ 2024-11-21,0.32930400000000004
54
+ 2024-11-22,0.3309290000000001
55
+ 2024-11-23,0.33784
56
+ 2024-11-24,0.33777799999999997
57
+ 2024-11-25,0.326565
58
+ 2024-11-26,0.33798599999999995
59
+ 2024-11-27,0.35257399999999983
60
+ 2024-11-28,0.3567239999999999
61
+ 2024-11-29,0.338039
62
+ 2024-11-30,0.3525539999999998
63
+ 2024-12-01,0.35975
64
+ 2024-12-02,0.36219400000000024
65
+ 2024-12-03,0.3508389999999998
66
+ 2024-12-04,0.35955
67
+ 2024-12-05,0.35667999999999983
68
+ 2024-12-06,0.3644960000000001
69
+ 2024-12-07,0.3502509999999998
70
+ 2024-12-08,0.3566579999999998
71
+ 2024-12-09,0.3515269999999998
72
+ 2024-12-10,0.3618360000000002
73
+ 2024-12-11,0.3512779999999998
74
+ 2024-12-12,0.35152299999999975
75
+ 2024-12-13,0.3421029999999998
76
+ 2024-12-14,0.35684299999999985
77
+ 2024-12-15,0.3301010000000001
78
+ 2024-12-16,0.3419449999999998
79
+ 2024-12-17,0.3420459999999998
80
+ 2024-12-18,0.34366299999999983
81
+ 2024-12-19,0.33738200000000007
82
+ 2024-12-20,0.34254999999999974
83
+ 2024-12-21,0.33768099999999995
84
+ 2024-12-22,0.34967799999999977
85
+ 2024-12-23,0.336995
86
+ 2024-12-24,0.3376249999999999
87
+ 2024-12-25,0.325614
88
+ 2024-12-26,0.33918699999999996
89
+ 2024-12-27,0.3237450000000001
90
+ 2024-12-28,0.32553699999999997
91
+ 2024-12-29,0.314538
92
+ 2024-12-30,0.3280120000000001
93
+ 2024-12-31,0.31443099999999996
94
+ 2025-01-01,0.314547
95
+ 2025-01-02,0.324797
96
+ 2025-01-03,0.33197000000000015
97
+ 2025-01-04,0.3033240000000001
98
+ 2025-01-05,0.32517199999999996
99
+ 2025-01-06,0.32286200000000015
100
+ 2025-01-07,0.338189
101
+ 2025-01-08,0.31902100000000017
102
+ 2025-01-09,0.32284400000000013
103
+ 2025-01-10,0.3181350000000002
104
+ 2025-01-11,0.33011100000000015
105
+ 2025-01-12,0.3062210000000002
106
+ 2025-01-13,0.3184950000000002
107
+ 2025-01-14,0.337531
108
+ 2025-01-15,0.33829099999999995
109
+ 2025-01-16,0.31744400000000017
110
+ 2025-01-17,0.3375540000000001
111
+ 2025-01-18,0.3311330000000002
112
+ 2025-01-19,0.3376440000000001
113
+ 2025-01-20,0.32550500000000004
114
+ 2025-01-21,0.3311570000000001
115
+ 2025-01-22,0.34338799999999986
116
+ 2025-01-23,0.3436099999999998
117
+ 2025-01-24,0.3284850000000001
118
+ 2025-01-25,0.3435919999999998
119
+ 2025-01-26,0.34386499999999987
120
+ 2025-01-27,0.35016699999999984
121
+ 2025-01-28,0.3437179999999998
122
+ 2025-01-29,0.3440629999999998
123
+ 2025-01-30,0.3573969999999999
124
+ 2025-01-31,0.36219500000000016
125
+ 2025-02-01,0.33840900000000007
126
+ 2025-02-02,0.3573489999999999
127
+ 2025-02-03,0.3503319999999998
128
+ 2025-02-04,0.3672670000000003
129
+ 2025-02-05,0.3498339999999998
130
+ 2025-02-06,0.3503299999999998
131
+ 2025-02-07,0.35019399999999984
132
+ 2025-02-08,0.35975199999999996
133
+ 2025-02-09,0.3401849999999999
134
+ 2025-02-10,0.35039999999999977
135
+ 2025-02-11,0.3665330000000003
136
+ 2025-02-12,0.3721180000000001
137
+ 2025-02-13,0.34273199999999965
138
+ 2025-02-14,0.36656800000000034
139
+ 2025-02-15,0.385209
140
+ 2025-02-16,0.3876800000000001
141
+ 2025-02-17,0.36603400000000014
142
+ 2025-02-18,0.385187
143
+ 2025-02-19,0.394805
144
+ 2025-02-20,0.39513099999999995
145
+ 2025-02-21,0.3783980000000001
146
+ 2025-02-22,0.39494899999999994
147
+ 2025-02-23,0.3911699999999999
148
+ 2025-02-24,0.40316499999999983
149
+ 2025-02-25,0.38761500000000004
150
+ 2025-02-26,0.3913419999999999
151
+ 2025-02-27,0.375906
152
+ 2025-02-28,0.392419
153
+ 2025-03-01,0.3737660000000001
154
+ 2025-03-02,0.375916
155
+ 2025-03-03,0.36828300000000025
156
+ 2025-03-04,0.377441
157
+ 2025-03-05,0.36438400000000015
158
+ 2025-03-06,0.36833200000000027
159
+ 2025-03-07,0.34198099999999976
160
+ 2025-03-08,0.37735
161
+ 2025-03-09,0.34196799999999966
162
+ 2025-03-10,0.3423249999999997
163
+ 2025-03-11,0.33730600000000005
164
+ 2025-03-12,0.34972899999999973
165
+ 2025-03-13,0.33726200000000006
166
+ 2025-03-14,0.337171
167
+ 2025-03-15,0.3361630000000001
168
+ 2025-03-16,0.33749
169
+ 2025-03-17,0.3286930000000001
170
+ 2025-03-18,0.3334970000000002
171
+ 2025-03-19,0.33757200000000004
172
+ 2025-03-20,0.3380929999999999
173
+ 2025-03-21,0.3319840000000002
174
+ 2025-03-22,0.33760599999999996
175
+ 2025-03-23,0.33095700000000017
176
+ 2025-03-24,0.337658
177
+ 2025-03-25,0.32849800000000007
178
+ 2025-03-26,0.3306860000000001
179
+ 2025-03-27,0.32460100000000014
180
+ 2025-03-28,0.3438399999999998
181
+ 2025-03-29,0.3192120000000002
models/random_forest_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d67e32d591256bd4fc76920b9dcf245c1685e629d9fd2532d2e886d0194516b7
3
+ size 7116481
static/MA30_A.png ADDED
static/ma_a.png ADDED
static/ma_b.png ADDED
static/plot.png CHANGED
static/result.png ADDED
templates/index.html CHANGED
@@ -32,24 +32,35 @@
32
  </style>
33
  </head>
34
  <body>
35
- <h1>Forecasting Harga Pembukaan Saham BCA (BBCA) dengan Linear Regression Multivariate</h1>
36
- <p>Data terakhir diambil tanggal : 2024-11-29</p>
37
- <a href="/predict">Lihat prediksi tanggal berikutnya</a>
 
 
 
 
 
 
 
 
 
 
 
38
  <div class="container my-5">
39
  <h2>DataFrame Display</h2>
40
  <div class="table-container">
41
- {{ table|safe }}
42
  </div>
 
43
 
44
- <div class="container my-5">
45
- <h2>Pergerakan Harga Pembukaan dan Terakhir MA 30</h2>
46
- <img src="{{ plot_pembukaan_terakhir_url }}" alt="Plot">
47
- </div>
48
 
49
- <div class="container my-5">
50
- <h2>Pergerakan Harga Tertinggi dan Terendah MA 30</h2>
51
- <img src="{{ plot_tertinggi_terendah_url }}" alt="Plot">
52
- </div>
53
  </div>
54
  </body>
55
  </html>
 
32
  </style>
33
  </head>
34
  <body>
35
+ <h1>Forecasting Harga Pembukaan Mata Uang Kripto Cardano (ADA) dengan Random Forest</h1>
36
+ <p>Data terakhir diambil tanggal : 2024-09-30</p>
37
+
38
+ <form action="{{ url_for('predict') }}" method="post">
39
+ <label for="timeframe">Pilih rentang waktu:</label>
40
+ <select name="waktu" id="timeframe">
41
+ <option value="1 bulan">1 Bulan</option>
42
+ <option value="3 bulan">3 Bulan</option>
43
+ <option value="6 bulan">6 Bulan</option>
44
+ <option value="1 tahun">1 Tahun</option>
45
+ </select>
46
+ <button type="submit">Submit</button>
47
+ </form>
48
+
49
  <div class="container my-5">
50
  <h2>DataFrame Display</h2>
51
  <div class="table-container">
52
+ {{ table_html|safe }}
53
  </div>
54
+ </div>
55
 
56
+ <div class="container my-5">
57
+ <h2>Pergerakan Harga Pembukaan dan Terakhir MA 30</h2>
58
+ <img src="{{ plot_ma_a }}" alt="Plot">
59
+ </div>
60
 
61
+ <div class="container my-5">
62
+ <h2>Pergerakan Harga Tertinggi dan Terendah MA 30</h2>
63
+ <img src="{{ plot_ma_b }}" alt="Plot">
 
64
  </div>
65
  </body>
66
  </html>
templates/predict.html CHANGED
@@ -3,38 +3,46 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>IMPHNEN</title>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  </head>
8
  <body>
9
- <h1>Hasil Forecasting Harga Pembukaan Saham BCA (BBCA) dengan Linear Regression Multivariate</h1>
10
- <a href="/">Kembali halaman utama</a>
 
 
11
  <div class="container my-5">
12
- <h2>Hasil Prediksi</h2>
13
- <p>Harga Pembukaan Saham BCA (BBCA) pada tanggal {{ next_date }} adalah sebesar Rp {{ next_value }}</p>
14
- </div>
15
- <div class="container my-5">
16
- <h2>Grafik Training Data</h2>
17
- <img src="{{ plot_training_url }}" alt="">
18
- </div>
19
- <div class="container my-5">
20
- <h2>Score Evaluasi</h2>
21
- <ul>
22
- <li>
23
- <strong>Mean Absolute Error (MAE):</strong> {{ mae }}
24
- </li>
25
- <li>
26
- <strong>Mean Squared Error (MSE):</strong> {{ mse }}
27
- </li>
28
- <li>
29
- <strong>Root Mean Squared Error (RMSE):</strong> {{ rmse }}
30
- </li>
31
- <li>
32
- <strong>Coefficient of Determination (R^2):</strong> {{ r2 }}
33
- </li>
34
- <li>
35
- <strong>Mean Absolute Percentage Error (MAPE):</strong> {{ mape }}
36
- </li>
37
- </ul>
38
  </div>
 
 
39
  </body>
40
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Document</title>
7
+ <style>
8
+ table {
9
+ border-collapse: collapse;
10
+ width: 100%;
11
+ border: 1px solid black; /* Add this line */
12
+ }
13
+
14
+ th, td {
15
+ border: 1px solid black;
16
+ padding: 8px;
17
+ text-align: left;
18
+ }
19
+
20
+ th {
21
+ background-color: #f2f2f2;
22
+ }
23
+
24
+ tr:nth-child(even) {
25
+ background-color: #f2f2f2;
26
+ }
27
+
28
+ .table-container {
29
+ max-height: 400px;
30
+ overflow-y: auto;
31
+ }
32
+ </style>
33
  </head>
34
  <body>
35
+ <h1>Hasil Prediksi</h1>
36
+
37
+ <a href="/">Kembali </a>
38
+
39
  <div class="container my-5">
40
+ <h2>DataFrame Display</h2>
41
+ <div class="table-container">
42
+ {{ forecasted_table|safe }}
43
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  </div>
45
+
46
+ <img src="{{ result_img }}" alt="" srcset="">
47
  </body>
48
  </html>