Low accuracy with logistic regression, desired error not necessarily achieved due to precision loss
been trying to implement coursera's machine learning course in python. I am stuck on recognizing handwritten digits/exercise 3, my accuracy is 84% instead of 94% and I am getting a warnings aswell. Ive been checking the gradient and compute_cost for days but I just cant anymore, I would really, really appreciate any insights.
See also questions close to this topic

reducer to find the most popular movie for each age group in python
I am trying to write mapper reducer for Hadoop to find the movies with 5 rating "the popular movies" for each age group.
I write this
mapper.py
to join the tow data set with the user Id to get the age from user data and the rating with the movie name from the rating data set .!/usr/bin/env python:
import sys for line in sys.stdin: # remove leading and trailing whitespace line = line.strip() line = line.split("::") rating = "1" movie = "1" user = "1" age = "1" if len(line) == 4 : #ratings data rating = line[2] movie = line[1] user = line[0] #print '%s %s %s' % (user,movie,rating) else: # users data user = line[0] age = line[2] print '%s\t%s\t%s\t%s' % (user,age,rating,movie)
this is the data structure rating data: userid, movieid, rating, timestamp user data: userid, gender, age, occupation
The reducer I wrote is not working at all it gave me 0 result.
I want the result to be the top popular movies for each age group:
1 2254 4567 18 8732 0987 0986 25 7654 8765 7658 35 6543 7645 7654 45 7654 8765 5433 50 7652 1876 7654 56 3986 3956

How to compr two columns from two DFs keeping some column constants and print row?
I'm working on a project where I have to find the changes done in second sheet (specific column) as compare to primary/Master sheet. after that I wanted to print or save the complete row in which changes are found. here are more details. both the excel sheets have many columns my master sheet has data something like as follows:
TID LOC HECI RR UNIT SUBD S EUSE INV ACT CAC FMT CKT DD SCID CUSTOMER F&E/SERVICE ID BVAP PORD AUTH RULE ST RGN CHCGILDTO3P050101D CHCGILDTO3P M3MSA0S1RA 0501.01D 1A1 IE D STR3RA8 S CL/HFFS/688898 /LGT 20180721 BLOOMBERG LP DS316668545 WMS881282 E.485339 IL N CHCGILDTO3P050101D CHCGILDTO3P M3MSA0S1RA 0501.01D 1A2 IE J DNA UNDER DECOM EID 2466 20190322 WMS881282 E.485339 IL N CHCGILDTO3P050101D CHCGILDTO3P M3MSA0S1RA 0501.01D 1A3 IE J DNA UNDER DECOM EID 2466 20190322 WMS881282 E.485339 IL N CHCGILDTO3P050101D CHCGILDTO3P M3MSA0S1RA 0501.01D 1A4 IE J DNA UNDER DECOM EID 2466 20190322 WMS881282 E.485339 IL N CHCGILDTO3P050101D CHCGILDTO3P M3MSA0S1RA 0501.01D 1A5 IE J DNA UNDER DECOM EID 2466 20190322 WMS881282 E.485339 IL N
and my second sheet has data as follows :
HECI UNIT INV SUB ACT CKT PACT DD LOC RR M3MSA0S1RA 1A1 IE $ CL/HFFS/688898 /LGT D 72118 CHCGILDTO3P 0501.01D M3MSA0S1RA 1A2 IE J DNA UNDER DECOM EID 2466 32219 CHCGILDTO3P 0501.01D M3MSA0S1RA 1A3 IE J DNA UNDER DECOM EID 2466 32219 CHCGILDTO3P 0501.01D M3MSA0S1RA 1A4 IE J DNA UNDER DECOM EID 2466 32219 CHCGILDTO3P 0501.01D M3MSA0S1RA 1A5 IE J DNA UNDER DECOM EID 2466 32219 CHCGILDTO3P 0501.01D
so first i want to check if the values of LOC HECI RR & UNIT are same in both the sheets I want to move forward and comapre ACT column and print the difference as output.
for example you can see row #1 in Master data ACT is 'D' and where as in second sheet its changes to '$'
so I want output something like related complete row which says its changes from 'D' to '$'
this seems very complicated to me as I'm at beginning stage of python and pandas.
I tried using loops but unable to execute also if I use too much loop that's not the pandas way I believe
here is my code:
import pandas as pd df1 = pd.read_excel("Master Database.xlsx") df2 = pd.read_excel("CHCGILDTO3P_0501.01D.xlsx") d1_act = df1['ACT'] d2_act = df2['ACT'] for index1, row1 in df1.iterrows(): for index2, row2 in df2.iterrows(): if(row1['LOC'],row1['HECI'],row1['RR']) ==(row2['LOC'],row2['HECI'],row2['RR']): for x in d1_act and y in d2_act: #print(x,y) if x != y: print (x, y) # not getting how to print complete respective row else: pass else: pass
I want ouput like:
M3MSA0S1RA 1A1 IE $ CL/HFFS/688898 /LGT D 72118 CHCGILDTO3P 0501.01D
changes from 'D to '$'
please assist ! thank you in advance!

