{"id":674,"date":"2018-11-27T16:32:46","date_gmt":"2018-11-27T15:32:46","guid":{"rendered":"https:\/\/www.pschatzmann.ch\/home\/?p=674"},"modified":"2020-11-21T22:22:50","modified_gmt":"2020-11-21T21:22:50","slug":"predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier","status":"publish","type":"post","link":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/","title":{"rendered":"Predicting the Direction of Stock Market Prices using a Random Forest Classifier"},"content":{"rendered":"<p>In this demo I will show how to predict if the closing price of Apple, General Electric and Samsung Electronics is moving up or down. We do this with the help of a Random Forest Classifier.<\/p>\n<p>I tried to replicate the result from a <a href=\"https:\/\/www.researchgate.net\/publication\/301818771_Predicting_the_direction_of_stock_market_prices_using_random_forest\">research paper\u00a0<\/a>authored by Luckyson Khaidem, Snehanshu Saha, Sudeepa Roy Dey which is describing the following concept:<\/p>\n<ul>\n<li>Data Preprocessing\n<ul>\n<li>exponentially smoothing<\/li>\n<\/ul>\n<\/li>\n<li>Features\n<ul>\n<li>Relative Strength Index<\/li>\n<li>Stochastic Oscillator<\/li>\n<li>Williams %R<\/li>\n<li>Moving Average Convergence Divergence<\/li>\n<li>Price Rate of Change<\/li>\n<li>On Balance Volume<\/li>\n<\/ul>\n<\/li>\n<li>Labels\n<ul>\n<li>Sign(closei+d \u2212 closei)<\/li>\n<\/ul>\n<\/li>\n<li>Ticker Symbols\n<ul>\n<li>Apple (NASDAQ:AAPL)<\/li>\n<li>General Electric (NASDAQ:GE)<\/li>\n<li>Samsung Electronics Co. Ltd (SSNLF)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>The solution has been implemented in Scala using Jupyter with the <a href=\"http:\/\/beakerx.com\/\">BeakerX kernel<\/a> using the following libraries<\/p>\n<ul>\n<li><a href=\"https:\/\/www.pschatzmann.ch\/home\/category\/quantitative-trading\/\">Investor<\/a><\/li>\n<li><a href=\"https:\/\/spark.apache.org\">Spark<\/a> &amp; <a href=\"https:\/\/spark.apache.org\/mllib\/\">MLLib<\/a><\/li>\n<\/ul>\n<p>The document can be found in the following <a href=\"https:\/\/nbviewer.jupyter.org\/gist\/pschatzmann\/99ac633024fbeb3550545df834d2e760\">Gist<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this demo I will show how to predict if the closing price of Apple, General Electric and Samsung Electronics is moving up or down. We do this with the help of a Random Forest Classifier. I tried to replicate the result from a research paper\u00a0authored by Luckyson Khaidem, Snehanshu [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":678,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[14,13],"tags":[],"class_list":["post-674","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","category-quantitative-trading"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.6 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Predicting the Direction of Stock Market Prices using a Random Forest Classifier - Phil Schatzmann<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Predicting the Direction of Stock Market Prices using a Random Forest Classifier - Phil Schatzmann\" \/>\n<meta property=\"og:description\" content=\"In this demo I will show how to predict if the closing price of Apple, General Electric and Samsung Electronics is moving up or down. We do this with the help of a Random Forest Classifier. I tried to replicate the result from a research paper\u00a0authored by Luckyson Khaidem, Snehanshu [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/\" \/>\n<meta property=\"og:site_name\" content=\"Phil Schatzmann\" \/>\n<meta property=\"article:published_time\" content=\"2018-11-27T15:32:46+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-11-21T21:22:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2018\/11\/randomForrestStocks.png\" \/>\n\t<meta property=\"og:image:width\" content=\"650\" \/>\n\t<meta property=\"og:image:height\" content=\"492\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"pschatzmann\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"pschatzmann\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/\"},\"author\":{\"name\":\"pschatzmann\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"headline\":\"Predicting the Direction of Stock Market Prices using a Random Forest Classifier\",\"datePublished\":\"2018-11-27T15:32:46+00:00\",\"dateModified\":\"2020-11-21T21:22:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/\"},\"wordCount\":145,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/randomForrestStocks.png\",\"articleSection\":[\"Machine Learning\",\"Quantitative Trading\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/\",\"name\":\"Predicting the Direction of Stock Market Prices using a Random Forest Classifier - Phil Schatzmann\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/randomForrestStocks.png\",\"datePublished\":\"2018-11-27T15:32:46+00:00\",\"dateModified\":\"2020-11-21T21:22:50+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/randomForrestStocks.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2018\\\/11\\\/randomForrestStocks.png\",\"width\":650,\"height\":492},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/2018\\\/11\\\/27\\\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Predicting the Direction of Stock Market Prices using a Random Forest Classifier\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#website\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/\",\"name\":\"Phil Schatzmann Consulting\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/home\\\/#\\\/schema\\\/person\\\/73a53638a4e34e8373405fd737dac9b1\",\"name\":\"pschatzmann\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"url\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"contentUrl\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\",\"width\":305,\"height\":305,\"caption\":\"pschatzmann\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.pschatzmann.ch\\\/wp-content\\\/uploads\\\/2022\\\/08\\\/pschatzmann.png\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Predicting the Direction of Stock Market Prices using a Random Forest Classifier - Phil Schatzmann","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/","og_locale":"en_US","og_type":"article","og_title":"Predicting the Direction of Stock Market Prices using a Random Forest Classifier - Phil Schatzmann","og_description":"In this demo I will show how to predict if the closing price of Apple, General Electric and Samsung Electronics is moving up or down. We do this with the help of a Random Forest Classifier. I tried to replicate the result from a research paper\u00a0authored by Luckyson Khaidem, Snehanshu [&hellip;]","og_url":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/","og_site_name":"Phil Schatzmann","article_published_time":"2018-11-27T15:32:46+00:00","article_modified_time":"2020-11-21T21:22:50+00:00","og_image":[{"width":650,"height":492,"url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2018\/11\/randomForrestStocks.png","type":"image\/png"}],"author":"pschatzmann","twitter_card":"summary_large_image","twitter_misc":{"Written by":"pschatzmann","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#article","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/"},"author":{"name":"pschatzmann","@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"headline":"Predicting the Direction of Stock Market Prices using a Random Forest Classifier","datePublished":"2018-11-27T15:32:46+00:00","dateModified":"2020-11-21T21:22:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/"},"wordCount":145,"commentCount":0,"publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2018\/11\/randomForrestStocks.png","articleSection":["Machine Learning","Quantitative Trading"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/","url":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/","name":"Predicting the Direction of Stock Market Prices using a Random Forest Classifier - Phil Schatzmann","isPartOf":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#primaryimage"},"image":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2018\/11\/randomForrestStocks.png","datePublished":"2018-11-27T15:32:46+00:00","dateModified":"2020-11-21T21:22:50+00:00","breadcrumb":{"@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#primaryimage","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2018\/11\/randomForrestStocks.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2018\/11\/randomForrestStocks.png","width":650,"height":492},{"@type":"BreadcrumbList","@id":"https:\/\/www.pschatzmann.ch\/home\/2018\/11\/27\/predicting-the-direction-of-stock-market-prices-using-a-random-forest-classifier\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pschatzmann.ch\/home\/"},{"@type":"ListItem","position":2,"name":"Predicting the Direction of Stock Market Prices using a Random Forest Classifier"}]},{"@type":"WebSite","@id":"https:\/\/www.pschatzmann.ch\/home\/#website","url":"https:\/\/www.pschatzmann.ch\/home\/","name":"Phil Schatzmann Consulting","description":"","publisher":{"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pschatzmann.ch\/home\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.pschatzmann.ch\/home\/#\/schema\/person\/73a53638a4e34e8373405fd737dac9b1","name":"pschatzmann","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","url":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","contentUrl":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png","width":305,"height":305,"caption":"pschatzmann"},"logo":{"@id":"https:\/\/www.pschatzmann.ch\/wp-content\/uploads\/2022\/08\/pschatzmann.png"}}]}},"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/674","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/comments?post=674"}],"version-history":[{"count":1,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/674\/revisions"}],"predecessor-version":[{"id":2207,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/posts\/674\/revisions\/2207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media\/678"}],"wp:attachment":[{"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/media?parent=674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/categories?post=674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pschatzmann.ch\/home\/wp-json\/wp\/v2\/tags?post=674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}