'''
@Author _ Nikesh Bajaj PhD Student at Queen Mary University of London & University of Genova Conact _ http://nikeshbajaj.in n[dot]bajaj@qmul.ac.uk bajaj[dot]nikkey@gmail.com '''
import time
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
import DataSet as ds
from LogisticRegression import LR
%matplotlib notebook
plt.close('all')
dtype = ['MOONS','GAUSSIANS','LINEAR','SINUSOIDAL','SPIRAL']
#X, y,_ = ds.create_dataset(200, dtype[2],0.05,varargin = 'PRESET')
X, y,_ = ds.create_dataset(500, dtype[0],0.05,varargin = 'PRESET')
print(X.shape, y.shape)
means = np.mean(X,1).reshape(X.shape[0],-1)
stds = np.std(X,1).reshape(X.shape[0],-1)
X = (X-means)/stds
Clf = LR(X,y,alpha=0.001,lambd=3,polyfit=True,degree=5)
fig=plt.figure(figsize=(10,4))
delay=0.01
gs=GridSpec(1,2)
ax1=fig.add_subplot(gs[0,0])
ax2=fig.add_subplot(gs[0,1])
for i in range(50):
Clf.fit(X,y,itr=10,verbose=False)
ax1.clear()
Clf.Bplot(ax1,hardbound=True)
ax2.clear()
Clf.LCurvePlot(ax2)
fig.canvas.draw()
time.sleep(delay)
yprob,yp = Clf.predict(X)
print('Accuracy::: Training :',100*np.sum(yp==y)/yp.shape[1])
(2, 500) (1, 500)
Accuracy::: Training : 88.6