资源简介
机器学习算法,包含随机森林,决策树,SVM,CNN等十几种算法的程序包
代码片段和文件信息
# coding:UTF-8
‘‘‘
Date:20160923
@author: zhaozhiyong
‘‘‘
import numpy as np
import math
MinPts = 5 # 定义半径内的最少的数据点的个数
def load_data(file_path):
‘‘‘导入数据
input: file_path(string):文件名
output: data(mat):数据
‘‘‘
f = open(file_path)
data = []
for line in f.readlines():
data_tmp = []
lines = line.strip().split(“\t“)
for x in lines:
data_tmp.append(float(x.strip()))
data.append(data_tmp)
f.close()
return np.mat(data)
def epsilon(data MinPts):
‘‘‘计算半径
input: data(mat):训练数据
MinPts(int):半径内的数据点的个数
output: eps(float):半径
‘‘‘
m n = np.shape(data)
xMax = np.max(data 0)
xMin = np.min(data 0)
eps = ((np.prod(xMax - xMin) * MinPts * math.gamma(0.5 * n + 1)) / (m * math.sqrt(math.pi ** n))) ** (1.0 / n)
return eps
def distance(data):
m n = np.shape(data)
dis = np.mat(np.zeros((m m)))
for i in xrange(m):
for j in xrange(i m):
# 计算i和j之间的欧式距离
tmp = 0
for k in xrange(n):
tmp += (data[i k] - data[j k]) * (data[i k] - data[j k])
dis[i j] = np.sqrt(tmp)
dis[j i] = dis[i j]
return dis
def find_eps(distance_D eps):
ind = []
n = np.shape(distance_D)[1]
for j in xrange(n):
if distance_D[0 j] <= eps:
ind.append(j)
return ind
def dbscan(data eps MinPts):
m = np.shape(data)[0]
# 区分核心点1,边界点0和噪音点-1
types = np.mat(np.zeros((1 m)))
sub_class = np.mat(np.zeros((1 m)))
# 用于判断该点是否处理过,0表示未处理过
dealed = np.mat(np.zeros((m 1)))
# 计算每个数据点之间的距离
dis = distance(data)
# 用于标记类别
number = 1
# 对每一个点进行处理
for i in xrange(m):
# 找到未处理的点
if dealed[i 0] == 0:
# 找到第i个点到其他所有点的距离
D = dis[i ]
# 找到半径eps内的所有点
ind = find_eps(D eps)
# 区分点的类型
# 边界点
if len(ind) > 1 and len(ind) < MinPts + 1:
types[0 i] = 0
sub_class[0 i] = 0
# 噪音点
if len(ind) == 1:
types[0 i] = -1
sub_class[0 i] = -1
dealed[i 0] = 1
# 核心点
if len(ind) >= MinPts + 1:
types[0 i] = 1
for x in ind:
sub_class[0 x] = number
# 判断核心点是否密度可达
while len(ind) > 0:
dealed[ind[0] 0] = 1
D = dis[ind[0] ]
tmp = ind[0]
del ind[0]
ind_1 = find_eps(D eps)
if len(ind_1) > 1: # 处理非噪音点
for x1 in ind_1:
sub_class[0 x1] = number
if len(ind_1) >= MinPts + 1:
types[0 tmp] = 1
else:
types[0 tmp] = 0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter12_DBSCAN\
文件 1520 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter12_DBSCAN\data.txt
文件 4631 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter12_DBSCAN\dbscan.py
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_1 Logistic Regression\
文件 32 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_1 Logistic Regression\README.md
文件 7251 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_1 Logistic Regression\data.txt
文件 2420 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_1 Logistic Regression\lr_test.py
文件 2907 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_1 Logistic Regression\lr_train.py
文件 6851 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_1 Logistic Regression\test_data
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_10 KMeans\
文件 4278 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_10 KMeans\KMeans.py
文件 2746 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_10 KMeans\KMeanspp.py
文件 2800 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_10 KMeans\data.txt
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_11 MeanShift\
文件 3001 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_11 MeanShift\data
文件 5620 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_11 MeanShift\mean_shift.py
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_13 LabelPropagation\
文件 131 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_13 LabelPropagation\cd_data.txt
文件 4356 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_13 LabelPropagation\lb.py
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_14 CollaborativeFiltering\
文件 50 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_14 CollaborativeFiltering\data.txt
文件 2386 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_14 CollaborativeFiltering\item_ba
文件 3737 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_14 CollaborativeFiltering\user_ba
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_15 MatrixFactorization\
文件 50 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_15 MatrixFactorization\data.txt
文件 4325 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_15 MatrixFactorization\mf.py
文件 1720 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_15 MatrixFactorization\nmf.py
目录 0 2018-04-16 23:33 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_16 PersonalRank\
文件 50 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_16 PersonalRank\data.txt
文件 3262 2017-12-01 23:19 机器学习算法Python-Machine-Learning-Algorithm-master\Chapter_16 PersonalRank\personal_rank.py
............此处省略51个文件信息
相关资源
- Logistic回归总结非常好的机器学习总结
- Convex Analysis and Optimization (Bertsekas
- 机器学习个人笔记完整版v5.2-A4打印版
- JUNIOR:粒子物理学中无监督机器学习
- 语料库.zip
- 中国科学技术大学 研究生课程 机器学
- 遗传算法越野小车unity5.5
- 吴恩达机器学习编程题
- shape_predictor_68_face_landmarks.dat.bz2 68个标
- 机器学习实战高清pdf,中文版+英文版
- 李宏毅-机器学习(视频2017完整)
- 机器学习深度学习 PPT
- 麻省理工:深度学习介绍PPT-1
- Wikipedia机器学习迷你电子书之四《D
- Learning From Data Yaser S. Abu-Mostafa
- 北大林宙辰:机器学习一阶算法的优
- 李宏毅深度学习ppt
- 机器学习方法R实现-用决策树、神经网
- 数字金融反欺诈白皮书
- 机器学习班PPT原件全邹博
- 机器学习实战(源码和数据样本)
- 计算广告含有目录 刘鹏版
- 数据挖掘导论完整版PPT及课后习题答
- kaggle信用卡欺诈数据
- 机器学习技法原始讲义和课程笔记
- 机器学习数学 陈希孺《 概率论与数理
- 概率论与数理统计陈希孺
- 哈尔滨工业大学深圳 机器学习 2017 考
- [概率论与数理统计]陈希孺带目录
- 刘鹏计算广告完整超清晰带目录版
评论
共有 条评论