{"id":16215,"date":"2021-09-21T17:41:21","date_gmt":"2021-09-21T12:11:21","guid":{"rendered":"http:\/\/ismiletechnologies.com\/?p=16215"},"modified":"2022-11-16T18:24:40","modified_gmt":"2022-11-16T12:54:40","slug":"anomaly-detection-ad-in-stock-prices-with-lstm-auto-encoders","status":"publish","type":"post","link":"https:\/\/ismiletechnologies.com\/en_us\/technology\/anomaly-detection-ad-in-stock-prices-with-lstm-auto-encoders\/","title":{"rendered":"Anomaly Detection: (AD) in Stock Prices with LSTM Auto-Encoders"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">This blog will use the S&amp;P 500 stock Dataset to Detect Anomalies training deep learning neural networks using Python, Keras, and Tensorflow.\u202f&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The identification of rare items, events, or remarks which raise suspicion by significant differences from the bulk of the info in different areas such as statistics, signal processing, finance, economics, manufacturing, networking, and <a href=\"http:\/\/ismiletechnologies.com\/data-and-analytics\/\"><span class=\"has-inline-color has-vivid-cyan-blue-color\">data processing<\/span><\/a>, and anomaly detection (including outlier detection) is a different subject. To tackle this problem, we can use deep learning to solve it. Over the years, researchers have come up with various models for analysing and detecting such anomalies in sequential data.\u202f\u202f&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Now we can train our model on the sequential data to detect anomalies or outliers in our data which will help us for more statistical analysis. And use Keras Library, which is built over Tensorflow, for building our model:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"606\" height=\"310\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-58.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16236\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-58.png 606w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-58-300x153.png 300w\" sizes=\"(max-width: 606px) 100vw, 606px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Now we can use a neural model called<\/strong>&nbsp;<strong>LSTM Auto-Encoder<\/strong>:&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">LSTM Auto-Encoder&nbsp;Code:&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"415\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-66-1024x415.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16245\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-66-1024x415.png 1024w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-66-300x122.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-66-768x311.png 768w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-66.png 1307w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Import Libraries:&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"970\" height=\"322\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-61.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16239\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-61.png 970w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-61-300x100.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-61-768x255.png 768w\" sizes=\"(max-width: 970px) 100vw, 970px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>&nbsp;Load and Inspect the S&amp;P 500 Index Data:&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"619\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-1024x619.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16240\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-1024x619.png 1024w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-300x181.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-768x464.png 768w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62.png 1062w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Data Pre-processing:&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"903\" height=\"218\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-60.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16238\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-60.png 903w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-60-300x72.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-60-768x185.png 768w\" sizes=\"(max-width: 903px) 100vw, 903px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>Create Training and Test Splits:&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"263\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-59-1024x263.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16237\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-59-1024x263.png 1024w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-59-300x77.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-59-768x197.png 768w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-59.png 1084w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Build an LSTM Auto-Encoder:&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"619\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-1024x619.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16241\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-1024x619.png 1024w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-300x181.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62-768x464.png 768w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-62.png 1062w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li>Train the Auto-Encoder&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"518\" height=\"270\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-67.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16246\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-67.png 518w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-67-300x156.png 300w\" sizes=\"(max-width: 518px) 100vw, 518px\" \/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\">\n<li>Plot Metrics and Evaluate the Model:&nbsp;<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"929\" height=\"721\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-65.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16244\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-65.png 929w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-65-300x233.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-65-768x596.png 768w\" sizes=\"(max-width: 929px) 100vw, 929px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><img decoding=\"async\" src=\"blob:http:\/\/ismiletechnologies.com\/d858a8e1-a5e0-4d19-b7a2-7f5553b1ee91\">&nbsp;8. Detect Anomalies in the S&amp;P 500 Index Data:&nbsp;&nbsp;<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"560\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-64-1024x560.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16243\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-64-1024x560.png 1024w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-64-300x164.png 300w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-64-768x420.png 768w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-64.png 1083w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"570\" height=\"246\" src=\"http:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-63.png\" alt=\"Anomaly Detection in Stock Prices with LSTM Auto-Encoders\" class=\"wp-image-16242\" srcset=\"https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-63.png 570w, https:\/\/ismiletechnologies.com\/wp-content\/uploads\/2021\/09\/image-63-300x129.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Therefore, we see that we can use LSTM Encoder-Decoder for Detecting Anomalies in Any Stock price.\u202f&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br><strong>Conclusion\u202f&nbsp;<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Stock market prices are unpredictable to detect, but the numbers get used to finding commonality through statistics. Anomaly detection is the fundamental way of using statistics with the help of technical languages such as python, Keras, and Tensorflow.\u202f&nbsp;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To get the first free consultation for discussing more on how Anomaly detection&nbsp;helps in stock&nbsp;prices,&nbsp;<a href=\"http:\/\/ismiletechnologies.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span class=\"has-inline-color has-vivid-cyan-blue-color\">click here<\/span><\/a>.&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This blog will use the S&amp;P 500 stock Dataset to Detect Anomalies training deep learning neural networks using Python, Keras, and Tensorflow.\u202f&nbsp; The identification of rare items, events, or remarks which raise suspicion by significant differences from the bulk of the info in different areas such as statistics, signal processing, finance, economics, manufacturing, networking, and [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":16391,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[],"class_list":["post-16215","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/16215","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/comments?post=16215"}],"version-history":[{"count":4,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/16215\/revisions"}],"predecessor-version":[{"id":35506,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/posts\/16215\/revisions\/35506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/media\/16391"}],"wp:attachment":[{"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/media?parent=16215"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/categories?post=16215"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ismiletechnologies.com\/en_us\/wp-json\/wp\/v2\/tags?post=16215"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}