{"id":3817,"date":"2023-07-15T09:21:43","date_gmt":"2023-07-15T09:21:43","guid":{"rendered":"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/"},"modified":"2023-07-15T09:21:43","modified_gmt":"2023-07-15T09:21:43","slug":"sklearn-regressiecoefficienten","status":"publish","type":"post","link":"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/","title":{"rendered":"Hoe regressieco\u00ebffici\u00ebnten uit het scikit-learn-model te extraheren"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">U kunt de volgende basissyntaxis gebruiken om regressieco\u00ebffici\u00ebnten te extraheren uit een regressiemodel dat is gebouwd met scikit-learn in Python:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008080;\"><span style=\"color: #000000;\">p.d. <span style=\"color: #3366ff;\">DataFrame<\/span> ( <span style=\"color: #008000;\">zip<\/span> ( <span style=\"color: #3366ff;\">X.columns<\/span> , <span style=\"color: #3366ff;\">model.coef_<\/span> ))\n<\/span><\/span><\/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<h2> <span style=\"color: #000000;\"><strong>Voorbeeld: extraheer regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">Stel dat we het volgende panda&#8217;s DataFrame hebben dat informatie bevat over de bestudeerde uren, het aantal afgelegde voorbereidende examens en het eindexamencijfer behaald door 11 studenten in een klas:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#createDataFrame\n<\/span>df = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #ff0000;\">hours<\/span> ': [1, 2, 2, 4, 2, 1, 5, 4, 2, 4, 4],\n                   ' <span style=\"color: #ff0000;\">exams<\/span> ': [1, 3, 3, 5, 2, 2, 1, 1, 0, 3, 4],\n                   ' <span style=\"color: #ff0000;\">score<\/span> ': [76, 78, 85, 88, 72, 69, 94, 94, 88, 92, 90]})\n\n<span style=\"color: #008080;\">#view DataFrame\n<\/span><span style=\"color: #008000;\">print<\/span> (df)\n\n    hours exam score\n0 1 1 76\n1 2 3 78\n2 2 3 85\n3 4 5 88\n4 2 2 72\n5 1 2 69\n6 5 1 94\n7 4 1 94\n8 2 0 88\n9 4 3 92\n10 4 4 90<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen de volgende code gebruiken om een <a href=\"https:\/\/statorials.org\/nl\/meerdere-lineaire-regressie\/\" target=\"_blank\" rel=\"noopener\">meervoudig lineair regressiemodel<\/a> in te passen, waarbij <strong>uren<\/strong> en <strong>examens<\/strong> als voorspellende variabelen en <strong>score<\/strong> als responsvariabele worden gebruikt:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\"><span style=\"color: #000000;\"><span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">linear_model<\/span> <span style=\"color: #008000;\">import<\/span> LinearRegression\n\n<span style=\"color: #008080;\">#initiate linear regression model\n<\/span>model = LinearRegression()\n\n<span style=\"color: #008080;\">#define predictor and response variables\n<\/span>x, y = df[[' <span style=\"color: #ff0000;\">hours<\/span> ', ' <span style=\"color: #ff0000;\">exams<\/span> ']], df. <span style=\"color: #3366ff;\">score<\/span>\n\n<span style=\"color: #008080;\">#fit regression model\n<\/span>model. <span style=\"color: #3366ff;\">fit<\/span> (x,y)\n<\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">We kunnen dan de volgende syntaxis gebruiken om de regressieco\u00ebffici\u00ebnten van <strong>uren<\/strong> en <strong>examens<\/strong> te extraheren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#print regression coefficients\n<span style=\"color: #000000;\">p.d. <span style=\"color: #3366ff;\">DataFrame<\/span> ( <span style=\"color: #008000;\">zip<\/span> ( <span style=\"color: #3366ff;\">X.columns<\/span> , <span style=\"color: #3366ff;\">model.coef_<\/span> ))\n\n            0 1\n0 hours 5.794521\n1 exams -1.157647\n<\/span><\/span><\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Uit het resultaat kunnen we de regressieco\u00ebffici\u00ebnten voor de twee voorspellende variabelen in het model zien:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Co\u00ebffici\u00ebnt voor <strong>uren<\/strong> : 5,794521<\/span><\/li>\n<li> <span style=\"color: #000000;\">Co\u00ebffici\u00ebnt voor <strong>examens<\/strong> : -1,157647<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Als we willen, kunnen we ook de volgende syntaxis gebruiken om de oorspronkelijke waarde uit het regressiemodel te extraheren:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\"><span style=\"color: #000000;\"><span style=\"color: #008080;\">#print intercept value\n<span style=\"color: #000000;\"><span style=\"color: #008000;\">print<\/span> (model. <span style=\"color: #3366ff;\">intercept_<\/span> )\n\n70.48282057040197\n<\/span><\/span><\/span><\/span><\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Met behulp van elk van deze waarden kunnen we de vergelijking voor het aangepaste regressiemodel schrijven:<\/span><\/p>\n<p> <span style=\"color: #000000;\">Score = 70.483 + 5.795 (uren) \u2013 1.158 (examens)<\/span><\/p>\n<p> <span style=\"color: #000000;\">We kunnen deze vergelijking vervolgens gebruiken om het eindexamencijfer van een student te voorspellen op basis van het aantal uren dat hij heeft gestudeerd en het aantal afgelegde oefenexamens.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Een student die bijvoorbeeld 3 uur heeft gestudeerd en 2 voorbereidende examens heeft afgelegd, zou een eindcijfer van <strong>85,55<\/strong> moeten krijgen:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Score = 70.483 + 5.795 (uren) \u2013 1.158 (examens)<\/span><\/li>\n<li> <span style=\"color: #000000;\">Score = 70,483 + 5,795(3) \u2013 1,158(2)<\/span><\/li>\n<li> <span style=\"color: #000000;\">Score = 85,55<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\"><strong>Gerelateerd:<\/strong> <a href=\"https:\/\/statorials.org\/nl\/hoe-regressiecoefficienten-te-interpreteren\/\" target=\"_blank\" rel=\"noopener\">Regressieco\u00ebffici\u00ebnten interpreteren<\/a><\/span><\/p>\n<h2> <span style=\"color: #000000;\"><strong>Aanvullende bronnen<\/strong><\/span><\/h2>\n<p> <span style=\"color: #000000;\">In de volgende tutorials wordt uitgelegd hoe u andere veelvoorkomende bewerkingen in Python uitvoert:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/nl\/eenvoudige-lineaire-regressie-in-python\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe eenvoudige lineaire regressie uit te voeren in Python<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/lineaire-regressiepython\/\" target=\"_blank\" rel=\"noopener noreferrer\">Hoe u meerdere lineaire regressies uitvoert in Python<\/a><br \/> <a href=\"https:\/\/statorials.org\/nl\/aic-in-python\/\" target=\"_blank\" rel=\"noopener\">Hoe AIC van regressiemodellen in Python te berekenen<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>U kunt de volgende basissyntaxis gebruiken om regressieco\u00ebffici\u00ebnten te extraheren uit een regressiemodel dat is gebouwd met scikit-learn in Python: p.d. DataFrame ( zip ( X.columns , model.coef_ )) Het volgende voorbeeld laat zien hoe u deze syntaxis in de praktijk kunt gebruiken. Voorbeeld: extraheer regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model Stel dat we het volgende panda&#8217;s [&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-3817","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 regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model te extraheren - Statorials<\/title>\n<meta name=\"description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u regressieco\u00ebffici\u00ebnten kunt extraheren uit een regressiemodel dat is gebouwd met scikit-learn.\" \/>\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\/sklearn-regressiecoefficienten\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Hoe regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model te extraheren - Statorials\" \/>\n<meta property=\"og:description\" content=\"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u regressieco\u00ebffici\u00ebnten kunt extraheren uit een regressiemodel dat is gebouwd met scikit-learn.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-15T09:21:43+00:00\" \/>\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\/sklearn-regressiecoefficienten\/\",\"url\":\"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/\",\"name\":\"Hoe regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model te extraheren - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/nl\/#website\"},\"datePublished\":\"2023-07-15T09:21:43+00:00\",\"dateModified\":\"2023-07-15T09:21:43+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 regressieco\u00ebffici\u00ebnten kunt extraheren uit een regressiemodel dat is gebouwd met scikit-learn.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/#breadcrumb\"},\"inLanguage\":\"de\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Thuis\",\"item\":\"https:\/\/statorials.org\/nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Hoe regressieco\u00ebffici\u00ebnten uit het scikit-learn-model te extraheren\"}]},{\"@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 regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model te extraheren - Statorials","description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u regressieco\u00ebffici\u00ebnten kunt extraheren uit een regressiemodel dat is gebouwd met scikit-learn.","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\/sklearn-regressiecoefficienten\/","og_locale":"de_DE","og_type":"article","og_title":"Hoe regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model te extraheren - Statorials","og_description":"In deze tutorial wordt aan de hand van een voorbeeld uitgelegd hoe u regressieco\u00ebffici\u00ebnten kunt extraheren uit een regressiemodel dat is gebouwd met scikit-learn.","og_url":"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/","og_site_name":"Statorials","article_published_time":"2023-07-15T09:21:43+00:00","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\/sklearn-regressiecoefficienten\/","url":"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/","name":"Hoe regressieco\u00ebffici\u00ebnten uit het Scikit-Learn-model te extraheren - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/nl\/#website"},"datePublished":"2023-07-15T09:21:43+00:00","dateModified":"2023-07-15T09:21:43+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 regressieco\u00ebffici\u00ebnten kunt extraheren uit een regressiemodel dat is gebouwd met scikit-learn.","breadcrumb":{"@id":"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/#breadcrumb"},"inLanguage":"de","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/nl\/sklearn-regressiecoefficienten\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Thuis","item":"https:\/\/statorials.org\/nl\/"},{"@type":"ListItem","position":2,"name":"Hoe regressieco\u00ebffici\u00ebnten uit het scikit-learn-model te extraheren"}]},{"@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\/3817","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=3817"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/posts\/3817\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/media?parent=3817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/categories?post=3817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/nl\/wp-json\/wp\/v2\/tags?post=3817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}