Beginning Anomaly Detection Using



Download 26,57 Mb.
Pdf ko'rish
bet102/283
Sana12.07.2021
Hajmi26,57 Mb.
#116397
1   ...   98   99   100   101   102   103   104   105   ...   283
Bog'liq
Beginning Anomaly Detection Using Python-Based Deep Learning

 Sparse  Autoencoders

In the above example of a simple autoencoder, the representations were only 

constrained by the size of the hidden layer (12). In such a situation, what typically 

happens is that the hidden layer is learning an approximation of PCA (principal 

component analysis). But another way to constrain the representations to be compact 

is to add a sparsity constraint on the activity of the hidden representations, so fewer 

units would fire at a given time. In Keras, this can be done by adding an activity_

regularizer to your dense layer.

The difference between the simple and sparse autoencoders is mostly due to the 

regularization term being added to the loss during training.

 

You will use the same credit card dataset as in the simple autoencoder example 



above. You will use the credit card data to detect whether a transaction is normal/

expected or abnormal/anomaly. Shown below is the data being loaded into a Pandas 

dataframe.

Figure 4-23.  Anomalies based on the threshold

Chapter 4   autoenCoders




141

Then, you will collect 20k normal and 400 abnormal records. You can pick different 

ratios to try, but in general more normal data examples are better because you want 

to teach your autoencoder what normal data looks like. Too much abnormal data in 

training will train the autoencoder to learn that the anomalies are actually normal, which 

goes against your goal. Split the dataframe into training and testing data sets (80- 20 split).

Now it’s time to create a 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 will expand the 12 back into 29 features. 

The key difference compared to the simple autoencoder is the activity regularizer to 

accommodate the sparse autoencoder. Figure 

4-24


 shows the code to create the neural 

network.


Figure 4-24.  Code to create the neural network

Chapter 4   autoenCoders




142

Figure 


4-25

 shows the graph of the model as visualized by TensorBoard.




Download 26,57 Mb.

Do'stlaringiz bilan baham:
1   ...   98   99   100   101   102   103   104   105   ...   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