Neural Networks

sklearn neural_net & export to js !

# -*- coding: utf-8 -*-
"""
Created on Mon Jan 21 01:30:05 2019

@author: K
"""

from sklearn.preprocessing import StandardScaler
from sklearn.datasets import load_breast_cancer
cancer = load_breast_cancer()
print(cancer['data'].shape)
X = cancer['data']
y = cancer['target']

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y)

#from sklearn.preprocessing import StandardScaler
from sklearn import preprocessing
#scaler = StandardScaler()
# Fit only to the training data
X_train = preprocessing.scale(X_train)

Réseau neuronal à 1 couche cachée


# -*- coding: utf-8 -*-
"""
Created on Thu Dec 13 14:50:40 2018

@author: K
"""

import numpy as np
import time
import scipy.io
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split

datas = scipy.io.loadmat('ex4data1.mat')
X = datas["X"]
y =  datas["y"]
im = X[2098].reshape(20, 20);
plt.imshow(im, cmap='gray')
#plt.imshow(X[0]).reshape([20, 20]);


#print(type(X[0]))
#realout = 
Y = np.zeros((5000,1))
for i in range(0, 5000):
    for j in range(1, 10):
        if np.mod(y[i],2) == 0:
            Y[i,0] = 1
        else:
Subscribe to Neural Networks