merge duplicate cells of a column
My Current excel looks like:
  Type  Val    A  1    A  2    B  3    B  4    B  5    C  6 

This is the required excel:
  Type  Val  Sum    A  1  3       2     B  3  12       4        5     C  6  6  
Is it possible in python using pandas or any other module?

How to group elements (of a tensor) according to classification tensor and calculate the std of each cluster (Tensorflow)?
I have a tensor of dimension [n_samples, height, width], i.e., many images.
I have another tensor of dimension [n_samples,], i.e, each element of this tensor is the cluster index of one image in the first tensor.
Now how can I calculate the variance of each cluster (clustering of the first tensor is based on the second tensor)in Tensorflow?
I found some Tensorflow function like unsorted_segment_mean which does the similar thing but I cannot figure out how to calculate variance? Can anyone help me with that? Thank you!

NumPy cumsum rounding issue
I am new to Numpy and I am vectorizing a homemade function that uses numpy's cumsum() for its calculation. However I found the result has some rounding error whose culprit seems to be the cumsum(). It can be shown as follows:
import numpy as np X = np.repeat(30000.1,114569) X1 = X**2 Y = np.cumsum(X1) Z =Y[1:]  Y[:1] print(f'Theoretical value: 900006000.01') print(f'first member of X1: {X1[0]}') print(f'first member of Z: {Z[0]}') print(f'last member of Z: {Z[1]}') print('They are mathematically the same, but in reality they are different')
The result is:
Theoretical value: 900006000.01 first member of X1: 900006000.0099999 first member of Z: 900006000.0099999 last member of Z: 900006000.015625 They are mathematically the same, but in reality they are different
Here are my questions:
1) Are there anyways to improve the precision of cumsum?
2a) If there are, can you show me a simple example?
2b) If not, then what's the known maximum size of a float64 or maximimum length of argument vector before cumsum run into rounding errors?
3) Are there any package in python to handle calculations with high precision floating point numbers
Thank you in advance
EDIT: changed the number to fewer decimal places to emphasize the issue here. I mean the problem of rounding error appears as early as 2 decimal places, I think it is a really big problem.
EDIT2: some people pointed out that the subtraction between big numbers also contributes to the error. My another question is that is there anyway in python to handle the numerical errors that stem from the subtraction between two big numbers?

Numpy dot product of a matrix and an array is a matrix
When I updated to the most recent version of numpy, a lot of my code broke because now every time I call
np.dot()
on a matrix and an array, it returns a 1xn matrix rather than simply an array. This causes me an error when I try to multiply the new vector/array by a matrixexample
A = np.matrix( [ [4, 1, 0, 0], [1, 5, 1, 0], [0, 1, 6, 1], [1, 0, 1, 4] ] ) x = np.array([0, 0, 0, 0]) print(x) x1 = np.dot(A, x) print(x1) x2 = np.dot(A, x1) print(x2) output: [0 0 0 0] [[0 0 0 0]] Traceback (most recent call last): File "review.py", line 13, in <module> x2 = np.dot(A, x1) ValueError: shapes (4,4) and (1,4) not aligned: 4 (dim 1) != 1 (dim 0)
I would expect that either dot of a matrix and vector would return a vector, or dot of a matrix and 1xn matrix would work as expected.
Using the transpose of x doesn't fix this, nor does using
A @ x
, orA.dot(x)
or any variation ofnp.matmul(A, x)

