I have dataset of 15 features and the goal is to estimate a best fitting curve (regression). Now I want to use a deep learning technique for this purpose. Now I see that there are many architectures that can be used such as CNN, DBM or auto-encoder, etc.. Which one to go for. And I could not find any examples for how to use the same. A sample code would be of great help. Thanks

P.S. Some of the features are categorical. How do we handle that as well?

  • 2
    $\begingroup$ why do you want to use deep learning? practice? or are there real reasons for deep networks would be preferable to simpler methods? $\endgroup$
    – metjush
    Jan 7, 2016 at 13:47
  • $\begingroup$ Yes. I have tried using using simpler models such as linear regression (GLM)) and also with more advanced ensemble based methods such as random forests (RF). Just wanted to try deep learning to check if it gives improved performance. The RMSE obtained for GLM and RF was 13 and 10 respectively for my problem. Just wanted to see how it improves using deep learning. The problem is new and there are no definite set of features and I am also looking for using more engineered features which deep learning automatically does i guess. $\endgroup$
    – prashanth
    Jan 7, 2016 at 13:55
  • $\begingroup$ fair enough! I was just wandering, because your question didn't sufficiently clarify how much work you've already done on the problem. $\endgroup$
    – metjush
    Jan 7, 2016 at 14:46
  • $\begingroup$ as far as categorical variables go - just encode them as binary variables and leave one out as the baseline. $\endgroup$
    – metjush
    Jan 7, 2016 at 14:46
  • 1
    $\begingroup$ Unless you have millions of data points deep-learning is probably no beneficial. Anyway I found a quick link about deep-learning and regression here: deeplearning4j.org/linear-regression.html $\endgroup$
    – usεr11852
    Jan 7, 2016 at 18:46

1 Answer 1


For standard regression I recommend using Multi-Layer Perceptron (MLP) with Mean Square Error (MSE) loss function. The model can be defined in Keras as follows:

model = Sequential()
model.add(Dense(20, input_dim=13, init='normal', activation='relu'))
model.add(Dense(10, init='normal', activation='relu'))
model.add(Dense(1, init='normal'))

model.compile(loss='mean_squared_error', optimizer='adam')

See this article for a complete example. For a TensorFlow implementation, consider the following code.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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