Matlab fitnet function ignores some input variables that contain NaN values

1 view (last 30 days)
Matlab fitnet function ignores some input variables that contain NaN values.
My input layer contains some points with NaN values. I am aware that fitnet will not handle NaN values. However, when I get the input weights (IW) from the network with ten predictors, the input weights matrix eliminates two predictors and I don't know which ones.

Answers (1)

MULI
MULI on 20 Jun 2024
Hi Jorge,
I understand that you are experiencing an issue in training the model due to NaN values.
Following steps helps in addressing the issue:
Step 1: Identify NaN-containing predictors
Before feeding your data into the fitnet function, check which predictors contain NaN values using MATLAB functions like “isnan”.
Step 2: Handling NaN Values
Once you have identified the columns with NaNs, you can:
Remove NaNs: If only a few rows contain NaNs, you might choose to remove those rows.
Imputation: Replace NaN values with some form of imputation. Common strategies include using the mean, median, or mode of the column.
Step 3: Re-check Input Weights Matrix
After handling NaN values, retrain your network using fitnet and check the input weights matrix again. Now, it should consider all predictors since none of them contain NaNs.
You may refer this documentation link for more information on “isnan” function
You may also refer this link for more information in handling NaN values in the training data set.
Hope this answers your query!

Categories

Find more on Sequence and Numeric Feature Data Workflows in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!