Deep Regressor not improving over epochs

Aditya_Shukla: <p>I am trying to writing a regressor which uses a series of dense layers to predict a value.<br>
The code is as follows:</p>
<p><strong>The Network</strong></p>
<pre><code class="lang-auto">class deep_regressor(nn.Module):
  def __init__(self):
    super(deep_regressor,self).__init__()
    self.linear_1 = nn.Linear(
                      in_features = 8,
                      out_features = 16
                    )
    self.linear_2 = nn.Linear(
                      in_features = 16,
                      out_features = 32
                    )
    self.output = nn.Linear(
                      in_features = 32,
                      out_features = 1
                    )
    
  def forward(self, input_tensor):
    tensor = self.linear_1(input_tensor)
    tensor = f.relu(tensor)

    tensor = self.linear_2(tensor)
    tensor = f.relu(tensor)

    tensor = self.output(tensor)
    return tensor
</code></pre>
<p><strong>The Script:</strong></p>
<pre><code class="lang-auto">neurons = deep_regressor()
optimizer = torch.optim.Adam(neurons.parameters(),lr = 0.01)
loss_function = nn.MSELoss()
for epoch in range(10):
    number = 0
    total_loss = 0 
    accuracy = 0
    for data_rows,labels in train_loader:
        predictions = neurons(data_rows)
        calc_loss = loss_function(predictions,labels)

        optimizer.zero_grad() #resets the gradients

        calc_loss.backward()
        optimizer.step()

    print(
        "Epochs =\t" + str(epoch + 1)
    )
    preds = neurons(torch.as_tensor(df, dtype = torch.float32))
    preds = preds.detach().numpy()
    rmse = math.sqrt(mean_squared_error(preds,target))
    print(rmse)
</code></pre>
<p><em>The output per epoch is as follows:</em></p>
<pre><code class="lang-auto">Epochs =	1
78.64161989373262
Epochs =	2
78.3528279726827
Epochs =	3
78.3800896760905
Epochs =	4
78.35181985605024
Epochs =	5
78.24301382034795
Epochs =	6
78.52033108135714
Epochs =	7
78.39965093292
Epochs =	8
78.2766145950348
Epochs =	9
78.39979733373761
Epochs =	10
78.39885957650147
</code></pre>
<p><strong>Why is this happening? How do I fix it?</strong></p>

Henry_Chibueze: <p>Lemme explain sth to u<br>
U see Neural networks are good and all but sometimes they don’t just fit better than other Machine learning models when it comes to certain things.<br>
Neural networks are only known to outperform other models when it comes to image and text data u know y? Coz they are very good at feature extraction and pattern recognition.</p>
<p>Now u r performing regression task which probably means ur data is structured, in this case there are models that work better than any when it comes to structured data these models are called Gradient Boosters (eg: Gboost, XGboost, Random forest, etc)<br>
How do they work?<br>
Well they are an esemble of weak learner algorithms called the decision tree that come together to form a strong learning unit. This ensemble can be used to perform regression and classification tasks on structured data and can even give much better accuracies than other ML algorithms if u know what u are doing.</p>
<p>Text or Image data -&gt; Neural networks.<br>
Structured data -&gt; Gradient Boosters.</p>

Henry_Chibueze: <p>Although in ur neural network 3 layers might be over kill for a ordinary regression task.<br>
Then again if u data have really deep underlying patterns that even u cannot figure out, then u can use more layers for it (just don’t forget to put a dropout layer so the network doesn’t overfit on training data and reach only local minimum instead of global minimum)<br>
Also u can add non-linear transformation between ur hidden layer and output layer (<code>nn.ReLU()</code>).</p>
<p>Hope these answers help.</p>

Aditya_Shukla: <p>I have already tried bagging and boosting. By your logic time series forecasting (which also happens to be a form of regression should not be done using neural network.</p>
<p>Here is an example related to standard regression: <a href="https://ieeexplore.ieee.org/document/5596936" rel="noopener nofollow ugc">https://ieeexplore.ieee.org/document/5596936</a></p>
<p>I think they know what they are doing!!</p>

Henry_Chibueze: <p>Actually there’s a special kinda Neural network algorithm for time series data there the Recurrent Neural Networks specifically the LSTM(long short term memory) and GRU(Gate Recurrent Unit)</p>
<p>The reason these are more preferable for time series data is coz RNNs are known for recognizing sequencial patterns and predicting the next sequence coz there store data of previous instances in the sequence that serve as the dependency for the next prediction.<img src="https://discuss.pytorch.org/images/emoji/apple/kissing.png?v=9" title=":kissing:" class="emoji" alt=":kissing:"></p>

Henry_Chibueze: <p>I’m not by any means trying to say that Neural networks can’t and shouldn’t be used for regression analysis.<br>
What I’m saying is that the gradient booster ensemble works better on structured data and I’ve actually experienced it myself alot of times.</p>

Aditya_Shukla: <p>I absolutely agree with you. The problem is, in this case they are not able to identify the the pattern (Perhaps I should have mentioned this). Hence the overkill dense layers.</p>
<p>As for RNNs, I know about them, I am using them with CTC loss and decoder. I too dislike using overkill solution and go about flag questions on StackOverflow; but in this case I think they might be the solution.</p>

Henry_Chibueze: <p>I see<br>
So what’s the context of ur data lemme see if I could come up with any suggestions</p>