-1

Plot visualization in R

model %>%
   fit (x = x_train,
        y = y_train,
        epochs = 25,
        batch_size = 32,
        validation_split =.2
        )

The code above is the one I used to obtain the graphs when the fit argument is ran, however, every time the code is ran the graphs are different. I understand this is how you visualize how the model is training or learning. Loss is displayed in the top chart and the accuracy in the second one, for this last one I keep changing the epochs, batch size and validation and it's always 0. I do not fully understand these plots and what the numbers on the y-axis mean.

2 Answers2

0

There is a great explanation on what exactly the "loss" and "accuracy" refers to in a Machine Learning model right here. The term "mape" refers to "Mean Absolute Percentage Error" which is a different way to measure the performance of your model - the lower it is, the better your model performs.

Looking at the plots attached, it's easy to tell that there's a problem with your model since the accuracy of your model is increasing neither on the training nor on the validation set, and the loss is not decreasing either. This might for example be due to a problem with the model you're using (not suited for the task you expect it to perform) or the data that you feed into the model (which might e.g. be labeled in an inconsistent way).

benebrue
  • 25
  • 6
0

Although your data preprocessing steps for deep learning, or the procedure for the construction of your model might not be correct (i.e., numbers of the y-axis of 1st chart, results on the 2nd chart), I will focus this answer on why "every time the code is running the graphs are different", and on "the numbers on the y-axis".

Numbers on the y-axis: in the 2nd chart, accuracy is in range of 0 to 1, while the 3rd takes values from 0 to 100 to express the error percentage.

Why graphs get different after iteration of model execution:

Getting different results is not a bug, rather a feature in machine learning [1] because it includes stochastic (non-deterministic) processes [2], by the explanation that algorithms make use of randomness or probabilistic decisions.

This variance in results might be due to differences in training data, because of stochastic learning algorithms or evaluation procedures, or because of differences in platform (running the model from different machine). In other words, randomness might be found on data collection, observation order, algorithm, sampling, or resampling [3]. For example, during training a deep neaural network, the algorithm might use randomness because of random initial weights (coefficients), or random shuffle of samples in each epoch.

Can you fix that?

Yes. You can control the randomness by assigning a fixed value to "random state" or "random seed" [4, 5, 6, 7, 8]. "random_state" variable

controls the shuffling applied to the data before applying the split [9].

I'm not familiar with R, hence the above documentation in scikit-learn with Python, but I suppose you can do something similar with the "seed.number" based on R documentation [10], i.e. by adding seed.number="some value" next to validation_split during model fitting.

I advise you on having a look at the articles of the references which I hope you find helpful.

dimi_fn
  • 164
  • 1
  • 9