{"id":2137,"date":"2023-07-23T13:02:12","date_gmt":"2023-07-23T13:02:12","guid":{"rendered":"https:\/\/statorials.org\/de\/python-bic\/"},"modified":"2023-07-23T13:02:12","modified_gmt":"2023-07-23T13:02:12","slug":"python-bic","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/python-bic\/","title":{"rendered":"So berechnen sie den bic in python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Das <strong>Bayes&#8217;sche Informationskriterium<\/strong> , oft als <strong>BIC<\/strong> abgek\u00fcrzt, ist ein Ma\u00df zum Vergleich der Anpassungsg\u00fcte verschiedener Regressionsmodelle.<\/span><\/p>\n<p> <span style=\"color: #000000;\">In der Praxis passen wir mehrere Regressionsmodelle an denselben Datensatz an und w\u00e4hlen das Modell mit dem niedrigsten BIC-Wert als das Modell aus, das am besten zu den Daten passt.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Zur Berechnung des BIC verwenden wir folgende Formel:<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>BIC:<\/strong> (RSS+log(n)d\u03c3\u0302 <sup>2<\/sup> ) \/ n<\/span><\/p>\n<p> <span style=\"color: #000000;\">Gold:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>d:<\/strong> Die Anzahl der Pr\u00e4diktoren<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>n:<\/strong> Gesamtbeobachtungen<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>\u03c3\u0302:<\/strong> Sch\u00e4tzung der Fehlervarianz, die jedem Antwortma\u00df in einem Regressionsmodell zugeordnet ist<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>RSS:<\/strong> Residualsumme der Quadrate aus dem Regressionsmodell<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>TSS:<\/strong> Gesamtsumme der Quadrate des Regressionsmodells<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Um den BIC mehrerer Regressionsmodelle in Python zu berechnen, k\u00f6nnen wir die Funktion <strong>statsmodels.regression.linear_model.OLS()<\/strong> verwenden, die \u00fcber eine Eigenschaft namens bic verf\u00fcgt, die uns den BIC-Wert f\u00fcr ein bestimmtes Modell angibt.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Das folgende Beispiel zeigt, wie diese Funktion zum Berechnen und Interpretieren des BIC f\u00fcr verschiedene Regressionsmodelle in Python verwendet wird.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Beispiel: Berechnen Sie den BIC von Regressionsmodellen in Python<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Angenommen, wir m\u00f6chten zwei verschiedene <a href=\"https:\/\/statorials.org\/de\/multiple-lineare-regression\/\" target=\"_blank\" rel=\"noopener\">multiple lineare Regressionsmodelle<\/a> mithilfe von Variablen aus dem <strong>mtcars-<\/strong> Datensatz anpassen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Zuerst laden wir diesen Datensatz:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">linear_model<\/span> <span style=\"color: #008000;\">import<\/span> LinearRegression\n<span style=\"color: #008000;\">import<\/span> statsmodels. <span style=\"color: #3366ff;\">api<\/span> <span style=\"color: #008000;\">as<\/span> sm\n<span style=\"color: #008000;\">import<\/span> pandas <span style=\"color: #008000;\">as<\/span> pd\n\n<span style=\"color: #008080;\">#define URL where dataset is located\n<\/span>url = \"https:\/\/raw.githubusercontent.com\/Statorials\/Python-Guides\/main\/mtcars.csv\"\n\n<span style=\"color: #008080;\">#read in data\n<\/span>data = pd. <span style=\"color: #3366ff;\">read_csv<\/span> (url)\n\n<span style=\"color: #008080;\">#view head of data\n<\/span>data. <span style=\"color: #3366ff;\">head<\/span> ()\n\n        model mpg cyl disp hp drat wt qsec vs am gear carb\n0 Mazda RX4 21.0 6 160.0 110 3.90 2.620 16.46 0 1 4 4\n1 Mazda RX4 Wag 21.0 6 160.0 110 3.90 2.875 17.02 0 1 4 4\n2 Datsun 710 22.8 4 108.0 93 3.85 2.320 18.61 1 1 4 1\n3 Hornet 4 Drive 21.4 6 258.0 110 3.08 3.215 19.44 1 0 3 1\n4 Hornet Sportabout 18.7 8 360.0 175 3.15 3.440 17.02 0 0 3 2\n<\/strong><\/pre>\n<p> <span style=\"color: #000000;\">Als n\u00e4chstes passen wir die folgenden zwei Regressionsmodelle an:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\"><strong>Modell 1<\/strong> : mpg = \u03b2 <sub>0<\/sub> + \u03b2 <sub>1<\/sub> (disp) + \u03b2 <sub>2<\/sub> (qsec)<\/span><\/li>\n<li> <span style=\"color: #000000;\"><strong>Modell 2<\/strong> : mpg = \u03b2 <sub>0<\/sub> + \u03b2 <sub>1<\/sub> (verf\u00fcgbar) + \u03b2 <sub>2<\/sub> (Gewicht)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Der folgende Code zeigt, wie das erste Modell angepasst und der BIC berechnet wird:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define response variable\n<\/span>y = data['mpg']\n\n<span style=\"color: #008080;\">#define predictor variables\n<\/span>x = data[['disp', 'qsec']]\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 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 BIC of model\n<\/span><span style=\"color: #993300;\">print<\/span> (model. <span style=\"color: #3366ff;\">bic<\/span> )\n\n174.23905634994506<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Der BIC dieses Modells betr\u00e4gt <strong>174,239<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Als n\u00e4chstes passen wir das zweite Modell an und berechnen den BIC:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#define response variable\n<\/span>y = data['mpg']\n\n<span style=\"color: #008080;\">#define predictor variables\n<\/span>x = data[['disp', 'wt']]\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 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 BIC of model\n<\/span><span style=\"color: #993300;\">print<\/span> (model. <span style=\"color: #3366ff;\">bic<\/span> )\n\n166.56499196301334<\/strong><\/span><\/pre>\n<p> <span style=\"color: #000000;\">Der BIC dieses Modells betr\u00e4gt <strong>166,565<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">Da das zweite Modell einen niedrigeren BIC-Wert hat, ist es das am besten passende Modell.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Sobald wir dieses Modell als das beste identifiziert haben, k\u00f6nnen wir mit der Modellanpassung fortfahren und die Ergebnisse analysieren, einschlie\u00dflich des R-Quadrat-Werts und der Beta-Koeffizienten, um die genaue Beziehung zwischen dem Satz von Vorhersagevariablen und der <a href=\"https:\/\/statorials.org\/de\/variablen-erklarende-antworten\/\" target=\"_blank\" rel=\"noopener\">Antwortvariablen<\/a> zu bestimmen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Zwei weitere h\u00e4ufig verwendete Metriken zum Vergleich der Anpassung von Regressionsmodellen sind <strong>AIC<\/strong> und <strong>angepasstes R-Quadrat<\/strong> .<\/span><\/p>\n<p> <span style=\"color: #000000;\">In den folgenden Tutorials wird erl\u00e4utert, wie Sie jede dieser Metriken f\u00fcr Regressionsmodelle in Python berechnen:<\/span><\/p>\n<p> <a href=\"https:\/\/statorials.org\/de\/aic-in-python\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie den AIC von Regressionsmodellen in Python<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/r-quadrat-in-python-passt-sich-an\/\" target=\"_blank\" rel=\"noopener\">So berechnen Sie das angepasste R-Quadrat in Python<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Das Bayes&#8217;sche Informationskriterium , oft als BIC abgek\u00fcrzt, ist ein Ma\u00df zum Vergleich der Anpassungsg\u00fcte verschiedener Regressionsmodelle. In der Praxis passen wir mehrere Regressionsmodelle an denselben Datensatz an und w\u00e4hlen das Modell mit dem niedrigsten BIC-Wert als das Modell aus, das am besten zu den Daten passt. Zur Berechnung des BIC verwenden wir folgende Formel: [&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 den BIC in Python \u2013 Statistik<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie BIC-Werte f\u00fcr Regressionsmodelle in Python berechnet werden.\" \/>\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\/python-bic\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So berechnen Sie den BIC in Python \u2013 Statistik\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie BIC-Werte f\u00fcr Regressionsmodelle in Python berechnet werden.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/python-bic\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T13:02:12+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=\"3 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/python-bic\/\",\"url\":\"https:\/\/statorials.org\/de\/python-bic\/\",\"name\":\"So berechnen Sie den BIC in Python \u2013 Statistik\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-23T13:02:12+00:00\",\"dateModified\":\"2023-07-23T13:02:12+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie BIC-Werte f\u00fcr Regressionsmodelle in Python berechnet werden.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/python-bic\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/python-bic\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/python-bic\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So berechnen sie den bic 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 den BIC in Python \u2013 Statistik","description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie BIC-Werte f\u00fcr Regressionsmodelle in Python berechnet werden.","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\/python-bic\/","og_locale":"de_DE","og_type":"article","og_title":"So berechnen Sie den BIC in Python \u2013 Statistik","og_description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie BIC-Werte f\u00fcr Regressionsmodelle in Python berechnet werden.","og_url":"https:\/\/statorials.org\/de\/python-bic\/","og_site_name":"Statorials","article_published_time":"2023-07-23T13:02:12+00:00","author":"Dr. Benjamin Anderson","twitter_card":"summary_large_image","twitter_misc":{"Verfasst von":"Dr. Benjamin Anderson","Gesch\u00e4tzte Lesezeit":"3 Minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/statorials.org\/de\/python-bic\/","url":"https:\/\/statorials.org\/de\/python-bic\/","name":"So berechnen Sie den BIC in Python \u2013 Statistik","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-23T13:02:12+00:00","dateModified":"2023-07-23T13:02:12+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand mehrerer Beispiele erl\u00e4utert, wie BIC-Werte f\u00fcr Regressionsmodelle in Python berechnet werden.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/python-bic\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/python-bic\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/python-bic\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So berechnen sie den bic 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\/2137"}],"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=2137"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/2137\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=2137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=2137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=2137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}