*Deep Learning for Subtyping and Prediction of Diseases: Long-Short Term Memory DOI: http://dx.doi.org/10.5772/intechopen.96180*

is the cancer type and non-cancer causes of death identified from the survey. https://seer.cancer.gov/data/. The steps for example 2 are summarized in **Table 2** (MATLAB 2020b) and because of space limitation, only the cloud of cancer from


*Example* **2**: Data from example 2 is from SEER 2017 for different age groups. SEER collects cancer incidence data from population-based cancer registries of the U.S. population. The SEER registries collect data on patient demographics, primary tumor site, tumor morphology, stage at diagnosis, and the first course of treatment, and they follow up with patients for vital status. The example given in this chapter

*.*

**Example 1. MATLAB Codes and descriptions of the codes**

numTimeStepsTrain = floor(0.95\*numel(Tpositive)); dataTrain = Tpositive(1:numTimeStepsTrain+1); dataTest = Tpositive(numTimeStepsTrain+1:end);

layers = [...sequenceInputLayer(numFeatures)

numHiddenUnits = 300;

*Deep Learning Applications*

regressionLayer];

'MaxEpochs',1000, ... 'GradientThreshold',1, ... 'InitialLearnRate',0.005, ... 'LearnRateSchedule','piecewise', ... 'LearnRateDropPeriod',125, ... 'LearnRateDropFactor',0.2, ...

'Verbose',0, ...

(end));

net = resetState(net);

YPred = [];

end

**Table 1.**

*\**

**74**

**g. Predict on each time step**

numTimeStepsTest = numel(XTest); for i = 1:numTimeStepsTest

(:,i),'ExecutionEnvironment','cpu');

'Plots','training-progress');

**e. Initialize -training and loop over** net = predictAndUpdateState(net,XTrain); [net,YPred] = predictAndUpdateState(net,YTrain

numTimeStepsTest = numel(XTest); for i = 2:numTimeStepsTest

net = predictAndUpdateState(net,XTrain);

[net,YPred(:,i)] = predictAndUpdateState(net,YPred (:,i-1),'ExecutionEnvironment','cpu'); end;

[net,YPred(:,i)] = predictAndUpdateState(net,XTest

*MATLAB codes and specification of cods for Example 1\**

lstmLayer(numHiddenUnits) fullyConnectedLayer(numResponses)

options = *trainingOptions('adam',* ...

**a. Data prepretion Descriptions**

**b. Define LSTM Descriptions**

**c. Specify the training options Descriptions**

**d. Train the LSTM network Descriptions**

**f. Update Network State with observed values Descriptions**

*All descriptions are based on MATLAB 2020b and related examples from the MATLAB.*

Partition the training and test data. Train on the first 95% of the sequence and test on the

Define LSTM Network Architecture and create an LSTM regression network. Specify the LSTM layer to have 300 hidden units

Training with Adam (adaptive moment

the gradient threshold to 1.

To prevent the gradients from exploding, set

The software updates the learning rate every certain number of epochs by multiplying with

Number of epochs for dropping the learning

Factor for dropping the learning rate when

The training and update data Next, make the first prediction using the last time step of the training response YTrain(end). Loop over the remaining predictions and input the previous prediction to predictAndUpdateState.

Update Network State with Observed Values

Predict on each time step. For each prediction, predict the next time step using the observed

value of the previous time step.

'LearnRateSchedule','piecewise'

last 5%

estimation)

a certain factor.

training options

rate

net = trainNetwork(XTrain,YTrain,layers,options); Train the LSTM network with the specified


age groups is illustrated in **Figure 12**. Here, in order to input the documents into an LSTM network, the "*wordEncoding(documentsTrain)"* is used. This code converts the name of diseases into sequences of numeric indices. The disease names (all types of text structure) in LSTM with MATLAB are performed in three consecutive steps: 1) tokenize the text 2) convert the text to lowercase and, 3) erase the punctuation. The function stops predicting when the network predicts the end-of-text character

*Deep Learning for Subtyping and Prediction of Diseases: Long-Short Term Memory*

LSTM is a very powerful ANN architecture for disease subtypes, time series analyses, for the text generation, handwriting recognition, music generation, language translation, image captioning process. The LSTM approach is effective to make predictions as equal attention is provided for all input sequences by the information flows through the cell state. Because of the mechanism adopted, the small change in the input sequence does not harm the prediction accuracy done by LSTM. Future work on LSTM has several directions. Most LSTM architectures are designed to handle data evenly distributed between elapsed times (days, months, years, etc.) for the consecutive elements of a sequence. More studies are needed to improve the predictive ability of LSTM for nonconstant consecutive observations elapsed times. Moreover, further studies are needed for possible overfitting problems for training with smaller data sets. Rather than using early stopping to avoid the overfitting, Bayesian regularized approach would be more effective to ensure that the neural network halts training at the point where further training would result in overfitting. As the Bayesian regularized approach uses a different loss function with different hyperparameters, this approach demands costly computa-

The author would like to sincerely thank to Rosey Zackula for reading and

© 2021 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution License (http://creativecommons.org/licenses/ by/3.0), which permits unrestricted use, distribution, and reproduction in any medium,

The University of Kansas School of Medicine, Wichita, USA

\*Address all correspondence to: hokut@kumc.edu

provided the original work is properly cited.

or when the generated text is 500 characters long.

**5. Conclusions and future work**

*DOI: http://dx.doi.org/10.5772/intechopen.96180*

tion resources.

**Author details**

Hayrettin Okut

**77**

**Acknowledgements**

revising the manuscript carefully.

#### **Table 2.**

*MATLAB codes and specification of cods for Example 2\*.*

#### **Figure 12.**

*Visualizing the training data text file for SEER-2017 cancer types by age groups using a word cloud of LSTM. The MATLAB codes to create this figure are given in Table 2. The bigger the word, the more often diagnosed cancer type in 2017.*

*Deep Learning for Subtyping and Prediction of Diseases: Long-Short Term Memory DOI: http://dx.doi.org/10.5772/intechopen.96180*

age groups is illustrated in **Figure 12**. Here, in order to input the documents into an LSTM network, the "*wordEncoding(documentsTrain)"* is used. This code converts the name of diseases into sequences of numeric indices. The disease names (all types of text structure) in LSTM with MATLAB are performed in three consecutive steps: 1) tokenize the text 2) convert the text to lowercase and, 3) erase the punctuation. The function stops predicting when the network predicts the end-of-text character or when the generated text is 500 characters long.
