Commit 5100b04c authored by Xu Jitao's avatar Xu Jitao
Browse files

test merge, partie TP

parent f355aa64
Pipeline #75 failed with stage
in 0 seconds
print("hello world")
import numpy as np
def generate_checkers(nb_app, nb_test, cov=[[0.25,0],[0,0.25]]):
print(cov)
xapp=np.ndarray((nb_app*16,2))
yapp=np.ndarray(nb_app*16)
xtest=np.ndarray((nb_test*16,2))
ytest=np.ndarray(nb_test*16)
y=1
index_app=0
index_test=0
for i in range(0,4):
for j in range(0,4):
center = [i,j]
y = 1 if (i+j) % 2 else -1
xapp[index_app:index_app+nb_app] = np.random.multivariate_normal(center,cov,nb_app)
yapp[index_app:index_app+nb_app] = np.ones(nb_app)*y
xtest[index_test:index_test+nb_test] = np.random.multivariate_normal(center,cov,nb_test)
ytest[index_test:index_test+nb_test] = np.ones(nb_test)*y
index_test += nb_test
index_app += nb_app
return xapp, yapp, xtest, ytest
def generate_linear_separable_case(nb_app,nb_test):
from sklearn.datasets import make_blobs
x, y = make_blobs(n_samples=nb_app+nb_test, centers=2, n_features=2)
x_app = x[0:nb_app,:]
y_app = y[0:nb_app].astype(np.int64)
x_test = x[nb_app:,:]
y_test = y[nb_app:]
y_app[y_app == 0] = -1
y_test[y_test == 0 ] = -1
return x_app, y_app, x_test, y_test
def generate_xor(nb_app,nb_test):
np.random.seed(0)
x_app = np.random.randn(nb_app, 2)
y_app = np.logical_xor(x_app[:, 0] > 0, x_app[:, 1] > 0).astype(int)
y_app[y_app == 0] = -1
np.random.seed(0)
x_test = np.random.randn(nb_test, 2)
y_test = np.logical_xor(x_test[:, 0] > 0, x_test[:, 1] > 0).astype(int)
y_test[y_test == 0] = -1
return x_app,y_app,x_test,y_test
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment