├── .idea
├── misc.xml
├── modules.xml
├── time_series_prediction.iml
├── vcs.xml
└── workspace.xml
├── ARIMA
├── CompareParm.py
├── __pycache__
│ └── buildArima.cpython-36.pyc
├── acf_pacf.py
├── buildArima.py
├── dataPreTest.py
└── testModel.py
├── DataPre_util
├── __pycache__
│ ├── ch.cpython-36.pyc
│ └── readCsv.cpython-36.pyc
├── adf.py
├── ch.py
└── readCsv.py
├── README.md
├── SVR
├── FindBestPam.py
├── __pycache__
│ └── svmprediction.cpython-36.pyc
├── svmprediction.py
└── testGammaAndC.py
├── data
└── PRSA_data_ff.csv
├── 课程设计报告.docx
└── 课程设计报告.pdf
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/time_series_prediction.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/workspace.xml:
--------------------------------------------------------------------------------
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 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
305 |
306 |
307 |
308 |
309 |
310 |
311 |
312 |
313 |
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 |
325 |
326 |
327 |
328 |
329 |
330 |
331 |
332 |
333 |
334 |
335 |
336 |
337 |
338 |
339 |
340 |
341 |
342 |
343 |
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 | 1562192425855
352 |
353 |
354 | 1562192425855
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 | file://$PROJECT_DIR$/SVR/testGammaAndC.py
389 | 19
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 |
723 |
724 |
725 |
726 |
727 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
--------------------------------------------------------------------------------
/ARIMA/CompareParm.py:
--------------------------------------------------------------------------------
1 | from pandas import read_csv
2 | from ARIMA.buildArima import evaluate_arima_model
3 | from pandas import datetime
4 | from sklearn import preprocessing
5 | import warnings
6 |
7 | # '''定义时间格式'''
8 | # def parser(x):
9 | # return datetime.strptime(x, '%Y/%m/%d')
10 |
11 |
12 | '''比较三个候选参数'''
13 | series = read_csv('../data/PRSA_data_ff.csv', header=0, parse_dates=[0], index_col=0, squeeze=True)
14 | X=preprocessing.scale(series.values)
15 |
16 | try:
17 | mse = evaluate_arima_model(X,(1,0,0))
18 | print("p=1,d=0,q=0 mse= %.3f" % mse)
19 | except:
20 | print("第一组参数无法计算")
21 |
22 | # try:
23 | # mse = evaluate_arima_model(X,(2,0,0))
24 | # print("p=2,d=0,q=0 mse= %.3f" %mse)
25 | # except:
26 | # print("第二组参数无法计算")
27 | #
28 | # try:
29 | # mse = evaluate_arima_model(X,(7,0,5))
30 | # print("p=7,d=0,q=5 mse= %.3f" %mse)
31 | # except:
32 | # print("第三组参数无法计算")
--------------------------------------------------------------------------------
/ARIMA/__pycache__/buildArima.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ohMyJason/time_series_prediction/cd782bdf28e87ce8ee5aea1e40c58666e32b9530/ARIMA/__pycache__/buildArima.cpython-36.pyc
--------------------------------------------------------------------------------
/ARIMA/acf_pacf.py:
--------------------------------------------------------------------------------
1 | import statsmodels.api as sm
2 | from pandas import datetime
3 | from pandas import read_csv
4 | import matplotlib.pyplot as plt
5 | from sklearn import preprocessing
6 | from DataPre_util.readCsv import read_csv
7 | def parser(x):
8 | return datetime.strptime(x, '%Y/%m/%d')
9 |
10 |
11 |
12 | '''计算相关系数和偏自相关系数'''
13 | # train=read_csv('../data/PRSA_data_ff.csv', header=0, parse_dates=[0], index_col=0, squeeze=True)
14 | index,train = read_csv('../data/PRSA_data_ff.csv')
15 |
16 | fig = plt.figure(figsize=(12, 8))
17 | ax1 = fig.add_subplot(211)
18 | fig = sm.graphics.tsa.plot_acf(train, lags=16, ax=ax1)
19 | ax1.xaxis.set_ticks_position('bottom')
20 | fig.tight_layout()
21 |
22 | ax2 = fig.add_subplot(212)
23 | fig = sm.graphics.tsa.plot_pacf(train, lags=16, ax=ax2)
24 | ax2.xaxis.set_ticks_position('bottom')
25 | fig.tight_layout()
26 | plt.show()
--------------------------------------------------------------------------------
/ARIMA/buildArima.py:
--------------------------------------------------------------------------------
1 | from pandas import read_csv
2 | from pandas import datetime
3 | from statsmodels.tsa.arima_model import ARIMA
4 | # from matplotlib import pyplot
5 | # import statsmodels.api
6 | # import warnings
7 | from sklearn.metrics import mean_squared_error
8 |
9 |
10 | '''评估模型MSE'''
11 | # evaluate an ARIMA model for a given order (p,d,q)
12 | def evaluate_arima_model(X, arima_order):
13 | # prepare training dataset
14 | train_size = int(len(X) * 0.66)
15 | train, test = X[0:train_size], X[train_size:]
16 | history = [x for x in train]
17 | # make predictions
18 | predictions = list()
19 | for t in range(len(test)):
20 | model = ARIMA(history, order=arima_order)
21 | model_fit = model.fit(disp=0)
22 | yhat = model_fit.forecast()[0]
23 | predictions.append(yhat)
24 | history.append(test[t])
25 | # calculate out of sample error
26 | error = mean_squared_error(test, predictions)
27 | return error
28 |
29 | '''寻找最优参'''
30 | # evaluate combinations of p, d and q values for an ARIMA model
31 | def evaluate_models(dataset, p_values, d_values, q_values):
32 | dataset = dataset.astype('float32')
33 | best_score, best_cfg = float("inf"), None
34 | for p in p_values:
35 | for d in d_values:
36 | for q in q_values:
37 | order = (p, d, q)
38 | try:
39 | mse = evaluate_arima_model(dataset, order)
40 | if mse < best_score:
41 | best_score, best_cfg = mse, order
42 | print('ARIMA%s MSE=%.3f' % (order, mse))
43 | except:
44 | continue
45 | print('Best ARIMA%s MSE=%.3f' % (best_cfg, best_score))
46 | return best_cfg
47 |
48 |
49 | def parser(x):
50 | return datetime.strptime(x, '%Y/%m/%d')
51 |
52 | series = read_csv('../data/PRSA_data_ff.csv', header=0, parse_dates=[0], index_col=0, squeeze=True)
53 |
54 | '''通过AIC准则寻找最优参'''
55 | def findC(series):
56 | temp = 1000000
57 | ansp = 0
58 | ansq = 0
59 | ansd = 0
60 | for p in range(0, 8):
61 | for q in range(0, 8):
62 | # if p+q!=0:
63 | try:
64 | testModel = ARIMA(series, order=(p, 0, q))
65 | testModel_fit = testModel.fit(disp=0)
66 | aic = testModel_fit.aic
67 | if aic < temp:
68 | temp = aic
69 | ansp = p
70 | ansq = q
71 | ansd = 0
72 | except:
73 | continue
74 | return ansp,ansd,ansq
75 |
76 | # fit model
77 | '''寻找最优参'''
78 | # p_values = [0, 1, 2, 3 , 4, 5,6]
79 | # d_values = range(0,1)
80 | # q_values = range(0, 6)
81 | #
82 |
83 | # X = series.values
84 | # bestOrder=evaluate_models(X, p_values, d_values, q_values)
85 | # model = ARIMA(series, order=bestOrder)
86 |
87 | p,d,q=findC(series.values)
88 |
89 | print(p,d,q)
90 | mse = evaluate_arima_model(series.values,(p,d,q))
91 | print("mse = %.3f"%mse)
92 | model = ARIMA(series, order=(p,d,q))
93 | # model = ARIMA(series, order=(2,0,0))
94 | model_fit = model.fit(disp=0) # disp=0关#闭对训练信息的打印
95 |
96 |
97 | '''打印模型信息'''
98 | print(model_fit.summary())
99 |
100 | # plot residual errors
101 | # residuals = DataFrame(model_fit.resid)
102 | # residuals.plot()
103 | # pyplot.show()
104 | # residuals.plot(kind='kde')
105 | # pyplot.show()
106 | # print(residuals.describe())
107 |
--------------------------------------------------------------------------------
/ARIMA/dataPreTest.py:
--------------------------------------------------------------------------------
1 | from pandas import datetime
2 | from matplotlib import pyplot
3 | from SVR.svmprediction import read_csv
4 | def set_ch():
5 | from pylab import mpl
6 | mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体
7 | mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
8 | def parser(x):
9 | return datetime.strptime(x, '%Y/%m/%d')
10 | set_ch()
11 |
12 | series,value = read_csv('../data/PRSA_data_ff.csv')
13 | pyplot.plot(series,value)
14 | pyplot.xlabel('time')
15 | pyplot.ylabel('PM2.5')
16 | pyplot.show()
17 | '''output
18 | data
19 | 2018-01-18 33
20 | 2018-01-19 31
21 | 2018-01-20 22
22 | 2018-01-21 16
23 | 2018-01-22 4
24 | Name: value, dtype: int64
25 |
26 | '''
--------------------------------------------------------------------------------
/ARIMA/testModel.py:
--------------------------------------------------------------------------------
1 | # _*_ coding: UTF-8 _*_
2 | from pandas import read_csv
3 | from pandas import datetime
4 | from matplotlib import pyplot
5 | from statsmodels.tsa.arima_model import ARIMA
6 | from sklearn.metrics import mean_squared_error
7 | from pandas import DataFrame
8 | import statsmodels.api as sm
9 | from sklearn import preprocessing
10 | import warnings
11 |
12 | def set_ch():
13 | from pylab import mpl
14 | mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体
15 | mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
16 | set_ch()
17 |
18 | def parser(x):
19 | return datetime.strptime(x, '%Y/%m/%d')
20 |
21 | series = read_csv('../data/PRSA_data_ff.csv', header=0, parse_dates=[0], index_col=0, squeeze=True)
22 | X = series.values
23 | X=preprocessing.scale(X)
24 | size = 3500 #取前30个数据作训练
25 | train, test = X[0:size], X[size:len(X)]
26 | history = [x for x in train]
27 | predictions = list()
28 |
29 | for t in range(len(test)):
30 | model = ARIMA(history, order=(7, 0, 5))
31 | model_fit = model.fit(disp=0)
32 | output = model_fit.forecast()
33 | yhat = output[0]
34 | predictions.append(yhat)
35 | obs = test[t]
36 | history.append(obs)
37 | # print('predicted=%f, expected=%f' % (yhat, obs))
38 |
39 | error = mean_squared_error(test, predictions)
40 | print('Test MSE: %.3f' % error)
41 |
42 |
43 | # plot
44 | pyplot.figure(figsize=(12,6))
45 | pyplot.plot(test,color='blue',label="实际值")
46 | pyplot.plot(predictions, color='red',label="预测值")
47 | pyplot.xlabel('time')
48 | pyplot.ylabel('PM2.5指数')
49 | pyplot.legend()
50 | pyplot.show()
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | '''显示残差图'''
59 | residuals = DataFrame(model_fit.resid)
60 | residuals.plot()
61 | pyplot.show()
62 | residuals.plot(kind='kde')
63 | pyplot.show()
64 | print(residuals.describe())
65 |
66 | '''对残差序列进行ADF检验'''
67 | t=sm.tsa.stattools.adfuller(model_fit.resid)
68 | print(model_fit.resid)
69 |
70 | # '''保存残差数据'''
71 | # type(model_fit.resid)
72 | #
73 | # output=DataFrame(index=['Test Statistic Value', "p-value", "Lags Used", "Number of Observations Used","Critical Value(1%)","Critical Value(5%)","Critical Value(10%)"],columns=['value'])
74 | # output['value']['Test Statistic Value'] = t[0]
75 | # output['value']['p-value'] = t[1]
76 | # output['value']['Lags Used'] = t[2]
77 | # output['value']['Number of Observations Used'] = t[3]
78 | # output['value']['Critical Value(1%)'] = t[4]['1%']
79 | # output['value']['Critical Value(5%)'] = t[4]['5%']
80 | # output['value']['Critical Value(10%)'] = t[4]['10%']
81 | # print(output)
82 |
83 |
84 |
--------------------------------------------------------------------------------
/DataPre_util/__pycache__/ch.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ohMyJason/time_series_prediction/cd782bdf28e87ce8ee5aea1e40c58666e32b9530/DataPre_util/__pycache__/ch.cpython-36.pyc
--------------------------------------------------------------------------------
/DataPre_util/__pycache__/readCsv.cpython-36.pyc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ohMyJason/time_series_prediction/cd782bdf28e87ce8ee5aea1e40c58666e32b9530/DataPre_util/__pycache__/readCsv.cpython-36.pyc
--------------------------------------------------------------------------------
/DataPre_util/adf.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import statsmodels.tsa.stattools as ts
3 | from matplotlib import pyplot
4 | from pandas import datetime
5 | from pandas import read_csv
6 | import pandas as pd
7 |
8 | def parser(x):
9 | return datetime.strptime(x, '%Y/%m/%d')
10 |
11 |
12 | '''对时间序列ADF检验'''
13 | train=read_csv('../data/PRSA_data_ff.csv', header=0, parse_dates=[0], index_col=0, squeeze=True)
14 | result = ts.adfuller(train, 1)
15 | print(result)
16 |
--------------------------------------------------------------------------------
/DataPre_util/ch.py:
--------------------------------------------------------------------------------
1 | #-*-coding:utf-8-*-
2 | #文件名: ch.py
3 | def set_ch():
4 | from pylab import mpl
5 | mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体
6 | mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
--------------------------------------------------------------------------------
/DataPre_util/readCsv.py:
--------------------------------------------------------------------------------
1 | import pandas as pd
2 | def read_csv(path):
3 | csv_data = pd.read_csv(path) # 读取训练数据
4 | data=[]
5 | value = []
6 | for i in range(0,csv_data.data.size):
7 | data.append(i)
8 | value.append(csv_data.value[i])
9 | return data,value
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 关于时间序列预测中ARIMA模型的比较与探究
2 |
3 | ## How to run
4 |
5 |
6 | - testModel.py
7 |
8 | 启动ARIMA部分
9 |
10 |
11 | - svmprediction.py
12 | 启动SVR部分
13 |
14 |
15 | ## Code explain
16 |
17 | ### ARIMA部分
18 |
19 | - acf_pacf.py
20 | 用于计算自相关系数与偏自相关系数
21 | - buildArima.py
22 | 用于探究最佳模型参数
23 | - dataPreTest.py
24 | 用于做数据的查看,画出数据散点图
25 | - testModel.py
26 | 用于预测后2606个数据,并利用真实的数据与预测数据计算mse值
27 | -CompareParm.py
28 | 用于比较三组候选参数的军方误差
29 |
30 | ### SVR部分
31 | - FindBestPam.py
32 | 找出最佳的参数
33 | - svmprediction.py
34 | 建立模型并预测预测后2606数据,并利用真实的数据与预测数据计算mse值
35 | - testGammaAndC.py
36 | 用于SVR中gamma参数与C参数的探究
37 |
38 | ### DataPre_util部分
39 | - adf.py
40 | 用于数据的adf平稳性检验
41 | - ch.py
42 | 用于解决画图中的中文乱码问题
43 | - readCsv.py
44 | 用于读取数据
45 |
46 |
--------------------------------------------------------------------------------
/SVR/FindBestPam.py:
--------------------------------------------------------------------------------
1 |
2 | from SVR.svmprediction import svm_timeseries_prediction
3 | from DataPre_util.readCsv import read_csv
4 | from sklearn import preprocessing
5 | data,value = read_csv("../data/PRSA_data_ff.csv")
6 |
7 | value=preprocessing.scale(value)
8 | temp_mse = 10000 #mse初始值 默认无限大
9 | c_weight = range(1,50) #c的取值范围
10 | gamma_weight = range(1,50) #gamma的取值范围
11 |
12 |
13 | for c_paramenter in c_weight:
14 | for gamma_paramenter in gamma_weight:
15 | X_data,Y_data,X_prediction,y_prediction,error,mse = svm_timeseries_prediction(data,value,c_paramenter,gamma_paramenter)
16 | if(mse