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
#coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def sigmoid(x,mu,s): | |
a = (x - mu) / s | |
return 1 / (1 + np.exp(-a)) | |
if __name__ == "__main__": |
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
#coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def phi(x,mu,s): | |
return np.exp(-(pow(x-mu,2))/(2*pow(s,2))) | |
if __name__ == "__main__": | |
N = 1000 |
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
#coding: utf-8 | |
from sklearn.multiclass import OneVsRestClassifier | |
from sklearn.svm import LinearSVC,SVC | |
import numpy as np | |
from sklearn.metrics import recall_score,precision_score,f1_score | |
from sklearn import datasets | |
class SVM: | |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
import random | |
from matplotlib import pyplot as plt | |
def makeData(trainNum): | |
noise = np.random.randn(trainNum) * 0.1 #make a noise | |
xTrain = np.random.rand(trainNum) #training data |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
from matplotlib import pyplot as plt | |
def function(x): | |
return np.sin(x) | |
def diff(x,n): |
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import numpy as np | |
from matplotlib import pyplot as plt | |
def function(x): | |
return x ** 2 - 4 * x + 4 | |
def diff(x): #数値微分 |
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
#coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def norm(x,mu,sigma): | |
return (1 / pow(2 * np.pi,x.shape[0]/2)) * (1 / pow(np.linalg.det(sigma),0.5)) * np.exp(-0.5 * np.dot(x - mu,np.linalg.inv(sigma)).dot(x - mu)) | |
if __name__ == "__main__": | |
x = np.linspace(-5.0, 5.0, 200) | |
y = np.linspace(-5.0, 5.0, 200) |
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
#coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
def norm(x,mu,sigma): | |
return 1 / pow(2*np.pi*sigma,0.5) * np.exp(-0.5*pow(x-mu,2)/sigma) | |
if __name__ == "__main__": | |
N = 1000 |
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
#coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.mlab as mlab | |
from scipy.special import gamma | |
N = 100 | |
alpha = [0.1,1.0,2.0,8.0,10.0] | |
beta = [0.1,1.0,3.0,4.0,10.0] |
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
#coding: utf-8 | |
import numpy as np | |
import matplotlib.pyplot as plt | |
import matplotlib.mlab as mlab | |
def bern(x,p): | |
return pow(p,x) * pow(1-p,1-x) | |
if __name__ == "__main__": |
NewerOlder