Is there a way to interpolate series with recurring values using matplotlib?
I am trying to interpolate a x/y series using
matplotlib
. The problem I am facing is thatspline
andinterp1d
fail because I have recurring values in both the x and y arrays.I have tried using the spline and
interp1d
functions fromscipy
, but both fail because of the recurring values issuex1 = [0.82 0.82 0.82 0.82 0.82 0.82 0.83 0.83 0.83 0.83 0.83 0.83 0.83] y1 = [0.93 0.93 0.93 0.93 0.94 0.94 0.94 0.94 0.94 0.94 0.94 0.94 0.94] f = interp1d(x1, y1, kind='cubic') #this gives an error: Expect x to be a 1D sorted array_like. #another thing I tried xnew = np.linspace(x1.min(),x1.max(),300) splined = spline(x1,y1,xnew) #this gives an error: Matrix is singular
I am expecting the interpolated y value to gradually increase with the increase of x. So for example, the corresponding y value for x = 0.82 would be 0.931, 0.932, etc. My goal in the end is to get a smooth curve.

Small script for bandpass filter fails
I am currently trying to create new audio files from existing audio files by putting it through a bandpass filter. I am using Scipy to do the transformation based on few guides I have read. My code is straightforward but I get the following error: "File format b... not understood." Any input would be much appreciated! Thank you so much
from scipy.io import wavfile from scipy import signal import numpy as np #load sr, x = wavfile.read("path\\to\\file") #transform b = signal.butter(1, Wn =[20, 300], btype='band', pass_zero=False) x = signal.lfilter(b, [1.0], x) #write wavfile.write('test2.wav', sr, x.astype(np.int16))

How to pass an array of input parameters in scipy.optimize.minimize?
I want to use scipy.optimize.minimize to solve for a set of parameters by minimizing an error function.
The function called "error" returns the squared error for the function that I am trying to find z1,z2,z3(the parameters) for.
I have an array of x(called "b" in the function) and y(called "real" in the function) values.
The code below works fine if I set x and y to some integer, but not if I try to pass in an array of x and y values, to act as the variable "b" and "real" in the equation to be minimized.
Trying to pass in an array of X and Y values results in the error pasted below.
Is there a way to pass in arrays to act as a variable in an equation for the minimize function, instead of just a single integer?
Here is what my code looks like:
import numpy as np import pandas as pd from scipy.optimize import minimize #dataset file, with a column named x,y with 1000 rows f = pd.read_csv('Test_Data_.txt', sep='\t') #initial guess x0 = [1, 2, 3] #f['x'] and f['y'] are columns with 1000 rows #x = f['x'].values #y = f['y'].values x = 1 #these parameters work fine y = 4 #a function called inside the function to be minimized def est(z1, z2, z3, b): return z1 * b**2 + z2 * b + z3 #function to minimize def error(x, real, b): return (real  est(x[0], x[1], x[2], b))**2 print(minimize(error, x0, args = ( x, y), method='BFGS', tol=1e6))
Feeding in the array of x and y values produces the error:
Traceback (most recent call last): File "problem1.py", line 24, in <module> minimize(error, x0, args = ( np.array(list(f['y'].values)), np.array(list(f['x'].values))), method='BFGS', tol=1e6) File "/usr/local/lib/python3.5/distpackages/scipy/optimize/_minimize.py", line 595, in minimize return _minimize_bfgs(fun, x0, args, jac, callback, **options) File "/usr/local/lib/python3.5/distpackages/scipy/optimize/optimize.py", line 970, in _minimize_bfgs gfk = myfprime(x0) File "/usr/local/lib/python3.5/distpackages/scipy/optimize/optimize.py", line 300, in function_wrapper return function(*(wrapper_args + args)) File "/usr/local/lib/python3.5/distpackages/scipy/optimize/optimize.py", line 730, in approx_fprime return _approx_fprime_helper(xk, f, epsilon, args=args) File "/usr/local/lib/python3.5/distpackages/scipy/optimize/optimize.py", line 670, in _approx_fprime_helper grad[k] = (f(*((xk + d,) + args))  f0) / d[k] ValueError: setting an array element with a sequence.

