0
$\begingroup$

I apologize if this has been addressed before, but I did not find a solution for this issue.

I am currently trying to solve a problem with four dependent variables and four independent variables, all non-categorial. They seem to have non-linear dependence and multicolinearity - standard multivariate regression yielded reasonable results, but I am trying to compare them with results from Random Forest and Neural Networks.

According to this link, it should be possible to get multi-output with the MLPRegressor. However, when I try to apply the .fit method, I get an error message:

fit() missing 1 required positional argument: 'y'

Here is the code that I am using:

# Data Preprocessing - Importing the Libraries
import pandas as pd

# Importing the dataset
dataset = pd.read_csv('Rock_Properties_4T.csv')

y = dataset.iloc[:, 4:8].values
X = dataset.iloc[:, 0:4].values

# ANN
from sklearn.neural_network import MLPRegressor
regressor_ANN = MLPRegressor(tol = 1e-16)
MLPRegressor.fit(X, y)

There you go... Any idea of what could be the problem?

$\endgroup$
0

2 Answers 2

1
$\begingroup$

Not sure if this makes a difference, but I think you need to call fit from the initialized object. So for example, your fit line should be:

regressor_ANN.fit(X,y) instead of MLPRegressor.fit(X, y)

then predicting a new set will be:

regressor_ANN.predict(X_test)
$\endgroup$
0
$\begingroup$

I've never encountered that but am guessing from how the documentation is phrased later on with a single target (not targets), you might need to specifically use the multioutput regressor in sklearn like here:

http://scikit-learn.org/stable/auto_examples/ensemble/plot_random_forest_regression_multioutput.html#sphx-glr-auto-examples-ensemble-plot-random-forest-regression-multioutput-py

$\endgroup$
3
  • $\begingroup$ Hi Calz, thanks for the answer. Just tried the MultiOutputRegressor and got the same error =/. $\endgroup$
    – Alfamaster
    Commented Jun 30, 2017 at 14:28
  • $\begingroup$ Please post a small, reproducible example using a public dataset. $\endgroup$
    – CalZ
    Commented Jun 30, 2017 at 16:19
  • $\begingroup$ I used X = np.random.rand(10,4) and Y = np.random.rand(10,4), since they have the same structure as my dataset. Got the same error message. $\endgroup$
    – Alfamaster
    Commented Jul 3, 2017 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.