{"id":2428,"date":"2023-07-22T07:58:40","date_gmt":"2023-07-22T07:58:40","guid":{"rendered":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/"},"modified":"2023-07-22T07:58:40","modified_gmt":"2023-07-22T07:58:40","slug":"plot-logistieke-regressie-in-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/","title":{"rendered":"Hoe een logistische regressiecurve in python te plotten"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de functie <a href=\"https:\/\/seaborn.pydata.org\/generated\/seaborn.regplot.html\" target=\"_blank\" rel=\"noopener\">regplot()<\/a> van de seaborn datavisualisatiebibliotheek gebruiken om een logistieke regressiecurve in Python te plotten:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">import<\/span> seaborn <span style=\"color: #008000;\">as<\/span> sns\n\nsns. <span style=\"color: #3366ff;\">regplot<\/span> (x=x, y=y, data=df, logistic= <span style=\"color: #008000;\">True<\/span> <span style=\"color: #008080;\"><span style=\"color: #000000;\">, ci= <span style=\"color: #008000;\">None<\/span> )<\/span><\/span>\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Voorbeeld: een logistische regressiecurve uitzetten in Python<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Voor dit voorbeeld gebruiken we de <strong>standaarddataset<\/strong> uit het <a href=\"https:\/\/www.statlearning.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">boek Introduction to Statistical Learning<\/a> . We kunnen de volgende code gebruiken om een samenvatting van de dataset te laden en weer te geven:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#import dataset from CSV file on Github\n<span style=\"color: #000000;\">url = \"https:\/\/raw.githubusercontent.com\/Statorials\/Python-Guides\/main\/default.csv\"\ndata = pd. <span style=\"color: #3366ff;\">read_csv<\/span> (url)\n<\/span><\/span>\n<span style=\"color: #008080;\">#view first six rows of dataset\n<\/span>data[0:6]\n\n        default student balance income\n0 0 0 729.526495 44361.625074\n1 0 1 817.180407 12106.134700\n2 0 0 1073.549164 31767.138947\n3 0 0 529.250605 35704.493935\n4 0 0 785.655883 38463.495879\n5 0 1 919.588530 7491.558572  \n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Deze dataset bevat de volgende informatie over 10.000 personen:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>standaard:<\/strong> geeft aan of een persoon in gebreke is gebleven of niet.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>student:<\/strong> geeft aan of een persoon student is of niet.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>saldo:<\/strong> Gemiddeld saldo dat door een individu wordt bijgehouden.<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>inkomen:<\/strong> inkomen van het individu.<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Stel dat we een logistisch regressiemodel willen construeren dat \u2018balans\u2019 gebruikt om de waarschijnlijkheid te voorspellen dat een bepaald individu in gebreke blijft.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen de volgende code gebruiken om een logistische regressiecurve uit te zetten:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define the predictor variable and the response variable\n<span style=\"color: #000000;\">x = data[' <span style=\"color: #ff0000;\">balance<\/span> ']\ny = data[' <span style=\"color: #ff0000;\">default<\/span> ']<\/span>\n\n#plot logistic regression curve\n<span style=\"color: #000000;\">sns. <span style=\"color: #3366ff;\">regplot<\/span> (x=x, y=y, data=data, logistic= <span style=\"color: #008000;\">True<\/span> , ci= <span style=\"color: #008000;\">None<\/span> )<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-21793 aligncenter\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/regplot1.png\" alt=\"\" width=\"540\" height=\"358\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Op de x-as staan de waarden van de voorspellende variabele \u2018balans\u2019 en op de y-as staat de voorspelde kans op wanbetaling.<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen duidelijk zien dat hogere evenwichtswaarden verband houden met een grotere kans dat een individu in gebreke blijft.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Merk op dat u ook <strong>scatter_kws<\/strong> en <strong>line_kws<\/strong> kunt gebruiken om de kleuren van de punten en de curve in de grafiek te wijzigen:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\">#define the predictor variable and the response variable\n<span style=\"color: #000000;\">x = data[' <span style=\"color: #ff0000;\">balance<\/span> ']\ny = data[' <span style=\"color: #ff0000;\">default<\/span> ']<\/span>\n\n#plot logistic regression curve with black points and red line\n<span style=\"color: #000000;\">sns. <span style=\"color: #3366ff;\">regplot<\/span> (x=x, y=y, data=data, logistic= <span style=\"color: #008000;\">True<\/span> , ci= <span style=\"color: #008000;\">None<\/span> ),\n            scatter_kws={' <span style=\"color: #ff0000;\">color<\/span> ': ' <span style=\"color: #ff0000;\">black<\/span> '}, line_kws={' <span style=\"color: #ff0000;\">color<\/span> ': ' <span style=\"color: #ff0000;\">red<\/span> '})<\/span><\/span><\/strong> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-21794 \" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/regplot2.png\" alt=\"logistische regressiecurve in Python\" width=\"544\" height=\"363\" srcset=\"\" sizes=\"auto, \"><\/p>\n<p> <span style=\"color: #000000;\">Voel je vrij om de kleuren te kiezen die je in de plot wilt hebben.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">De volgende zelfstudies bieden aanvullende informatie over logistische regressie:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/logistische-regressie-1\/\" target=\"_blank\" rel=\"noopener\">Inleiding tot logistieke regressie<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/hoe-logistische-regressieresultaten-te-rapporteren\/\" target=\"_blank\" rel=\"noopener\">Hoe logistieke regressieresultaten te rapporteren<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/logistische-regressiepython\/\" target=\"_blank\" rel=\"noopener\">Logistieke regressie uitvoeren in Python (stap voor stap)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de functie regplot() van de seaborn datavisualisatiebibliotheek gebruiken om een logistieke regressiecurve in Python te plotten: import seaborn as sns sns. regplot (x=x, y=y, data=df, logistic= True , ci= None ) Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken. Voorbeeld: een logistische regressiecurve uitzetten in Python Voor [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-2428","post","type-post","status-publish","format-standard","hentry","category-gids"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Hoe een logistische regressiecurve in Python te plotten - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u een logistieke regressiecurve in Python kunt plotten.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe een logistische regressiecurve in Python te plotten - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u een logistieke regressiecurve in Python kunt plotten.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-22T07:58:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/regplot1.png\" \/>\n<meta name=\"author\" content=\"Dr.benjamin anderson\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Verfasst von\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dr.benjamin anderson\" \/>\n\t<meta name=\"twitter:label2\" content=\"Gesch\u00e4tzte Lesezeit\" \/>\n\t<meta name=\"twitter:data2\" content=\"2\u00a0Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/\",\"url\":\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/\",\"name\":\"Hoe een logistische regressiecurve in Python te plotten - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-22T07:58:40+00:00\",\"dateModified\":\"2023-07-22T07:58:40+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\"},\"description\":\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u een logistieke regressiecurve in Python kunt plotten.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe een logistische regressiecurve in python te plotten\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/nl\/#website\",\"url\":\"https:\/\/statorials.org\/nl\/\",\"name\":\"Statorials\",\"description\":\"Uw gids voor statistische competentie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/nl\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219\",\"name\":\"Dr.benjamin anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de\",\"@id\":\"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr.benjamin anderson\"},\"description\":\"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder\",\"sameAs\":[\"http:\/\/statorials.org\/nl\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Hoe een logistische regressiecurve in Python te plotten - Statorials","description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u een logistieke regressiecurve in Python kunt plotten.","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:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe een logistische regressiecurve in Python te plotten - Statorials","og_description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u een logistieke regressiecurve in Python kunt plotten.","og_url":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/","og_site_name":"Statorials","article_published_time":"2023-07-22T07:58:40+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/regplot1.png"}],"author":"Dr.benjamin anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr.benjamin anderson","Gesch\u00e4tzte Lesezeit":"2\u00a0Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/","url":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/","name":"Hoe een logistische regressiecurve in Python te plotten - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-22T07:58:40+00:00","dateModified":"2023-07-22T07:58:40+00:00","author":{"@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219"},"description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u een logistieke regressiecurve in Python kunt plotten.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/plot-logistieke-regressie-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe een logistische regressiecurve in python te plotten"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/nl\/#website","url":"https:\/\/statorials.org\/nl\/","name":"Statorials","description":"Uw gids voor statistische competentie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/nl\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de"},{"@type":"Person","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/d4b8842173cca1bb62cdec41860e4219","name":"Dr.benjamin anderson","image":{"@type":"ImageObject","inLanguage":"de","@id":"https:\/\/statorials.org\/nl\/#\/schema\/person\/image\/","url":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","contentUrl":"http:\/\/statorials.org\/nl\/wp-content\/uploads\/2023\/10\/Dr.-Benjamin-Anderson-96x96.jpg","caption":"Dr.benjamin anderson"},"description":"Ik ben Benjamin, een gepensioneerde hoogleraar statistiek die nu een toegewijde Statorials-lesgever is. Ik heb uitgebreide ervaring en expertise op het gebied van statistiek en ik ben vastbesloten om mijn kennis te delen met studenten via Statorials. Lees verder","sameAs":["http:\/\/statorials.org\/nl"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/comments?post=2428"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/2428\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=2428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=2428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=2428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}