title: Using ANN for Multiple Regression in Python (Keras)
body: <p>I wish to use the Keras package in Python to perform a prediction task. For each observation, I have measurements of 4 (continuous) independent variables (my X) and 1 (continuous) dependent variable (my y). y is generally a value between -10 and +10 though there are measurements of y in the data outside this range. When I ran the code below (and some later code to generate the predictions on the test set), the ANN was predicting the same output irrespective of what x-values it was supplied (when of course really I want the model to give different predictions when supplied a set of dependent variables with different values). The dataset in question concerns rounds of golf and I have circa. 450,000 observations (x-y pairs). I am trying to predict how well players will play in their next round.</p>
  
  <p>Clearly I don't <em>need</em> to be using an ANN for this but I wanted to explore what it was capable of.</p>
  
  <p>Here is my code:</p>
  
  <pre><code># Importing the Keras libraries and packages
  import keras
  from keras.models import Sequential
  from keras.layers import Dense
  
  X = dataset.iloc[:, 3:7].values
  y = dataset.iloc[:, 13].values
  
  # Splitting the dataset into the Training set and Test set
  from sklearn.model_selection import train_test_split
  X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.2, random_state = 0)
  
  # Feature Scaling
  from sklearn.preprocessing import StandardScaler
  sc = StandardScaler()
  X_train = sc.fit_transform(X_train)
  X_test = sc.transform(X_test)
  
  # Initialising the ANN
  classifier = Sequential()
  
  # Adding the input layer and the first hidden layer
  classifier.add(Dense(units = 6, kernel_initializer = 'uniform', activation = 'relu', input_dim = 4))
  
  # Adding the second hidden layer
  classifier.add(Dense(units = 3, kernel_initializer = 'uniform', activation = 'relu'))
  
  # Adding the output layer
  classifier.add(Dense(units = 1, kernel_initializer = 'uniform'))
  
  # Compiling the ANN
  classifier.compile(optimizer = 'adam', loss = 'mse', metrics = ['ame'])
  
  # Fitting the ANN to the Training set
  classifier.fit(X_train, y_train, batch_size = 10, epochs = 5)
  </code></pre>