Sklearn error : predict(x,y) takes 2 positional arguments but 3 were given

Use reg.predict(x). You don't need to provide the y values to predict. In fact, the purpose of training the machine learning model is to let it infer the values of y given the input parameters in x.

Also, the documentation of predict here explains that predict expects only x as a parameter.

The reason why you get the error:

predict() takes 2 positional arguments but 3 were given

is because, when you call reg.predic(x), python will implicitly translate this to reg.predict(self,x), that's why the error is telling you that predict() takes 2 positional arguments. The way you call predict, reg.predict(x,y), will be translated to reg.predict(self,x,y) thus 3 positional arguments will be used instead of 2 and that explains the whole error message.