资源简介
机器学习基础教程(Rogers)内的源码,包含.m和.r文件,大家下载学习吧!
代码片段和文件信息
import numpy as np
class SimpleSVM(object):
def __init__(selftrainxtraintkernel=‘rbf‘kpar = 1.0C = 2tol=1e-10max_passes = 1000):
self.trainx = trainx
self.traint = traint
self.kernel = kernel
self.kpar = kpar
self.C = C
self.tol = tol
self.max_passes = max_passes
self.N = len(self.traint)
self.K = self.kernel_matrix()
self.alpha = np.zeros_like(traint)
self.b = 0.0
def test_kernel(selftestx):
testK = np.zeros_like(self.traint)
if self.kernel == ‘linear‘:
testK = np.dot(self.trainxtestx.T)[:None]
elif self.kernel == ‘rbf‘:
for i in range(self.N):
testK[i] = np.exp(-self.kpar * ((self.trainx[i:]-testx)**2).sum())
return testK
def kernel_matrix(self):
K = None
if self.kernel == ‘linear‘:
K = np.dot(self.trainxself.trainx.T)
elif self.kernel == ‘rbf‘:
K = np.zeros((self.Nself.N))
for i in range(self.N):
for j in range(self.N):
K[ij] = np.exp(-self.kpar * ((self.trainx[i:]-self.trainx[j:])**2).sum())
return K
def train_predict(selfi):
ksub = self.K[i:][:None]
return (ksub*self.alpha*self.traint).sum() + self.b
def test_predict(selftestx):
testK = self.test_kernel(testx)
return (testK*self.alpha*self.traint).sum() + self.b
def smo_optimise(self):
# initialise
self.alpha = np.zeros_like(self.traint)
self.b = 0
passes = 0
while passes < self.max_passes:
num_changed_alphas = 0
for i in range(self.N):
Ei = self.train_predict(i) - self.traint[i]
if (self.traint[i]*Ei < -self.tol and self.alpha[i] < self.C) or (self.traint[i]*Ei > self.tol and self.alpha[i] > 0):
j = np.random.randint(self.N)
Ej = self.train_predict(j) - self.traint[j]
alphai = float(self.alpha[i])
alphaj = float(self.alpha[j])
if self.traint[i] == self.traint[j]:
L = max((0alphai+alphaj-self.C))
H = min((self.Calphai+alphaj))
else:
L = max((0alphaj-alphai))
H = min((self.Cself.C+alphaj-alphai))
if L==H:
continue
eta = 2*self.K[ij] - self.K[ii] - self.K[jj]
if eta >= 0:
continue
self.alpha[j] = alphaj - (self.traint[j]*(Ei-Ej))/eta
if self.alpha[j] > H:
self.alpha[j] = H
if self.alpha[j] < L:
self.alpha[j] = L
if abs(self.alpha[j]-alphaj) < 1e-5:
continue
self.alpha[i] = self.alpha[i] + self.traint[i]*self.traint[j]*(alphaj - self.alpha[j])
b1 = self.b - Ei - self.traint[i]*(self.alpha[i] - alphai)*self.K[ii] - self.traint[j]*(self.alpha[j] - alphaj)*self.K[ij]
b2 = self.b - Ej - self.traint[i]*(self.alpha[i] - alphai)*self.K[ij] - s
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 64956 2018-10-18 04:38 机器学习基础教程源码\labs\bayesian_regression\.ipynb_checkpoints\Bayesian Regression for the Olympic Data-checkpoint.ipynb
....... 189788 2018-10-18 04:38 机器学习基础教程源码\labs\bayesian_regression\bayes_regression2.pdf
....... 274 2018-10-18 04:38 机器学习基础教程源码\labs\bayesian_regression\data100m.csv
....... 208218 2018-10-18 04:38 机器学习基础教程源码\labs\bayesian_regression\olymp_bayes.pdf
....... 27957 2018-10-18 04:38 机器学习基础教程源码\labs\classification\.ipynb_checkpoints\KNN-checkpoint.ipynb
....... 160746 2018-10-18 04:38 机器学习基础教程源码\labs\classification\knn.pdf
....... 163994 2018-10-18 04:38 机器学习基础教程源码\labs\classification\logreg.pdf
....... 170770 2018-10-18 04:38 机器学习基础教程源码\labs\classification\logreg_metropolis_skeleton.ipynb
....... 209660 2018-10-18 04:38 机器学习基础教程源码\labs\classification\naivebayes.pdf
....... 3466 2018-10-18 04:38 机器学习基础教程源码\labs\classification\simplesvm.py
....... 122629 2018-10-18 04:38 机器学习基础教程源码\labs\classification\SVM.ipynb
....... 118909 2018-10-18 04:38 机器学习基础教程源码\labs\classification\svm.pdf
....... 21414 2018-10-18 04:38 机器学习基础教程源码\labs\classification\testx.csv
....... 5357 2018-10-18 04:38 机器学习基础教程源码\labs\classification\trainx.csv
....... 985610 2018-10-18 04:38 机器学习基础教程源码\labs\clustering\Gaussian_mixture.ipynb
....... 146526 2018-10-18 04:38 机器学习基础教程源码\labs\clustering\kmeans.pdf
....... 101392 2018-10-18 04:38 机器学习基础教程源码\labs\clustering\K_means_skeleton.ipynb
....... 274 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\data100m.csv
....... 42071 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\linear_regression.ipynb
....... 144702 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\linear_regression.pdf
....... 2255 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\max_like.mk
....... 178518 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\max_like.pdf
....... 2612 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\vector_matrices_cv.mk
....... 139534 2018-10-18 04:38 机器学习基础教程源码\labs\linear_regression\vector_matrices_cv.pdf
....... 1792 2018-10-18 04:38 机器学习基础教程源码\matlab\chapter1\.svn\entries
....... 2140 2018-10-18 04:38 机器学习基础教程源码\matlab\chapter1\.svn\text-ba
....... 2140 2018-10-18 04:38 机器学习基础教程源码\matlab\chapter1\.svn\text-ba
....... 852 2018-10-18 04:38 机器学习基础教程源码\matlab\chapter1\.svn\text-ba
....... 1087 2018-10-18 04:38 机器学习基础教程源码\matlab\chapter1\.svn\text-ba
....... 1021 2018-10-18 04:38 机器学习基础教程源码\matlab\chapter1\.svn\text-ba
............此处省略1539个文件信息
- 上一篇:大麦DW22D原厂编程器固件
- 下一篇:银行业数据治理实践德勤.pdf
相关资源
- MatchNet: Unifying Feature and Metric Learning
- Trajectory Planning for Automatic Machines and
- Mastering Machine Learning with Spark 2.X 无水
- 图表示学习Graph representation learning (
- The elements of statistical Learning 书与答案
- Michael Nielsen所著的Neural Networks and De
- Cengage.Learning.Business.Analytics.3rd.Editio
- Learning OpenCV 3
- Learning From Data plus 完整版带目录 林轩
- LearningOpenCV3ComputervisioninC.pdf
- Learning with Kernels - Support Vector Machine
- An Adventure in Statistics_Field Andy Iles Jam
- 2MachineLearning机器学习byTomMitchell英文原
- Coursera machine learning答案
- Hands-On Machine Learning with Scikit-Learn an
- 吴恩达 Deeplearning深度学习笔记v5.41.
- PRML pattern recognition and machine learning
- Hands-On Machine Learning with Scikit-Learn an
- Pattern Recognition And Machine Learning中英文
- Computational Learning Theory
- Deep Learning with Keras
- 李宏毅-Deep Learning Tutorial-300页的PPT
- Grokking-Deep-Learning-master.zip
- deep learning 完整中文版无水印
- Learning the bash Shell 3rd Edition
- Deep Learning with Keras带书签版
- Grokking Deep Learning最新版无水印+源代码
- 全2020吴恩达机器学习MachineLearning课程
- David Silver强化学习reinforcement learning课
- 最经典的机器学习教科书之一:《模
评论
共有 条评论