forked from PRML/PRMLT
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
42 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
Pattern Recognition and Machine Learning | ||
=========== | ||
|
||
This package contains the matlab implementation of the algorithms described in the book: | ||
Pattern Recognition and Machine Learning by C. Bishop (http://research.microsoft.com/en-us/um/people/cmbishop/prml/) | ||
|
||
|
||
License | ||
------- | ||
Currently Released Under GPLv3 | ||
|
||
|
||
Contact | ||
------- | ||
sth4nth(CHEN, Mo) [username] at gmail dot com | ||
sth4nth at gmail dot com | ||
|
||
KuantKid(LI,Wei) [username] at gmail dot com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function z = nmi(x, y) | ||
% Compute nomalized mutual information I(x,y)/sqrt(H(x)*H(y)). | ||
% Compute normalized mutual information I(x,y)/sqrt(H(x)*H(y)). | ||
% x, y: two vectors of integers of the same length | ||
% Written by Mo Chen ([email protected]). | ||
assert(numel(x) == numel(y)); | ||
|
@@ -18,6 +18,8 @@ | |
Pxy = nonzeros(Mx'*My/n); %joint distribution of x and y | ||
Hxy = -dot(Pxy,log2(Pxy)); | ||
|
||
|
||
% hacking, to elimative the 0log0 issue | ||
Px = nonzeros(mean(Mx,1)); | ||
Py = nonzeros(mean(My,1)); | ||
|
||
|
@@ -31,3 +33,4 @@ | |
% normalized mutual information | ||
z = sqrt((MI/Hx)*(MI/Hy)); | ||
z = max(0,z); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
function z = nvi(x, y) | ||
% Compute nomalized variation information (1-I(x,y)/H(x,y)). | ||
% Compute normalized variation information (1-I(x,y)/H(x,y)). | ||
% x, y: two vectors of integers of the same length | ||
% Written by Mo Chen ([email protected]). | ||
assert(numel(x) == numel(y)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,25 @@ | ||
% Done | ||
% demo for chapter 03 | ||
clear; close all; | ||
n = 100; | ||
beta = 1e-1; | ||
X = rand(1,n); | ||
w = randn; | ||
b = randn; | ||
t = w'*X+b+beta*randn(1,n); | ||
x = linspace(min(X)-1,max(X)+1,n); % test data | ||
|
||
% d = 1; | ||
% n = 200; | ||
% [X,t,model] = linRnd(d,n); | ||
% plotBand(X,t,2*model.sigma); | ||
d = 1; | ||
n = 200; | ||
[x,t,model] = linRnd(d,n); | ||
linPlot(model,x,t); | ||
%% | ||
model = linReg(X,t); | ||
y = linPred(model,x); | ||
figure; | ||
hold on; | ||
plot(X,t,'o'); | ||
plot(x,y,'r-'); | ||
hold off | ||
model = linReg(x,t); | ||
linPlot(model,x,t); | ||
fprintf('Press any key to continue. \n'); | ||
pause | ||
%% | ||
[model,llh] = linRegEbEm(X,t); | ||
[y, sigma] = linPred(model,x,t); | ||
[model,llh] = linRegEbEm(x,t); | ||
linPlot(model,x,t); | ||
figure; | ||
hold on; | ||
plotBand(x,y,2*sigma); | ||
plot(X,t,'o'); | ||
plot(x,y,'r-'); | ||
hold off | ||
figure | ||
plot(llh); | ||
linPlot(model,x,t) | ||
fprintf('Press any key to continue. \n'); | ||
pause | ||
%% | ||
[model,llh] = linRegEbFp(X,t); | ||
[model,llh] = linRegEbFp(x,t); | ||
[y, sigma] = linPred(model,x,t); | ||
linPlot(model,x,t); | ||
figure; | ||
hold on; | ||
plotBand(x,y,2*sigma); | ||
plot(X,t,'o'); | ||
plot(x,y,'r-'); | ||
hold off | ||
figure | ||
plot(llh); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
function linPlot(model, x, t) | ||
% Plot linear function and data | ||
% X: 1xn data | ||
% t: 1xn response | ||
% Written by Mo Chen ([email protected]). | ||
color = [255,228,225]/255; %pink | ||
[y,sigma] = linPred(model,x,t); | ||
h = 2*sigma; | ||
|
||
[x,idx] = sort(x); | ||
t = t(idx); | ||
[y,s] = linPred(model,x); | ||
figure; | ||
hold on; | ||
x = x(:); | ||
y = y(:); | ||
fill([x;flipud(x)],[y+h;flipud(y-h)],color); | ||
fill([x,fliplr(x)],[y+s,fliplr(y-s)],color); | ||
plot(x,t,'o'); | ||
plot(x,y,'r-'); | ||
hold off | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters