In error function

if I append the value returned from error function then extra term also come why?
like:- [array([0.09379479])]
why array is written here as I only returned value not array

Hey @Jan19LPN0013, could you pls share the code of your error function by saving it on cb.lk/ide.

here is the code plz check why array is written:- https://ide.codingblocks.com/s/222250

Hey @Jan19LPN0013, your code is fine, just make in line 31 your code line is

e=error(X,Y,thetha)

it should be

e=error(X,Y,thetha)[0]

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

but why we should use [0] at the end as I only passed a value from error function why an extra term array is appended in the list

Hey @Jan19LPN0013, its becauese e is a numpy array, that’s the reason we add [0], which will extract 0th element from the numpy array. Otherwise e will be a numpy array and when you add it to list, array word will be printed when you print th error_list to signify that the values ahead is the numpy array.

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

but when we print thetha in that array is not written why?
as we have done the same steps for thetha_list also

Hey @Jan19LPN0013, in case of such small doubts, just try to print and explore yourself, you need not to depend on us for clarification. Here’s what you should have tried,

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:


my only problem is why error function is returning array instead of float value and I have created my own error function in which I passed the only array a same as main error function but that does not return array it returns an only value and why main error function return array plz explain?

Hey @Jan19LPN0013, instead of passing a[0], this is because hypothesis function in our code returns, numpy array of shape (1,) and not a scalar value. Try to print it using print statement.