Error: java.lang.IllegalArgumentException: invalid method areaUnderROC for object 281
Sparklyr  Multiclass Logistic Regression issue
We were trying to fit a multiclass logistic regression model in sparklyr. The dataset used “mtcars” , the target variable which we were trying to predict is ‘gear’, which has 3 class,method “ml_logistic_regression” threw following error “Error: java.lang.IllegalArgumentException: invalid method areaUnderROC for object 281" The code works fine for the target variable “am” which has 2 classes
sc < spark_connect(master="yarnclient", version=spark_version, config=config, spark_home=spark_home)
Converting mtcars dataset to spark dataframe
mtcars_tbl < sdf_copy_to(sc, mtcars, name = "mtcars_tbl", overwrite = TRUE)
Fitting Binary Logistic Regression. 'am' is a binary variable
lr_model < mtcars_tbl %>% ml_logistic_regression(am ~ gear + carb)
Finding: The code gets executed successfully
Fitting Multiclass Logistic Regression. 'gear' has 3 unique values
lr_model < mtcars_tbl %>% ml_logistic_regression(gear ~ am + carb, family='multinomial')
Finding: Throws an error

How to fix 'Error in x[which(data$Status == 1), ] : incorrect number of dimensions' in R?
I want to perform logistic regression with genetic algorithm for variable selection with stratified 5 fold cross validation. I run my r script, but i got this error: Error in x[which(data$Status == 1), ] : incorrect number of dimensions. How can I fix this error?
My data consist of dependent variable with 2 classes and 6 independent variable.
#DATA Status = sample(c(1,0), 50, replace = TRUE) col1 = sample(c(0,1), 50, replace = TRUE) col2 = sample(c(0,1), 50, replace = TRUE) col3 = sample(c(0,1), 50, replace = TRUE) col4 = sample(c(0,1), 50, replace = TRUE) col5 = sample(c(0,1), 50, replace = TRUE) col6 = sample(31:80) data < data.frame(Status, col1, col2, col3, col4, col5, col6) #CONVERT TO FACTOR for(k in 1:6) { data[, k] < as.factor(data[, k]) }
I change my data type with as.factor
#Randomly shuffle the data data<data[sample(nrow(data)),] datax=data[,2:7] datay=data[,1] datay0=data[which(data$Status==1),] datay0=datay0[,1] datay1=data[which(data$Status==0),] datay1=datay1[,1] n0=length(datay0) n1=length(datay1) #Create 5 equally size folds folds0 < cut(seq(1,length(datay0)),breaks=5,labels=FALSE) folds1 < cut(seq(1,length(datay1)),breaks=5,labels=FALSE) library(caret) #Perform 5 fold cross validation fitness < function(string) { inc < which(string==1) x < datax[,inc] datax0=x[which(data$Status==1),] datax1=x[which(data$Status==0),] akurasi< rep(0,5) sensi< rep(0,5) speci<rep(0,5) auc< rep(0,5) for(i in 1:5){ #Segement your data by fold using the which() function testIndexes0 < which(folds0==i,arr.ind=TRUE) testIndexes1 < which(folds1==i,arr.ind=TRUE) trainx0 < datax0[testIndexes0, ] trainx1 < datax1[testIndexes1, ] trainy0 < datay0[testIndexes0] trainy1 < datay1[testIndexes1] testx0 < datax0[testIndexes0, ] testx1 < datax1[testIndexes1, ] testy0 < datay0[testIndexes0] testy1 < datay1[testIndexes1] if(ncol(x)==1){ xtrain < data.frame(c(trainx0,trainx1)1) colnames(xtrain) = "x" xtest < data.frame(c(testx0,testx1)1) colnames(xtest) = "x" } else { xtrain < rbind(trainx0,trainx1) xtest < rbind(testx0,testx1) } ytrain < c(trainy0, trainy1)1 ytest < c(testy0,testy1)1 #Use the test and train data partitions however you desire... b < data.frame(cbind(ytrain,xtrain)) model < glm(as.factor(ytrain)~.,data=b, family=binomial(link='logit')) predtest=as.factor(ifelse(predict(model,xtest,type='response')>0.5,1,0)) cm < confusionMatrix(predtest, as.factor(ytest)) akurasi[i] < cm$overall['Accuracy'] sensi[i] < cm$byClass['Sensitivity'] speci[i] < cm$byClass['Specificity'] auc[i] < 0.5*(sensi[i]+speci[i]) } mean.auc=mean(auc) return(mean.auc) } library(GA) gaControl("binary" = list(selection = "ga_rwSelection")) GA_REGLOG < ga("binary", fitness = fitness, nBits = ncol(datax), names = colnames(datax), selection = gaControl("binary")$selection, popSize = 100, pcrossover = 0.8, pmutation = 0.1, maxFitness = 1)
I think, there is problem here
datax0=x[which(data$Status==1),] datax1=x[which(data$Status==0),]

