{"id":203928,"date":"2024-04-01T12:06:21","date_gmt":"2024-04-01T16:06:21","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=203928"},"modified":"2024-04-02T10:48:14","modified_gmt":"2024-04-02T14:48:14","slug":"machine-learning-logistic-regression-python-trading-and-more-part-ii","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/","title":{"rendered":"Machine Learning Logistic Regression: Python, Trading and More &#8211; Part II"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><em>See <a href=\"\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-i\/\">Part I<\/a> for an intro to linear regression and logistic regression.<\/em><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"example-of-logistic-regression-in-trading\">Example of logistic regression in trading<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on predictor variables (technical indicators). Here&#8217;s an example of how Machine learning logistic regression might be applied in a trading context:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example: Predicting Stock Price Movement<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Suppose a trader wants to predict whether a stock price will increase (1) or decrease (0) based on certain predictor variables or indicators. The trader collects historical data and selects the following predictor variables:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Moving Average Crossover:<\/strong>&nbsp;A binary variable indicating whether there was a recent crossover of the short-term moving average (e.g., 50-day MA) above the long-term moving average (e.g., 200-day MA) (1 = crossover occurred, 0 = no crossover).<\/li>\n\n\n\n<li><strong>Relative Strength Index (RSI)<\/strong>: A continuous variable representing the RSI value, which measures the momentum of the stock (values range from 0 to 100).<\/li>\n\n\n\n<li><strong>Trading Volume<\/strong>: A continuous variable representing the trading volume of the stock, which may indicate the level of interest or activity in the stock.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The trader builds a logistic regression model using historical data, where the outcome variable is the binary indicator of whether the stock price increased (1) or decreased (0) on the next trading day.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After training the logistic regression model, the trader can use it to make predictions on new data. For example, if the model predicts a high probability of a stock price increase (p &gt; 0.7) based on past or current data, the trader may decide to buy the stock.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"types-of-logistic-regression\">Types of logistic regression<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logistic regression is a versatile statistical method that can be adapted to various types of classification problems. Depending on the nature of the outcome variable and the specific requirements of the analysis, different types of logistic regression models can be employed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here are some common types of logistic regression:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"720\" height=\"360\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Types-of-logistic-regression-quantinsti.jpg\" alt=\"\" class=\"wp-image-203930 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Types-of-logistic-regression-quantinsti.jpg 720w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Types-of-logistic-regression-quantinsti-700x350.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Types-of-logistic-regression-quantinsti-300x150.jpg 300w\" data-sizes=\"(max-width: 720px) 100vw, 720px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 720px; aspect-ratio: 720\/360;\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Binary Logistic Regression:<\/strong>&nbsp;This is the most basic form of logistic regression, where the outcome variable is binary and can take on two categorical values, such as &#8220;yes&#8221; or &#8220;no,&#8221; &#8220;success&#8221; or &#8220;failure&#8221;. These values are read as &#8220;1&#8221; or &#8220;0&#8221; by the machine learning model.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Hence, binary logistic regression is used to model the relationship between the predictor variables (an indicator such as RSI, MACD etc.) and the probability of the outcome being in a particular category (\u201cincrease\u201d or \u201cdecrease\u201d in stock price).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Multinomial Logistic Regression:<\/strong>&nbsp;In multinomial logistic regression, the outcome variable is categorical and can have more than two unordered categories. This type of logistic regression is suitable for modelling nominal outcome variables with three or more categories that do not have a natural ordering.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example, classifying stocks into multiple categories such as &#8220;buy,&#8221; &#8220;hold,&#8221; or &#8220;sell&#8221; based on a set of predictor variables such as fundamental metrics, technical indicators, and market conditions.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ordinal Logistic Regression:<\/strong>&nbsp;Ordinal logistic regression is used when the outcome variable is ordinal, meaning that it has a natural ordering but the intervals between the categories are not necessarily equal. Examples of ordinal variables include Likert scale ratings (e.g., &#8220;strongly disagree,&#8221; &#8220;disagree,&#8221; &#8220;neutral,&#8221; &#8220;agree,&#8221; &#8220;strongly agree&#8221;). Ordinal logistic regression models the cumulative probabilities of the outcome variable categories.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example, analysing the ordinal outcome of trader sentiment or confidence levels (e.g., &#8220;low,&#8221; &#8220;medium,&#8221; &#8220;high&#8221;) based on predictor variables such as market volatility, economic indicators, and news sentiment.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Multilevel Logistic Regression (or Hierarchical Logistic Regression):&nbsp;<\/strong>Multilevel logistic regression is used when the data has a hierarchical or nested structure, such as individuals nested within groups or clusters. This type of logistic regression accounts for the dependence or correlation among observations within the same cluster and allows for the estimation of both within-group and between-group effects.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example, Modelling the binary outcome of stock price movements within different industry sectors (e.g., technology, healthcare, finance) while accounting for the hierarchical structure of the data (stocks nested within sectors).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Mixed-effects Logistic Regression:<\/strong>&nbsp;Mixed-effects logistic regression combines fixed effects (predictor variables that are the same for all observations) and random effects (predictor variables that vary across groups or clusters) in the model. This type of logistic regression is useful for analysing data with both individual-level and group-level predictors and accounting for the variability within and between groups.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example, examining the binary outcome of stock price movements based on both individual-level predictors (such as company-specific factors, technical indicators) and group-level predictors (such as industry sector, market index etc.).<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Regularised Logistic Regression:<\/strong>&nbsp;Regularised logistic regression, such as Lasso (L1 regularisation) or Ridge (L2 regularisation) logistic regression, incorporates regularisation techniques to prevent overfitting and improve the generalisability of the model. Regularisation adds a penalty term to the logistic regression model, which shrinks the coefficients of the predictor variables and selects the most important predictors.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For example, building a binary classification model to predict whether a stock is likely to outperform the market based on a large number of predictor variables while preventing overfitting and selecting the most important features.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each type of logistic regression has its assumptions, advantages, and limitations, and the choice of the appropriate model depends on the nature of the data, the type of outcome variable, and the specific research or analytical objectives.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"difference-between-logistic-regression-and-linear-regression\">Difference between logistic regression and linear regression<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now, let us see the difference between logistic regression and linear regression.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Feature\/Aspect<\/strong><\/td><td><strong>Linear Regression<\/strong><\/td><td><strong>Logistic Regression<\/strong><\/td><\/tr><tr><td>Outcome Type<\/td><td>Continuous where the variable can take any value within a given range (e.g., daily stock price)<\/td><td>Binary or Categorical (e.g., Price is \u201cUp\u201d or \u201cDown\u201d)<\/td><\/tr><tr><td>Prediction<\/td><td>Value prediction. For example, stock price<\/td><td>Probability prediction For example, likelihood of an event<\/td><\/tr><tr><td>Relationship Assumption<\/td><td>Linear, that is, the dependent variable (such as predictive outcome) can be found out with the help of independent variables (such as past values). For example, on the basis of historical data, a trader can predict future prices of stock.<\/td><td>Log-Linear. For example, consider a situation where a quantity grows exponentially over time. A log-linear model would describe the relationship between the logarithm of the quantity and time as linear, implying that the quantity grows or decays at a constant rate on a logarithmic scale.<\/td><\/tr><tr><td>Model Output<\/td><td>Change in outcome per unit change in predictor<\/td><td>Change in log odds per unit change in predictor<\/td><\/tr><tr><td>Applications<\/td><td>Predicting in terms of amounts<\/td><td>Classifying in categories<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In essence:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Linear Regression predicts a continuous outcome based on predictors.<\/li>\n\n\n\n<li>Logistic Regression estimates the probability of a categorical outcome based on predictors.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\" \/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"key-assumptions-while-using-logistic-regression\">Key assumptions while using logistic regression<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Logistic regression, like other statistical methods, relies on several key assumptions to ensure the validity and reliability of the results. Here are some of the key assumptions underlying logistic regression:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"720\" height=\"720\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Key-assumptions-while-using-logistic-regression-quantinsti.jpg\" alt=\"\" class=\"wp-image-203932 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Key-assumptions-while-using-logistic-regression-quantinsti.jpg 720w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Key-assumptions-while-using-logistic-regression-quantinsti-700x700.jpg 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/03\/Key-assumptions-while-using-logistic-regression-quantinsti-300x300.jpg 300w\" data-sizes=\"(max-width: 720px) 100vw, 720px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 720px; aspect-ratio: 720\/720;\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Binary Outcome:<\/strong>&nbsp;Logistic regression is specifically designed for binary outcome variables, meaning that the outcome variable should have only two categorical outcomes (e.g., 0\/1, Yes\/No).<\/li>\n\n\n\n<li><strong>Linearity of Log Odds:&nbsp;<\/strong>The relationship between the predictor variables and the log odds of the outcome should be linear. This assumption means that the log odds of the outcome should change linearly with the predictor variables.<\/li>\n\n\n\n<li><strong>Independence of Observations:<\/strong>&nbsp;Each observation in the dataset should be independent of the other observations. This assumption ensures that the observations are not correlated or dependent on each other, which could bias the estimates and inflate the Type I error rate.<\/li>\n\n\n\n<li><strong>No Multicollinearity:<\/strong>&nbsp;The predictor variables in the model should not be highly correlated with each other, as multicollinearity can make it difficult to estimate the individual effects of the predictor variables on the outcome.<\/li>\n\n\n\n<li><strong>Large Sample Size:<\/strong>&nbsp;Logistic regression models perform better and provide more reliable estimates with a larger sample size (data values). While there is no strict rule for the minimum sample size, having a sufficiently large sample size ensures that the estimates are stable and the model has enough power to detect significant effects.<\/li>\n\n\n\n<li><strong>Correct Specification of Model:<\/strong>&nbsp;The logistic regression model should be correctly specified, meaning that all relevant predictor variables should be included in the model, and the functional form of the model should accurately reflect the underlying relationship between the predictor variables and the outcome.<\/li>\n\n\n\n<li><strong>Absence of Outliers:<\/strong>&nbsp;The presence of outliers in the dataset can influence the estimates and distort the results of the logistic regression model. It is essential to identify and handle outliers during data cleaning to ensure the robustness and validity of the model.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">In summary, while logistic regression is a powerful and widely used method for modelling binary outcomes, it is crucial to ensure that the key assumptions of the model are met to obtain valid and reliable results. Violation of these assumptions can lead to biassed estimates, inaccurate predictions, and misleading conclusions, emphasising the importance of careful data preparation, model checking, and interpretation in logistic regression analysis.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Author: Chainika Thakar (Originally written By Vibhu Singh)<\/em><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Stay tuned for Part III<\/em> <em>on how to use logistic regression in trading<\/em>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally posted on&nbsp;<a href=\"https:\/\/blog.quantinsti.com\/machine-learning-logistic-regression-python\/\">QuantInsti<\/a>&nbsp;blog.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on predictor variables (technical indicators). <\/p>\n","protected":false},"author":186,"featured_media":161338,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,349,338,341],"tags":[851,16879,4405,852,16877,16880,595,16878],"contributors-categories":[13654],"class_list":["post-203928","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-python-development","category-ibkr-quant-news","category-quant-development","tag-algo-trading","tag-binary-logistic-regression","tag-logistic-regression","tag-machine-learning","tag-moving-average-crossover","tag-multinomial-logistic-regression","tag-python","tag-relative-strength-index-rsi","contributors-categories-quantinsti"],"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v28.0) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Machine Learning Logistic Regression: Python, Trading and More &#8211; Part II<\/title>\n<meta name=\"description\" content=\"Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on...\" \/>\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.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/203928\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Machine Learning Logistic Regression: Python, Trading and More \u2013 Part II\" \/>\n<meta property=\"og:description\" content=\"Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on predictor variables (technical indicators).\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2024-04-01T16:06:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-02T14:48:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Contributor Author\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Contributor Author\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Contributor Author\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\"\n\t            },\n\t            \"headline\": \"Machine Learning Logistic Regression: Python, Trading and More &#8211; Part II\",\n\t            \"datePublished\": \"2024-04-01T16:06:21+00:00\",\n\t            \"dateModified\": \"2024-04-02T14:48:14+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/\"\n\t            },\n\t            \"wordCount\": 1497,\n\t            \"commentCount\": 0,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/10\\\/quant-binary-red-green.jpg\",\n\t            \"keywords\": [\n\t                \"Algo Trading\",\n\t                \"Binary Logistic Regression\",\n\t                \"Logistic Regression\",\n\t                \"Machine Learning\",\n\t                \"Moving Average Crossover\",\n\t                \"Multinomial Logistic Regression\",\n\t                \"Python\",\n\t                \"Relative Strength Index (RSI)\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Python Development\",\n\t                \"Quant\",\n\t                \"Quant Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/\",\n\t            \"name\": \"Machine Learning Logistic Regression: Python, Trading and More - Part II | IBKR Campus US\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/10\\\/quant-binary-red-green.jpg\",\n\t            \"datePublished\": \"2024-04-01T16:06:21+00:00\",\n\t            \"dateModified\": \"2024-04-02T14:48:14+00:00\",\n\t            \"description\": \"Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on predictor variables (technical indicators).\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/machine-learning-logistic-regression-python-trading-and-more-part-ii\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/10\\\/quant-binary-red-green.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/10\\\/quant-binary-red-green.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Quant\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/e823e46b42ca381080387e794318a485\",\n\t            \"name\": \"Contributor Author\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/contributor-author\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Machine Learning Logistic Regression: Python, Trading and More &#8211; Part II","description":"Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on...","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.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/203928\/","og_locale":"en_US","og_type":"article","og_title":"Machine Learning Logistic Regression: Python, Trading and More \u2013 Part II","og_description":"Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on predictor variables (technical indicators).","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/","og_site_name":"IBKR Campus US","article_published_time":"2024-04-01T16:06:21+00:00","article_modified_time":"2024-04-02T14:48:14+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg","type":"image\/jpeg"}],"author":"Contributor Author","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Contributor Author","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/"},"author":{"name":"Contributor Author","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485"},"headline":"Machine Learning Logistic Regression: Python, Trading and More &#8211; Part II","datePublished":"2024-04-01T16:06:21+00:00","dateModified":"2024-04-02T14:48:14+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/"},"wordCount":1497,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg","keywords":["Algo Trading","Binary Logistic Regression","Logistic Regression","Machine Learning","Moving Average Crossover","Multinomial Logistic Regression","Python","Relative Strength Index (RSI)"],"articleSection":["Data Science","Programming Languages","Python Development","Quant","Quant Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/","name":"Machine Learning Logistic Regression: Python, Trading and More - Part II | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg","datePublished":"2024-04-01T16:06:21+00:00","dateModified":"2024-04-02T14:48:14+00:00","description":"Logistic regression can be used in trading to predict binary outcomes (stock price will \u201cincrease\u201d or decrease\u201d) or classify data based on predictor variables (technical indicators).","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/machine-learning-logistic-regression-python-trading-and-more-part-ii\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg","width":1000,"height":563,"caption":"Quant"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/e823e46b42ca381080387e794318a485","name":"Contributor Author","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/contributor-author\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2022\/10\/quant-binary-red-green.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/203928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/186"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=203928"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/203928\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/161338"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=203928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=203928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=203928"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=203928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}