TypeError: fit() got an unexpected keyword argument 'epochs' - neural-network

i'm trying to use NeuralProphet, but get an error with epochs.
my code is:
m = NeuralProphet()
m.fit(price, freq = "M", epochs = 1000)
i get: TypeError: fit() got an unexpected keyword argument 'epochs'.
Anyone know what the problem could be? Tried to follow a tutorial that wrote it like this.

This happens when the function you are calling does not actually take the argument you provide. In this case the "fit" function you are calling does not have "epochs" as its arguments. After having looked into the NeuralProphet code , turns out that it should be something like this :
m = NeuralProphet(epochs = 1000)
m.fit(price, freq = "M")

Related

fzero: Too many output arguments

To learn how to work with fzero() I tried this code:
function equation(x)
k=(96-x)/6;
end
and then:
x0=4;
x=fzero('equation',x0)
The error is:
??? Error using ==> fzero at 307
FZERO cannot continue because user supplied function_handle ==> equation
failed with the error below.
Too many output arguments.
fzerois expecting a return value from your equation so (internally) it is trying to assign something to the output of that function. If I try
result = equation(42);
I get the same error message
Error using equation
Too many output arguments.
Just change your function signature to
function [k] = equation(x)
to indicate that k is the output of this function.
Try to supply the function argument as handle:
x = fzero(#equation,x0)

What is "index should be positive integer(not complex format integer)" in MATLAB?

// I made function like this:
function y = ZL(L,f)
if isvector(f)
y=1j*2*pi.*f*L;
else
y=1j*2*pi.*f*L;
end
// and command :
L = 10,
f= -10000:100:10000,
ZL=ZL(L,f);
// then error :
index should be positive integer(not complex format integer) or boolean
-> this error is translated by me who is Korean; sorry
what's wrong with it?
First time you call ZL = ZL(L,f), you don't get any error.
If you try to call your command a second time, you'll get this error: Index exceeds matrix dimensions. It's because you affect the variable ZL, so the second time it's not the function you're calling but you"re trying to get elements from the array ZL.
So please don't use same name for a variable and an existing function, otherwise the function name is masked by the variable.

Evaluate function in Matlab

I am trying to evaluate the function in t = 1 in Matlab.
How can I get an answer to the following code ?
result = dsolve('D2y-23*Dy+22*y=sin(t)','y(0)=0','Dy(0)=0');
disp(result);
disp(fnval(result, 1));
The first answer is: exp(22*t)/10185 + (23*cos(t))/970 - exp(t)/42 + (21*sin(t))/970.
But when I am trying to find the evaluation of the function in the point t =1, the progrem is throwing some exception. Maybe the 'fnval' function is not suitable for here.
You can use subs.
result = dsolve('D2y-23*Dy+22*y=sin(t)','y(0)=0','Dy(0)=0');
t = 1;
subs(result)
ans =
3.5198e+005
You could also do it using eval, which is similar to your initial approach:
eval(result)
after assigning a value to t.
You can evaluate the function for a number range, using eval together with vectorize:
t = -0.1:0.01:0.1;
plot(t,eval(vectorize(result)))
This gives:

Output argument "val" (and maybe others) not assigned during call to

I have the following function that aims to set a colour to a specific pixel.
function val = xyz(p)
if (p(2,2)) == 40
val=[255,0,0];
end
end
I'm not sure if the function works correct in assigning the colour since I get the following error when I call the function:
Output argument "val" (and maybe others) not assigned during call to.....
How can I solve this issue?
Thanks.
Sebastian said right, you need to add an else to be sure your output is fill.
function val = xyz(p)
if (p(2,2)) == 40
val=[255,0,0];
else
val = [];
end
end

Matlab: how to call a function

This is my function
function [mean,stdev] = stat(x)
n = length(x);
mean = sum(x)/n;
stdev = sqrt(sum((x-mean).^2/n));
and I called
[mean stdev] = stat([12.7 45.4 98.9 26.6 53/1])
??? Undefined function or method 'stat' for input arguments of type 'double'.
I also tried
mean,stdev = stat([12.7 45.4 98.9 26.6 53/1])
??? Input argument "x" is undefined.
Error in ==> mean at 30
y = sum(x,dim)/size(x,dim);
Both of them are wrong and I cannot figure out why.
Could you please help me =] Thanks a lot
Your function looks fine to me, therefore I assume that your Matlab "Current Directory" is not the same directory where your function lives.
Another reason might be that the file in which this function exists does not have the same as this function. In order for Matlab to know that this function exists, it has to live in a separate file called stat.m (note how file name is the same as the function name).