In [10]:
import numpy as np
from sklearn.svm import SVR
import matplotlib.pyplot as plt
# Generate sample data
X = np.sort(5*np.random.rand(40,1), axis=0)
y = X**3
y=y.ravel()
# Add noise to targets
X[::4] +=3*(0.5 - np.random.rand(1))
y[::5] += 50 * (0.5 - np.random.rand(8))
plt.plot(X,y, 'g^')
plt.show()
#neural network example from scikit-learn website
from sklearn.neural_network import MLPClassifier
X1=[[0., 0.], [1., 1.]]
y1=[0,1]
clf=MLPClassifier(solver='lbfgs', alpha=0.001, hidden_layer_sizes=(5,2), random_state=1)
clf.fit(X1,y1)
print (clf.predict([[2., 2.], [-1., -2.]]))
[coef.shape for coef in clf.coefs_]
clf.predict_proba([[2., 2.], [1., 2.]])
Out[10]:
In [ ]: