-1

I want to know is there any way to train the neural network in python with unequal length of Input and Target data.

Sample Files:

Here is input data file

Here is output data file

Thanks in advance

Uzair
  • 231
  • 4
  • 18
  • You should print some samples from both your files. Also, since you have split your input data into train and test, why dont you pass `X_train, y_train` into the `fit()` function. Or if you want to use all data, just use `transformed_input_data`. Why do you pass `transformed_input_data.values()`? Are you following any tutorial for it? – Vivek Kumar Apr 24 '17 at 01:34
  • Because i am getting error when passing X_train, y_train in fit function... – Uzair Apr 24 '17 at 07:16
  • What error are you getting? – Vivek Kumar Apr 24 '17 at 07:21
  • it was Unknown label type sklearn – Uzair Apr 24 '17 at 07:22
  • What do you want to do actually, classify the new data according to given targets, or predict the value of y from data? Because if latter, then you have to use Regressor, not Classifier. Can you show samples of your y_train? – Vivek Kumar Apr 24 '17 at 07:25
  • The links to your input and output files are switched. – andrew_reece Apr 24 '17 at 07:29
  • Basically, i want to train this data and show the output of train and error which we get, using neural network... and for that i am tried MLP approach – Uzair Apr 24 '17 at 07:30
  • Yeah, "You want to train this data". You have just jumped onto the code, without thinking about the type of problem. You need to understand basics of ML before coding. Seeing your input and output, thats a regression problem. You are using `MLPClassifier` which is for classification, not regression. Use `MLPRegressor` instead. – Vivek Kumar Apr 24 '17 at 07:45
  • You should have mentioned about "Unknown label type" error in the post. And for plotting the graph, do you understand how many types of graph are possible for the output and error. Which type do you want? – Vivek Kumar Apr 24 '17 at 07:50
  • I want to plot the result of it... sir i tried much can u please look at this question (http://stackoverflow.com/questions/43563836/convert-matlab-code-into-python-using-neural-network-library) – Uzair Apr 24 '17 at 07:53

1 Answers1

-1

Re: AttributeError: 'list' object has no attribute 'values':

You've defined transformed_input_data and transformed_output_data both as type list.

transformed_input_data = [[x] for x in input_data]  
transformed_output_data = [[x] for x in output_data]

A list doesn't have a .values property. Try removing .values from the error-causing line. Here's a brief example:

from sklearn.neural_network import MLPClassifier

mlp = MLPClassifier()

input_data = [0,1,2]
output_data = [10,9,8]
transformed_input_data = [[x] for x in input_data]
transformed_output_data = [[x] for x in output_data]

mlp.fit(X=transformed_input_data, y=transformed_output_data)

Output:

MLPClassifier(activation='relu', alpha=0.0001, batch_size='auto', beta_1=0.9,
              beta_2=0.999, early_stopping=False, epsilon=1e-08,
              hidden_layer_sizes=(100,), learning_rate='constant',
              learning_rate_init=0.001, max_iter=200, momentum=0.9,
              nesterovs_momentum=True, power_t=0.5, random_state=None,
              shuffle=True, solver='adam', tol=0.0001, validation_fraction=0.1,
              verbose=False, warm_start=False)

FWIW, .values is available as an attribute of Pandas Series objects, which do share some properties with lists. For Series objects, .values turns them into a Numpy ndarray.

Re: plotting output and error
What kind of plot do you want to make? It will help to be specific and provide some example data. That issue may be most appropriate as a separate question.

andrew_reece
  • 20,390
  • 3
  • 33
  • 58
  • I want to import data from file and that's where i am having trouble...and by plotting i mean i want to diplay graph of after training the data – Uzair Apr 24 '17 at 07:17