荀振宇 王衛(wèi)濤
摘 要 本文設(shè)計(jì)了基于改進(jìn)的近鄰傳播聚類算法的金融市場分析案例。首先,本文提出了基于屬性權(quán)重以及核變換的WHAP算法。WHAP算法首先計(jì)算出樣本集每維特征的權(quán)重值,然后根據(jù)每維權(quán)重值計(jì)算出樣本點(diǎn)之間的距離,再然后通過核函數(shù)將樣本點(diǎn)之間的距離進(jìn)行映射變換計(jì)算出相似度矩陣,最終計(jì)算出解聚類結(jié)果;然后,本文結(jié)合Spring boot、Redis、Vue、MySQL搭建出一套應(yīng)用開發(fā)系統(tǒng),該系統(tǒng)進(jìn)行數(shù)據(jù)的選擇同時(shí)將數(shù)據(jù)量化為WHAP算法可處理的數(shù)據(jù)集,然后將此數(shù)據(jù)集作為該算法的輸入樣本集,再然后通過計(jì)算將聚類結(jié)果轉(zhuǎn)換為頁面可視化數(shù)據(jù),最終通過聚類結(jié)果為金融市場提供有效的參考方案。
關(guān)鍵詞 權(quán)重;核函數(shù);Spring boot;金融市場
Financial Market Analysis Based on Kernel Transformation Affinity Propagation clustering algorithm
Xun Zhenyu1, Wang Weitao2
1. The First Military Representative Office of the Maritime Equipment Shenyang Bureau in Dalian, Dalian 116000
2. 713th Research Institute China Ship Building Industry Corporation, Zhengzhou 450000
Abstract This article designs a financial market analysis case based on improved Affinity Propagation clustering algorithm. First, this paper proposes an WHAP algorithm based on attribute weights and kernel transformation. The WHAP algorithm first calculates the weight value of each dimension of the sample set, then calculate the distance between the sample points according to the weight value of each dimension, Then use the kernel function to map the distance between the sample points to calculate the similarity matrix, Finally calculate the clustering results; Second, This article combines Spring Boot, Redis, Vue, and MySQL to build a set of application development systems, The system selects data and quantizes the data into a dataset that can be processed by the WAP algorithm, This data set is then used as the input sample set for the algorithm, The clustering results are then converted into page visualization data by calculation, Finally, provide effective reference solutions for financial markets through clustering results.
Key words Weights; Kernel function; Spring boot; Financial market
引言
2007年Frey和Dueck在Science上發(fā)表了Points Clustering by Passing Messages Between Data,系統(tǒng)闡述了近鄰傳播聚類算(Affinity Propagation, AP)的原理和應(yīng)用。近鄰傳播算法不需要事先設(shè)定聚類的個(gè)數(shù),不需要初始化聚類中心點(diǎn),是一種快速有效的聚類算法[1]。但是在研究的過程中,發(fā)現(xiàn)近鄰傳播算法在處理現(xiàn)實(shí)生活中實(shí)際的應(yīng)用問題上,略顯不足。
本文針對(duì)上述提到的問題,提出了WHAP算法。目的是通過改進(jìn)的近鄰傳播聚類算法來處理現(xiàn)實(shí)生活中的應(yīng)用問題,同時(shí)選取股票數(shù)據(jù)集作為金融市場分析的量化指標(biāo),最終將該算法應(yīng)用于股票數(shù)據(jù)集上[2]。通過實(shí)驗(yàn)結(jié)果表明改進(jìn)后的近鄰傳播聚類算法具有一定的應(yīng)用價(jià)值。
1 近鄰傳播聚類算法(AP)
近鄰傳播聚類算法根據(jù)樣本點(diǎn)之間的相似度進(jìn)行迭代計(jì)算。其中計(jì)算相似度矩陣的公式如下:
(1)
該算法引入了歸屬度矩陣A和吸引度矩陣R。其中:,。計(jì)算公式如下:
(2)
(3)
(4)
(5)
在計(jì)算歸屬度矩陣相似度矩陣過程中,引入了阻尼因子來增強(qiáng)算法的穩(wěn)定性,計(jì)算公式如下:
(6)
(7)
其中聚類目標(biāo)函數(shù)如下:
(8)
式中,為樣本點(diǎn)i的聚類中心點(diǎn),是由組成的向量。其中計(jì)算公式如下:
(9)
迭代結(jié)束之后通過計(jì)算的值來確定聚類中心點(diǎn),當(dāng)時(shí),樣本點(diǎn)即為聚類中心點(diǎn)。各個(gè)樣本點(diǎn)的聚類中心點(diǎn)的計(jì)算公式如下:
(10)
2 WHAP算法
首先計(jì)算出樣本點(diǎn)之間的相似度S,
,
其中,,
。式中,指數(shù)是核函數(shù)的調(diào)整因子,調(diào)整其映射空間的范圍。其中,,均為系數(shù),取值范圍為。
在計(jì)算相似度矩陣S后,然后根據(jù)第一章節(jié)中介紹的計(jì)算步驟去計(jì)算出最終的聚類結(jié)果。
綜上所述,WHAP算法步驟見表1:
3 應(yīng)用開發(fā)相關(guān)技術(shù)介紹
3.1 Spring原理及介紹
Spring是一種輕量級(jí)的Java開發(fā)框架,能降低邏輯層與其他各層的耦合度,它的特點(diǎn)有[3-5]:①方便耦合;②支持AOP;③通過聲明式方式管理事務(wù);④方便測試;⑤對(duì)Java EE API進(jìn)行封裝,方便使用;⑥易于學(xué)習(xí)。
3.2 Redis原理及介紹
Redis是目前應(yīng)用的最廣泛的分布式緩存架構(gòu)之一,是一種key-value型數(shù)據(jù)庫,它可以減少磁盤的IO操作以及數(shù)據(jù)庫的訪問次數(shù),從而可以提高系統(tǒng)的整體性能,尤其是在多用戶訪問的情況下,Redis表現(xiàn)得更加優(yōu)異[6]。
3.3 Vue原理及介紹
Vue是視圖層面的一種漸進(jìn)式架構(gòu),Vue最主要的特點(diǎn)是它實(shí)現(xiàn)了響應(yīng)式編程,當(dāng)數(shù)據(jù)發(fā)生改變時(shí),視圖會(huì)自動(dòng)更新,通過利用Object.defineProperty 轉(zhuǎn)換為 getter/setter,實(shí)現(xiàn)數(shù)據(jù)變化監(jiān)聽功能[7-9]。
3.4 MySQL原理及介紹
MySQL是一種輕量型數(shù)據(jù)庫管理系統(tǒng),開放的源碼為設(shè)計(jì)師提供了大量的改進(jìn)接口,同時(shí)它自身運(yùn)行速度快、系統(tǒng)穩(wěn)定、免費(fèi)開放贏得了大量用戶的信賴[10-12]。
4 股票數(shù)據(jù)
本文從盈利能力、成長能力、經(jīng)營能力、現(xiàn)金流能力以及負(fù)債能力等多個(gè)角度來分析股票的價(jià)值,詳細(xì)指標(biāo)見表2:
上表的各個(gè)指標(biāo)的計(jì)算公式見表3:
5 系統(tǒng)設(shè)計(jì)步驟
結(jié)合前幾節(jié)對(duì)WHAP算法的分析以及對(duì)應(yīng)用業(yè)務(wù)的詳細(xì)介紹,現(xiàn)整個(gè)系統(tǒng)設(shè)計(jì)如下表所示:
6 實(shí)驗(yàn)結(jié)果
本文開發(fā)了一套集成了改進(jìn)的近鄰傳播聚類算法和選擇數(shù)據(jù)并反饋數(shù)據(jù)的系統(tǒng),該系統(tǒng)根據(jù)盈利能力、成長能力、經(jīng)營能力以及現(xiàn)金流能力多個(gè)角度來分析股票的價(jià)值。
該系統(tǒng)提供了選擇股票的界面,用戶可以通過自主選擇股票,為用戶提供了極大的便利。
從上圖可知,從盈利能力、成長能力、經(jīng)營能力以及現(xiàn)金流能力多個(gè)角度來選取投資價(jià)值更高的股票是具備一定的現(xiàn)實(shí)意義的[13]。WHAP在股票分析等金融市場領(lǐng)域具有一定的參考價(jià)值。
7 結(jié)束語
本文介紹了近鄰傳播的原理與步驟,同時(shí)介紹了通過指標(biāo)權(quán)重以及核函數(shù)計(jì)算相似度的方法,然后介紹了基于Spring boot+Redis+Vue+MySQL架構(gòu)的應(yīng)用系統(tǒng),該系統(tǒng)提供了選擇數(shù)據(jù)以及反饋數(shù)據(jù)等功能。通過實(shí)驗(yàn)結(jié)果分析表明改進(jìn)后的近鄰傳播聚類算法具備一定的應(yīng)用價(jià)值。
參考文獻(xiàn)
[1] G Hongyu. Research on term weighting algorithm based on information entropy theory[J]. Computer Engineering & Applications,2013,49(10):140-146.
[2] Gan G,Ng K P. Subspace clustering using affinity propagation[J]. Pattern Recognition,2015,48(4):1455-1464.
[3] Jia H,Ding S,Meng L,et al. A density-adaptive affinity propagation clustering algorithm based on spectral dimension reduction[J]. Neural Computing & Applications,2014,25(7-8):1557-1567.
[4] Dueck D,F(xiàn)rey B J. Non-metric affinity propagation for unsupervised image categorization[C]// IEEE, International Conference on Computer Vision. IEEE,2007:1-8.
[5] Wang K,Zhang J,Li D,et al. Adaptive Affinity Propagation Clustering[J]. Acta Automatica Sinica,2007,33(12):1242-1246.
[6] Yu X. Semi-Supervised Clustering Based on Affinity Propagation Algorithm[J]. Journal of Software, 2008, 19(11):2803-2813.
[7] Dong J. Affinity Propagation Clustering Based on Variable-Similarity Measure[J]. Journal of Electronics & Information Technology, 2010, 32(3):509-514.
[8] Jia H, Ding S, Meng L, et al. A density-adaptive affinity propagation clustering algorithm based on spectral dimension reduction[J]. Neural Computing & Applications, 2014, 25(7-8):1557-1567.
[9] 魯偉明,杜晨陽,魏寶剛,等.基于MapReduce的分布式近鄰傳播聚類算法[J].計(jì)算機(jī)研究與發(fā)展,2012,49(8):1762-1772.
[10] Zhang Z, Wang B Q, Yi P, et al. Semi-supervised Affinity Propagation Clustering Algorithm Based on Stratified Combination[J]. Journal of Electronics & Information Technology, 2013, 35(3):645-651.
[11] Xu M L,Wang S,Hang W L.A Semi-supervised Affinity Propagation Clustering Method with Homogeneity Constraint[J]. Acta Automatica Sinica, 2015,(2):255-269.
[12] Zhou S B, Xu Z Y, Tang X Q. A method for determining the optimal number of clusters based on affinity propagation clustering[J]. Kongzhi Yu Juece/control & Decision, 2011, 26(8):1147-1152,1157.
[13] 倪志偉,荊婷婷,倪麗萍.一種近鄰傳播的層次優(yōu)化算法[J].計(jì)算機(jī)科學(xué),2015,42(3):195-200.
作者簡介
荀振宇(1983-),男,碩士研究生,工程師,研究方向:人工智能。
王衛(wèi)濤(1989-),男, 碩士研究生, 工程師。本文通訊作者:王衛(wèi)濤,研究方向:人工智能。