91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

壓縮包中包含算法的Python實現(xiàn)代碼、測試數(shù)據(jù)集及運行結(jié)果,可供感興趣的同學參考。因為現(xiàn)在的實現(xiàn)并不能對所有的數(shù)據(jù)集都得到良好的效果,所以如果哪位同學有更好的想法,希望能不吝賜教。

資源截圖

代碼片段和文件信息

#?-*-?coding:?utf-8?-*-
“““
Created?on?Mon?Oct?20?13:38:18?2014

@author:?Shaobo
The?best?of?all
“““

import?numpy?as?np
import?matplotlib.pyplot?as?plt
import?random

MAX?=?1000000

def?nearestNeighbor(index):
????dd?=?MAX
????neighbor?=?-1
????for?i?in?range(length):
????????if?dist[index?i]?????????????dd?=?dist[index?i]
????????????neighbor?=?i
????if?result[neighbor]?==?-1:
????????result[neighbor]?=?nearestNeighbor(neighbor)
????return?result[neighbor]

#Read?data
fileName?=?raw_input(“Enter?the?file‘s?name:?“)
location?=?[]
label?=?[]
for?line?in?open(fileName?“r“):
????items?=?line.strip(“\n“).split(““)
????label.append(int(items.pop()))
????tmp?=?[]
????for?item?in?items:
????????tmp.append(float(item))
????location.append(tmp)
location?=?np.array(location)
label?=?np.array(label)
length?=?len(location)

#Caculate?distance
dist?=?np.zeros((length?length))
ll?=?[]
begin?=?0
while?begin?????end?=?begin?+?1
????while?end?????????dd?=?np.linalg.norm(location[begin]-location[end])
????????dist[begin][end]?=?dd
????????dist[end][begin]?=?dd
????????ll.append(dd)
????????end?=?end?+?1
????begin?=?begin?+?1
ll?=?np.array(ll)
#?Algorithm????????
#percent?=?float(raw_input(“Enter?the?average?percentage?of?neighbours:?“))
percent?=?2.0
position?=?int(len(ll)?*?percent?/?100)
sortedll?=?np.sort(ll)
dc?=?sortedll[position]?#閾值
#求點的局部密度(local?density)
rho?=?np.zeros((length?1))
begin?=?0
while?begin?????end?=?begin?+?1
????while?end?????????rho[begin]?=?rho[begin]?+?exp(-(dist[begin][end]/dc)?**?2)
????????rho[end]?=?rho[end]?+?exp(-(dist[begin][end]/dc)?**?2)
????????#if?dist[begin][end]?????????#????rho[begin]?=?rho[begin]?+?1
????????#????rho[end]?=?rho[end]?+?1
????????end?=?end?+?1
????begin?=?begin?+?1

#求比點的局部密度大的點到該點的最小距離
delta?=?np.ones((length?1))?*?MAX
maxDensity?=?np.max(rho)
begin?=?0
while?begin?????if?rho[begin]?????????end?=?0
????????while?end?????????????if?rho[end]?>?rho[begin]?and?dist[begin][end]?????????????????delta[begin]?=?dist[begin][end]
????????????end?=?end?+?1
????else:
????????delta[begin]?=?0.0
????????end?=?0
????????while?end?????????????if?dist[begin][end]?>?delta[begin]:
????????????????delta[begin]?=?dist[begin][end]
????????????end?=?end?+?1
????begin?=?begin?+?1

rate1?=?0.6
#Aggregation?Spiral?0.6
#Jain?Flame?0.8
#D31?0.75
#R15?0.6
#Compound?0.5
#Pathbased?0.2
thRho?=?rate1?*?(np.max(rho)?-?np.min(rho))?+?np.min(rho)

rate2?=?0.2
#Aggregation?Spiral?0.2
#Jain?Flame?0.2
#D31?0.05
#R15?0.1
#Compound?0.08
#Pathbased?0.4
thDel?=?rate2?*?(np.max(delta)?-?np.min(delta))?+?np.min(delta)

#確定聚類中心
result?=?np.ones(length?dtype=np.int)?*?(-1)
center?=?0
#items?=?range(length)
#random.shuffle(items)
for?i?in?range(length):?#items:
????if?rho[i]?>?thRho?and?delta

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-10-22?22:46??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\
?????文件???????10427??2014-10-18?10:10??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Aggregation.txt
?????文件?????1904194??2014-10-20?14:05??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Aggregation結(jié)果_v3.tif
?????文件????????4053??2014-10-20?21:24??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Clustering_v3.py
?????文件????????5421??2014-10-18?20:05??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Compound.txt
?????文件?????1904194??2014-10-20?17:56??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Compound結(jié)果_v3.tif
?????文件???????59098??2014-10-18?20:05??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\D31.txt
?????文件?????1904194??2014-10-20?14:22??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\D31結(jié)果_v3.tif
?????文件????????3127??2014-10-18?20:06??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Flame.txt
?????文件?????1904194??2014-10-20?17:55??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Flame結(jié)果_v3.tif
?????文件????????4933??2014-10-18?20:06??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Jain.txt
?????文件?????1904194??2014-10-20?17:53??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Jain結(jié)果_v3.tif
?????文件????????4085??2014-10-18?20:06??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Pathbased.txt
?????文件?????1904194??2014-10-20?17:51??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Pathbased結(jié)果_v3.tif
?????文件????????9548??2014-10-18?20:07??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\R15.txt
?????文件?????1904194??2014-10-20?14:11??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\R15結(jié)果_v3.tif
?????文件????????4200??2014-10-18?20:07??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Spiral.txt
?????文件?????1904194??2014-10-20?14:00??算法的python實現(xiàn)代碼、測試數(shù)據(jù)集及結(jié)果\Spiral結(jié)果_v3.tif

評論

共有 條評論