
數(shù)據(jù)挖掘的分類算法
數(shù)據(jù)分析師對數(shù)據(jù)進行數(shù)據(jù)挖掘時,會運用很多算法,其中一種是分類算法,下面就對數(shù)據(jù)分析師運用分類算法進行一下詳解,如下:
@@ -0,0 +1,15 @@ | ||
+packageDataMining_HITS; | ||
+ | ||
+/** | ||
+* HITSá′?ó·?????·¨ | ||
+* @author lyq | ||
+* | ||
+*/ | ||
+publicclassClient{ | ||
+publicstaticvoidmain(String[]args){ | ||
+StringfilePath="C:\\Users\\lyq\\Desktop\\icon\\input.txt"; | ||
+ | ||
+HITSTooltool=newHITSTool(filePath); | ||
+ tool.printResultPage(); | ||
+ } | ||
+} |
@@ -0,0 +1,150 @@ | ||
+packageDataMining_HITS; | ||
+ | ||
+importjava.io.BufferedReader; | ||
+importjava.io.File; | ||
+importjava.io.FileReader; | ||
+importjava.io.IOException; | ||
+importjava.util.ArrayList; | ||
+ | ||
+/** | ||
+* HITS鏈接分析算法工具類 | ||
+* @author lyq | ||
+* | ||
+*/ | ||
+publicclassHITSTool{ | ||
+//輸入數(shù)據(jù)文件地址 | ||
+privateStringfilePath; | ||
+//網(wǎng)頁個數(shù) | ||
+privateintpageNum; | ||
+//網(wǎng)頁Authority權(quán)威值 | ||
+privatedouble[] authority; | ||
+//網(wǎng)頁hub中心值 | ||
+privatedouble[] hub; | ||
+//鏈接矩陣關(guān)系 | ||
+privateint[][] linkMatrix; | ||
+//網(wǎng)頁種類 | ||
+privateArrayList<String>pageClass; | ||
+ | ||
+publicHITSTool(StringfilePath){ | ||
+this.filePath=filePath; | ||
+ readDataFile(); | ||
+ } | ||
+ | ||
+/** | ||
+* 從文件中讀取數(shù)據(jù) | ||
+*/ | ||
+privatevoidreadDataFile() { | ||
+Filefile=newFile(filePath); | ||
+ArrayList<String[]>dataArray=newArrayList<String[]>(); | ||
+ | ||
+try{ | ||
+BufferedReaderin=newBufferedReader(newFileReader(file)); | ||
+Stringstr; | ||
+String[] tempArray; | ||
+while((str=in.readLine())!=null) { | ||
+ tempArray=str.split(""); | ||
+ dataArray.add(tempArray); | ||
+ } | ||
+ in.close(); | ||
+ }catch(IOExceptione) { | ||
+ e.getStackTrace(); | ||
+ } | ||
+ | ||
+ pageClass=newArrayList<>(); | ||
+// 統(tǒng)計網(wǎng)頁類型種數(shù) | ||
+for(String[] array:dataArray) { | ||
+for(Strings:array) { | ||
+if(!pageClass.contains(s)) { | ||
+ pageClass.add(s); | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+inti=0; | ||
+intj=0; | ||
+ pageNum=pageClass.size(); | ||
+ linkMatrix=newint[pageNum][pageNum]; | ||
+ authority=newdouble[pageNum]; | ||
+ hub=newdouble[pageNum]; | ||
+for(intk=0; k<pageNum; k++){ | ||
+//初始時默認權(quán)威值和中心值都為1 | ||
+ authority[k]=1; | ||
+ hub[k]=1; | ||
+ } | ||
+ | ||
+for(String[] array:dataArray) { | ||
+ | ||
+ i=Integer.parseInt(array[0]); | ||
+ j=Integer.parseInt(array[1]); | ||
+ | ||
+// 設(shè)置linkMatrix[i][j]為1代表i網(wǎng)頁包含指向j網(wǎng)頁的鏈接 | ||
+ linkMatrix[i-1][j-1]=1; | ||
+ } | ||
+ } | ||
+ | ||
+/** | ||
+* 輸出結(jié)果頁面,也就是authority權(quán)威值最高的頁面 | ||
+*/ | ||
+publicvoidprintResultPage(){ | ||
+//最大Hub和Authority值,用于后面的歸一化計算 | ||
+doublemaxHub=0; | ||
+doublemaxAuthority=0; | ||
+intmaxAuthorityIndex=0; | ||
+//誤差值,用于收斂判斷 | ||
+doubleerror=Integer.MAX_VALUE; | ||
+double[] newHub=newdouble[pageNum]; | ||
+double[] newAuthority=newdouble[pageNum]; | ||
+ | ||
+ | ||
+while(error>0.01*pageNum){ | ||
+for(intk=0; k<pageNum; k++){ | ||
+ newHub[k]=0; | ||
+ newAuthority[k]=0; | ||
+ } | ||
+ | ||
+//hub和authority值的更新計算 | ||
+for(inti=0; i<pageNum; i++){ | ||
+for(intj=0; j<pageNum; j++){ | ||
+if(linkMatrix[i][j]==1){ | ||
+ newHub[i]+=authority[j]; | ||
+ newAuthority[j]+=hub[i]; | ||
+ } | ||
+ } | ||
+ } | ||
+ | ||
+ maxHub=0; | ||
+ maxAuthority=0; | ||
+for(intk=0; k<pageNum; k++){ | ||
+if(newHub[k]>maxHub){ | ||
+ maxHub=newHub[k]; | ||
+ } | ||
+ | ||
+if(newAuthority[k]>maxAuthority){ | ||
+ maxAuthority=newAuthority[k]; | ||
+ maxAuthorityIndex=k; | ||
+ } | ||
+ } | ||
+ | ||
+ error=0; | ||
+//歸一化處理 | ||
+for(intk=0; k<pageNum; k++){ | ||
+ newHub[k]/=maxHub; | ||
+ newAuthority[k]/=maxAuthority; | ||
+ | ||
+ error+=Math.abs(newHub[k]-hub[k]); | ||
+System.out.println(newAuthority[k]+":"+newHub[k]); | ||
+ | ||
+ hub[k]=newHub[k]; | ||
+ authority[k]=newAuthority[k]; | ||
+ } | ||
+System.out.println("---------"); | ||
+ } | ||
+ | ||
+System.out.println("****最終收斂的網(wǎng)頁的權(quán)威值和中心值****"); | ||
+for(intk=0; k<pageNum; k++){ | ||
+System.out.println("網(wǎng)頁"+pageClass.get(k)+":"+authority[k]+":"+hub[k]); | ||
+ } | ||
+System.out.println("權(quán)威值最高的網(wǎng)頁為:網(wǎng)頁"+pageClass.get(maxAuthorityIndex)); | ||
+ } | ||
+ | ||
+} |
@@ -0,0 +1,4 @@ | ||
+1 2 | ||
+1 3 | ||
+2 3 | ||
+3 1 |
數(shù)據(jù)分析咨詢請掃描二維碼
若不方便掃碼,搜微信號:CDAshujufenxi
訓練與驗證損失驟升:機器學習訓練中的異常診斷與解決方案 在機器學習模型訓練過程中,“損失曲線” 是反映模型學習狀態(tài)的核心指 ...
2025-09-19解析 DataHub 與 Kafka:數(shù)據(jù)生態(tài)中兩類核心工具的差異與協(xié)同 在數(shù)字化轉(zhuǎn)型加速的今天,企業(yè)對數(shù)據(jù)的需求已從 “存儲” 轉(zhuǎn)向 “ ...
2025-09-19CDA 數(shù)據(jù)分析師:讓統(tǒng)計基本概念成為業(yè)務決策的底層邏輯 統(tǒng)計基本概念是商業(yè)數(shù)據(jù)分析的 “基礎(chǔ)語言”—— 從描述數(shù)據(jù)分布的 “均 ...
2025-09-19CDA 數(shù)據(jù)分析師:表結(jié)構(gòu)數(shù)據(jù) “獲取 - 加工 - 使用” 全流程的賦能者 表結(jié)構(gòu)數(shù)據(jù)(如數(shù)據(jù)庫表、Excel 表、CSV 文件)是企業(yè)數(shù)字 ...
2025-09-19SQL Server 中 CONVERT 函數(shù)的日期轉(zhuǎn)換:從基礎(chǔ)用法到實戰(zhàn)優(yōu)化 在 SQL Server 的數(shù)據(jù)處理中,日期格式轉(zhuǎn)換是高頻需求 —— 無論 ...
2025-09-18MySQL 大表拆分與關(guān)聯(lián)查詢效率:打破 “拆分必慢” 的認知誤區(qū) 在 MySQL 數(shù)據(jù)庫管理中,“大表” 始終是性能優(yōu)化繞不開的話題。 ...
2025-09-18DSGE 模型中的 Et:理性預期算子的內(nèi)涵、作用與應用解析 動態(tài)隨機一般均衡(Dynamic Stochastic General Equilibrium, DSGE)模 ...
2025-09-17Python 提取 TIF 中地名的完整指南 一、先明確:TIF 中的地名有哪兩種存在形式? 在開始提取前,需先判斷 TIF 文件的類型 —— ...
2025-09-17CDA 數(shù)據(jù)分析師:解鎖表結(jié)構(gòu)數(shù)據(jù)特征價值的專業(yè)核心 表結(jié)構(gòu)數(shù)據(jù)(以 “行 - 列” 規(guī)范存儲的結(jié)構(gòu)化數(shù)據(jù),如數(shù)據(jù)庫表、Excel 表、 ...
2025-09-17Excel 導入數(shù)據(jù)含缺失值?詳解 dropna 函數(shù)的功能與實戰(zhàn)應用 在用 Python(如 pandas 庫)處理 Excel 數(shù)據(jù)時,“缺失值” 是高頻 ...
2025-09-16深入解析卡方檢驗與 t 檢驗:差異、適用場景與實踐應用 在數(shù)據(jù)分析與統(tǒng)計學領(lǐng)域,假設(shè)檢驗是驗證研究假設(shè)、判斷數(shù)據(jù)差異是否 “ ...
2025-09-16CDA 數(shù)據(jù)分析師:掌控表格結(jié)構(gòu)數(shù)據(jù)全功能周期的專業(yè)操盤手 表格結(jié)構(gòu)數(shù)據(jù)(以 “行 - 列” 存儲的結(jié)構(gòu)化數(shù)據(jù),如 Excel 表、數(shù)據(jù) ...
2025-09-16MySQL 執(zhí)行計劃中 rows 數(shù)量的準確性解析:原理、影響因素與優(yōu)化 在 MySQL SQL 調(diào)優(yōu)中,EXPLAIN執(zhí)行計劃是核心工具,而其中的row ...
2025-09-15解析 Python 中 Response 對象的 text 與 content:區(qū)別、場景與實踐指南 在 Python 進行 HTTP 網(wǎng)絡請求開發(fā)時(如使用requests ...
2025-09-15CDA 數(shù)據(jù)分析師:激活表格結(jié)構(gòu)數(shù)據(jù)價值的核心操盤手 表格結(jié)構(gòu)數(shù)據(jù)(如 Excel 表格、數(shù)據(jù)庫表)是企業(yè)最基礎(chǔ)、最核心的數(shù)據(jù)形態(tài) ...
2025-09-15Python HTTP 請求工具對比:urllib.request 與 requests 的核心差異與選擇指南 在 Python 處理 HTTP 請求(如接口調(diào)用、數(shù)據(jù)爬取 ...
2025-09-12解決 pd.read_csv 讀取長浮點數(shù)據(jù)的科學計數(shù)法問題 為幫助 Python 數(shù)據(jù)從業(yè)者解決pd.read_csv讀取長浮點數(shù)據(jù)時的科學計數(shù)法問題 ...
2025-09-12CDA 數(shù)據(jù)分析師:業(yè)務數(shù)據(jù)分析步驟的落地者與價值優(yōu)化者 業(yè)務數(shù)據(jù)分析是企業(yè)解決日常運營問題、提升執(zhí)行效率的核心手段,其價值 ...
2025-09-12用 SQL 驗證業(yè)務邏輯:從規(guī)則拆解到數(shù)據(jù)把關(guān)的實戰(zhàn)指南 在業(yè)務系統(tǒng)落地過程中,“業(yè)務邏輯” 是連接 “需求設(shè)計” 與 “用戶體驗 ...
2025-09-11塔吉特百貨孕婦營銷案例:數(shù)據(jù)驅(qū)動下的精準零售革命與啟示 在零售行業(yè) “流量紅利見頂” 的當下,精準營銷成為企業(yè)突圍的核心方 ...
2025-09-11