fit logistic regression model with cross validation
I want to Evaluate a Logistic regression with cross validation. I did this:
from sklearn.preprocessing import StandardScaler from sklearn import preprocessing from sklearn.metrics import classification_report from sklearn.model_selection import cross_val_predict X = preprocessing.normalize(X) X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.3,random_state=0) model = LogisticRegression(class_weight= 'balanced') print(cross_val_score(model, X, y, cv=5, scoring='roc_auc').mean()) model.fit(X_train, y_train) predicted = cross_val_predict(model, X, y, cv=5) report = classification_report(y, predicted) print(report)
How can i do to have a classification report of my model of logistic regression evaluated by cross validation.

Exploding gradient for gpflow SVGP
When optimizing a SVGP with Poisson Likelihood for a big data set I see what I think are exploding gradients. After a few epochs I see a spiky drop of the ELBO, which then very slowly recovers after getting rid of all progress made before. Roughly 21 iterations correspond to an Epoch.
This spike (at least the second one) resulted in a complete shift of the parameters (for vectors of parameters I just plotted the norm to see changes):
How can I deal with that? My first approach would be to clip the gradient, but that seems to require digging around the gpflow code.
My Setup:
Training works via Natural Gradients for the variational parameters and ADAM for the rest, with a slowly (linearly) increasing schedule for the Natural Gradient Gamma.
The batch and inducing point sizes are as large as possible for my setup (both 2^12, with the data set consisting of ~88k samples). I include 1e5 jitter and initialize the inducing points with kmeans.
I use a combined kernel, consisting of a combination of RBF, Matern52, a periodic and a linear kernel on a total of 95 features (a lot of them due to a onehot encoding), all learnable. The lengthscales are transformed with gpflow.transforms.
with gpflow.defer_build(): k1 = Matern52(input_dim=len(kernel_idxs["coords"]), active_dims=kernel_idxs["coords"], ARD=False) k2 = Periodic(input_dim=len(kernel_idxs["wday"]), active_dims=kernel_idxs["wday"]) k3 = Linear(input_dim=len(kernel_idxs["onehot"]), active_dims=kernel_idxs["onehot"], ARD=True) k4 = RBF(input_dim=len(kernel_idxs["rest"]), active_dims=kernel_idxs["rest"], ARD=True) # k1.lengthscales.transform = gpflow.transforms.Exp() k2.lengthscales.transform = gpflow.transforms.Exp() k3.variance.transform = gpflow.transforms.Exp() k4.lengthscales.transform = gpflow.transforms.Exp() m = gpflow.models.SVGP(X, Y, k1 + k2 + k3 + k4, gpflow.likelihoods.Poisson(), Z, mean_function=gpflow.mean_functions.Constant(c=np.ones(1)), minibatch_size=MB_SIZE, name=NAME) m.mean_function.set_trainable(False) m.compile()
UPDATE: Using only ADAM Following the suggestion by user1018464, I switched to ADAM only, which helped me get rid of that sudden explosion. However, I still initialized with an epoch of natgrad only, which seems to save a lot of time.
In addition, the variational parameters seem to change a lot less abrupt (in terms of their norm at least). I guess they'll converge way slower now, but at least it's stable.

Curve fitting with gradient descent
I wrote some code that performs gradient descent on a couple of data points. For some reason the curve is not converging correctly, but I have no idea why that is. I always end up with an exploding tail.
Am I doing one of the computations wrong? Am I actually getting stuck in a local minimum or is it something else?
Here is my code:
import numpy as np import matplotlib.pyplot as plt def estimate(weights, x, order): est = 0 for i in range(order): est += weights[i] * x ** i return est def cost_function(x, y, weights, m): cost = 0 for i in range(m1): cost += (((weights[i] * x ** i)  y) ** 2) return (np.sum(cost ** 2) / ( 2 * m )) def descent(A, b, iterations, descent_rate, order): x = A.T[0] y = b.reshape(4) # features ones = np.vstack(np.ones(len(A))) x = np.vstack(A.T[0]) x2 = np.vstack(A.T[0] ** 2) # Our feature matrix features = np.concatenate((ones,x,x2), axis = 1).T # Initialize our coefficients to zero weights = np.zeros(order + 1) m = len(y) # gradient descent for i in range(iterations): est = estimate(weights, x, order).T difference = est  y weights = weights + (descent_rate * (1/m) * np.matmul(difference, features.T)[0]) cost = cost_function(x, y, weights, m) print(cost) plt.scatter(x,y) u = np.linspace(0,3,100) plt.plot(u, (u ** 2) * weights[2] + u * weights[1] + weights[0], '') plt.show() A = np.array(((0,1), (1,1), (2,1), (3,1))) b = np.array((1,2,0,3), ndmin = 2 ).T iterations = 150 descent_rate = 0.01 order = 2 descent(A, b, iterations, descent_rate, order)
I would like to avoid getting stuck in such a minimum. I have attempted setting the initial weights to random values but to no avail, sometimes it dips a bit more but then gives me the same behaviour again.
Here is the one of the plots that I am getting:
And here is the expected result obtained by a least squares solution:

