Beginning Anomaly Detection Using



Download 26,57 Mb.
Pdf ko'rish
bet97/283
Sana12.07.2021
Hajmi26,57 Mb.
#116397
1   ...   93   94   95   96   97   98   99   100   ...   283
Bog'liq
Beginning Anomaly Detection Using Python-Based Deep Learning

Figure 4-6.  Examining the Pandas dataframe

Figure 4-7.  Sampling the dataframe and choosing the majority of normal data

You split the dataframe into training and testing data sets (80-20 split). Figure 

4-8

 

shows the code to split the data into the train and test subsets.



Figure 4-8.  Spliting the data into test and train sets, using 20% as holdout  

test data

Chapter 4   autoenCoders




131

Now it’s time to create a simple neural network model with just an encoder and 

decoder layer. You will encode the 29 columns of the input credit card dataset into 

12 features using the encoder. The decoder expands the 12 back into the 29 features. 

Figure 

4-9


 shows the code to create the neural network.

Figure 4-9.  Creating the simple autoencoder neural network

If you look at the code in Figure 

4-9

, you will see two different activation functions, 



namely relu and softmax. So what are they?

RELU, the Rectified Linear Unit, is the most commonly used activation function in 

deep learning models. The function returns 0 if it receives any negative input, but for any 

positive value xx it returns that value back. So it can be written as

f(x)=max(0,x).



Softmax, the Softmax function, outputs a vector that represents the probability 

distributions of a list of potential outcomes. The probabilities always add up to 1.

Needless to say, there are several activation functions available and you can refer to 

the Keras documentation to look at the options at 

https://keras.io/activations/

.

Now, compile the model using RMSprop as the optimizer and mean squared error 



for the loss computation. The RMSprop optimizer is similar to the gradient descent 

algorithm with momentum. A metric function is similar to a loss function, except that 

the results from evaluating a metric are not used when training the model. You may use 

Chapter 4   autoenCoders




132

any of the loss functions as a metric function, as listed in 

https://keras.io/losses/

Figure 



4-10

 shows the code to compile the model using mean absolute error and 

accuracy as metrics.

Now you can start training the model using the training dataset to validate the model 

at every step. Choose 32 as the batchsize and 20 epochs. Figure 

4-11


 shows the code to 

train the model, which is the most time consuming part of the process.




Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   93   94   95   96   97   98   99   100   ...   283




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish