{"id":1336,"date":"2023-07-26T19:53:42","date_gmt":"2023-07-26T19:53:42","guid":{"rendered":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/"},"modified":"2023-07-26T19:53:42","modified_gmt":"2023-07-26T19:53:42","slug":"restquadratsumme-in-python","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/","title":{"rendered":"So berechnen sie die restquadratsumme in python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Ein <a href=\"https:\/\/statorials.org\/de\/ruckstand\/\" target=\"_blank\" rel=\"noopener\">Residuum<\/a> ist die Differenz zwischen einem beobachteten Wert und einem vorhergesagten Wert in einem Regressionsmodell.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Es wird wie folgt berechnet:<\/span><\/p>\n<p> <span style=\"color: #000000;\">Residuum = Beobachteter Wert \u2013 Vorhergesagter Wert<\/span><\/p>\n<p> <span style=\"color: #000000;\">Eine M\u00f6glichkeit zu verstehen, wie gut ein Regressionsmodell zu einem Datensatz passt, ist die Berechnung der <strong>Restquadratsumme<\/strong> , die wie folgt berechnet wird:<\/span><\/p>\n<p> <span style=\"color: #000000;\">Restquadratsumme = \u03a3(e <sub>i<\/sub> ) <sup>2<\/sup><\/span><\/p>\n<p> <span style=\"color: #000000;\">Gold:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>\u03a3<\/strong> : Ein griechisches Symbol mit der Bedeutung \u201eSumme\u201c<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>e <sub>i<\/sub><\/strong> : Der i- <sup>te<\/sup> Rest<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Je niedriger der Wert, desto besser passt das Modell zu einem Datensatz.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dieses Tutorial bietet ein schrittweises Beispiel f\u00fcr die Berechnung der Restquadratsumme f\u00fcr ein Regressionsmodell in Python.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 1: Geben Sie die Daten ein<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">F\u00fcr dieses Beispiel geben wir Daten zur Anzahl der Lernstunden, zur Gesamtzahl der abgelegten Vorbereitungspr\u00fcfungen und zu den Pr\u00fcfungsergebnissen von 14 verschiedenen Studierenden ein:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #107d3f;\">import<\/span> pandas <span style=\"color: #107d3f;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#createDataFrame<\/span>\ndf = pd. <span style=\"color: #3366ff;\">DataFrame<\/span> ({' <span style=\"color: #008000;\">hours<\/span> ': [1, 2, 2, 4, 2, 1, 5, 4, 2, 4, 4, 3, 6, 5],\n                   ' <span style=\"color: #008000;\">exams<\/span> ': [1, 3, 3, 5, 2, 2, 1, 1, 0, 3, 4, 3, 2, 4],\n                   ' <span style=\"color: #008000;\">score<\/span> ': [76, 78, 85, 88, 72, 69, 94, 94, 88, 92, 90, 75, 96, 90]})\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 2: Passen Sie das Regressionsmodell an<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Als n\u00e4chstes verwenden wir die<\/span> <a href=\"https:\/\/www.statsmodels.org\/devel\/generated\/statsmodels.regression.linear_model.OLS.html\" target=\"_blank\" rel=\"noopener noreferrer\">Funktion OLS()<\/a> <span style=\"color: #000000;\">aus der Statsmodels-Bibliothek, um eine gew\u00f6hnliche Regression der kleinsten Quadrate durchzuf\u00fchren, wobei wir \u201eStunden\u201c und \u201ePr\u00fcfungen\u201c als Pr\u00e4diktorvariablen und \u201ePunktzahl\u201c als Antwortvariable verwenden:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008000;\">import<\/span> statsmodels. <span style=\"color: #3366ff;\">api<\/span> <span style=\"color: #008000;\">as<\/span> sm\n\n<span style=\"color: #008080;\">#define response variable\n<\/span>y = df[' <span style=\"color: #008000;\">score<\/span> ']\n\n<span style=\"color: #008080;\">#define predictor variables\n<\/span>x = df[[' <span style=\"color: #008000;\">hours<\/span> ', ' <span style=\"color: #008000;\">exams<\/span> ']]\n\n<span style=\"color: #008080;\">#add constant to predictor variables\n<\/span>x = sm. <span style=\"color: #3366ff;\">add_constant<\/span> (x)\n\n<span style=\"color: #008080;\">#fit linear regression model\n<\/span>model = sm. <span style=\"color: #3366ff;\">OLS<\/span> (y,x). <span style=\"color: #3366ff;\">fit<\/span> ()\n\n<span style=\"color: #008080;\">#view model summary\n<\/span><span style=\"color: #993300;\">print<\/span> ( <span style=\"color: #3366ff;\">model.summary<\/span> ())\n\n                            OLS Regression Results                            \n==================================================== ============================\nDept. Variable: R-squared score: 0.722\nModel: OLS Adj. R-squared: 0.671\nMethod: Least Squares F-statistic: 14.27\nDate: Sat, 02 Jan 2021 Prob (F-statistic): 0.000878\nTime: 15:58:35 Log-Likelihood: -41.159\nNo. Comments: 14 AIC: 88.32\nDf Residuals: 11 BIC: 90.24\nModel: 2                                         \nCovariance Type: non-robust                                         \n==================================================== ============================\n                 coef std err t P&gt;|t| [0.025 0.975]\n-------------------------------------------------- ----------------------------\nconst 71.8144 3.680 19.517 0.000 63.716 79.913\nhours 5.0318 0.942 5.339 0.000 2.958 7.106\nexams -1.3186 1.063 -1.240 0.241 -3.658 1.021\n==================================================== ============================\nOmnibus: 0.976 Durbin-Watson: 1.270\nProb(Omnibus): 0.614 Jarque-Bera (JB): 0.757\nSkew: -0.245 Prob(JB): 0.685\nKurtosis: 1.971 Cond. No. 12.1\n==================================================== ============================\n<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 3: Berechnen Sie die Restquadratsumme<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Wir k\u00f6nnen den folgenden Code verwenden, um die verbleibende Quadratsumme des Modells zu berechnen:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #993300;\">print<\/span> ( <span style=\"color: #3366ff;\">model.ssr<\/span> )\n\n293.25612951525414\n<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Die verbleibende Quadratsumme ergibt sich zu <strong>293.256<\/strong> .<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/de\/einfache-lineare-regression-in-python\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine einfache lineare Regression in Python durch<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/lineare-regressionspython\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine multiple lineare Regression in Python durch<\/a><br \/> Restquadratsummenrechner<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ein Residuum ist die Differenz zwischen einem beobachteten Wert und einem vorhergesagten Wert in einem Regressionsmodell. Es wird wie folgt berechnet: Residuum = Beobachteter Wert \u2013 Vorhergesagter Wert Eine M\u00f6glichkeit zu verstehen, wie gut ein Regressionsmodell zu einem Datensatz passt, ist die Berechnung der Restquadratsumme , die wie folgt berechnet wird: Restquadratsumme = \u03a3(e i [&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":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>So berechnen Sie die Restquadratsumme in Python - Statorials<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Restquadratsumme f\u00fcr ein Regressionsmodell in Python berechnet wird.\" \/>\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\/de\/restquadratsumme-in-python\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So berechnen Sie die Restquadratsumme in Python - Statorials\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Restquadratsumme f\u00fcr ein Regressionsmodell in Python berechnet wird.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-26T19:53:42+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 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/\",\"url\":\"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/\",\"name\":\"So berechnen Sie die Restquadratsumme in Python - Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-26T19:53:42+00:00\",\"dateModified\":\"2023-07-26T19:53:42+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Restquadratsumme f\u00fcr ein Regressionsmodell in Python berechnet wird.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So berechnen sie die restquadratsumme in python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/statorials.org\/de\/#website\",\"url\":\"https:\/\/statorials.org\/de\/\",\"name\":\"Statorials\",\"description\":\"Ihr Leitfaden f\u00fcr statistische Kompetenz !\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/statorials.org\/de\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"de-DE\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\",\"name\":\"Dr. Benjamin Anderson\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"de-DE\",\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"contentUrl\":\"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg\",\"caption\":\"Dr. Benjamin Anderson\"},\"description\":\"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen\",\"sameAs\":[\"https:\/\/statorials.org\/de\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"So berechnen Sie die Restquadratsumme in Python - Statorials","description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Restquadratsumme f\u00fcr ein Regressionsmodell in Python berechnet wird.","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\/de\/restquadratsumme-in-python\/","og_locale":"de_DE","og_type":"article","og_title":"So berechnen Sie die Restquadratsumme in Python - Statorials","og_description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Restquadratsumme f\u00fcr ein Regressionsmodell in Python berechnet wird.","og_url":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/","og_site_name":"Statorials","article_published_time":"2023-07-26T19:53:42+00:00","author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"2 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/","url":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/","name":"So berechnen Sie die Restquadratsumme in Python - Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-26T19:53:42+00:00","dateModified":"2023-07-26T19:53:42+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand eines Beispiels erl\u00e4utert, wie die Restquadratsumme f\u00fcr ein Regressionsmodell in Python berechnet wird.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/restquadratsumme-in-python\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/restquadratsumme-in-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So berechnen sie die restquadratsumme in python"}]},{"@type":"WebSite","@id":"https:\/\/statorials.org\/de\/#website","url":"https:\/\/statorials.org\/de\/","name":"Statorials","description":"Ihr Leitfaden f\u00fcr statistische Kompetenz !","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/statorials.org\/de\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"de-DE"},{"@type":"Person","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0","name":"Dr. Benjamin Anderson","image":{"@type":"ImageObject","inLanguage":"de-DE","@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/image\/","url":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","contentUrl":"https:\/\/statorials.org\/de\/wp-content\/uploads\/2023\/11\/Benjamin-Anderson-96x96.jpg","caption":"Dr. Benjamin Anderson"},"description":"Hallo, ich bin Benjamin, ein pensionierter Statistikprofessor, der sich zum engagierten Statorials-Lehrer entwickelt hat. Mit umfassender Erfahrung und Fachwissen auf dem Gebiet der Statistik bin ich bestrebt, mein Wissen zu teilen, um Studenten durch Statorials zu bef\u00e4higen. Mehr wissen","sameAs":["https:\/\/statorials.org\/de"]}]}},"yoast_meta":{"yoast_wpseo_title":"","yoast_wpseo_metadesc":"","yoast_wpseo_canonical":""},"_links":{"self":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/1336"}],"collection":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/comments?post=1336"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/1336\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=1336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=1336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=1336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}