MiniBatches Gradient Descent vs. Stochastic Grad. Desc. how to show power of Vectorization
I learned:
When comparing Stochastig Gradient Descent (which works on one example only) to MiniBatch Gradient Descent. MiniBatches are faster as cpu can use vectorization during calculation. However I cannot show it. Andrew Ng says in his course(link) at 4:19 min.
So, why do we want to look at b examples at a time rather than look at just a single example at a time as the Stochastic gradient descent? The answer is in vectorization. In particular, Minibatch gradient descent is likely to outperform Stochastic gradient descent only if you have a good vectorized implementation.
Can somebody show me some code that demonstrates this?
I tried by myself but couldn't show it:
I have 1000 Examples
Stochastic gradient descent runs 2 times through all examples ==> 2000 updates
MiniBatches are 100 Examples each so I need 10 Minibatches for all examples and I'm looping 200 times ==> 2000 updates
import time import math, numpy as np from numpy.random import random from matplotlib import pyplot as plt #(Mini)Batch Gradient Descent def upd(x,y): global a_guess, b_guess y_pred = a_guess*x+b_guess a_guess = a_guess  lr * len(x)**1*((y_predy) * x).sum() b_guess = b_guess  lr * len(x)**1*((y_predy)).sum() #This function takes some inputs(e.g. x) and targets (e.g. y) and a desired batch size and slizes data def iterate_minibatches(inputs, targets, batchsize, shuffle=False): assert inputs.shape[0] == targets.shape[0] if shuffle: indices = np.arange(inputs.shape[0]) np.random.shuffle(indices) for start_idx in range(0, inputs.shape[0], batchsize): end_idx = min(start_idx + batchsize, inputs.shape[0]) if shuffle: excerpt = indices[start_idx:end_idx] else: excerpt = slice(start_idx, end_idx) yield inputs[excerpt], targets[excerpt] #Generate some points as X and Y a=3 b=2 n=int(1e3) x = random(n) y = a*x+b plt.scatter(x,y) #Stochastic Gradient Descent with Batchsize=1 a_guess=1 b_guess=1 lr=0.01 batchsize=1 start_time = time.time() for n in range(2): for batch in iterate_minibatches(x, y, batchsize, shuffle=True): x_batch, y_batch = batch upd(x_batch,y_batch) elapsed_time = time.time()  start_time print('CPU time on one Example = ',elapsed_time) y_pred=a_guess*x+b_guess loss=((yy_pred)**2).sum() print( "loss: %.10s, a_guess= %.10s, b_guess= %.10s, a=%.10s, b=%.10s" % (loss,a_guess,b_guess,a,b)) #Setting length of MiniBatches to 100 a_guess=1 b_guess=1 lr=0.01 batchsize=100 start_time = time.time() for n in range(200): for batch in iterate_minibatches(x, y, batchsize, shuffle=True): x_batch, y_batch = batch upd(x_batch,y_batch) elapsed_time = time.time()  start_time print('CPU time on batches with 100 examples each= ',elapsed_time) y_pred=a_guess*x+b_guess loss=((yy_pred)**2).sum() print( "loss: %.10s, a_guess= %.10s, b_guess= %.10s, a=%.10s, b=%.10s" % (loss,a_guess,b_guess,a,b))
However MiniBatches is taking longer. Shouldn't it be the other way around?
CPU time on one Example = 0.03797745704650879 CPU time on batches with 100 examples each= 0.05696702003479004