{"id":2169,"date":"2023-07-23T09:57:36","date_gmt":"2023-07-23T09:57:36","guid":{"rendered":"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/"},"modified":"2023-07-23T09:57:36","modified_gmt":"2023-07-23T09:57:36","slug":"python-kurvenprazisionsruckruf","status":"publish","type":"post","link":"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/","title":{"rendered":"So erstellen sie eine pr\u00e4zisionsr\u00fcckrufkurve in python"},"content":{"rendered":"<p><\/p>\n<hr>\n<p><span style=\"color: #000000;\">Bei der Verwendung <a href=\"https:\/\/statorials.org\/de\/regression-vs.-klassifizierung\/\" target=\"_blank\" rel=\"noopener\">von Klassifizierungsmodellen<\/a> beim maschinellen Lernen verwenden wir h\u00e4ufig zwei Metriken zur Bewertung der Modellqualit\u00e4t: Pr\u00e4zision und Erinnerung.<\/span><\/p>\n<p> <span style=\"color: #000000;\"><strong>Genauigkeit<\/strong> : Korrigieren Sie positive Vorhersagen im Verh\u00e4ltnis zur Gesamtzahl der positiven Vorhersagen.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dies wird wie folgt berechnet:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Genauigkeit = True Positives \/ (True Positives + False Positives)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\"><strong>Erinnerung<\/strong> : Korrigieren Sie positive Vorhersagen anhand der gesamten tats\u00e4chlichen positiven Ergebnisse<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dies wird wie folgt berechnet:<\/span><\/p>\n<ul>\n<li> <span style=\"color: #000000;\">Erinnerung = Wahre Positive \/ (Wahr Positive + Falsch Negative)<\/span><\/li>\n<\/ul>\n<p> <span style=\"color: #000000;\">Um die Pr\u00e4zision und den R\u00fcckruf eines bestimmten Modells zu visualisieren, k\u00f6nnen wir eine <strong>Pr\u00e4zisions-R\u00fcckrufkurve<\/strong> erstellen.<\/span> <span style=\"color: #000000;\">Diese Kurve zeigt den Kompromiss zwischen Pr\u00e4zision und Erinnerung f\u00fcr verschiedene Schwellenwerte.<\/span> <\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-20068\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/precisionrecall2.png\" alt=\"Pr\u00e4zisionsr\u00fcckrufkurve in Python\" width=\"523\" height=\"416\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Das folgende Schritt-f\u00fcr-Schritt-Beispiel zeigt, wie Sie eine Pr\u00e4zisionsr\u00fcckrufkurve f\u00fcr ein logistisches Regressionsmodell in Python erstellen.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 1: Pakete importieren<br \/><\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Zuerst importieren wir die notwendigen Pakete:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <strong><span style=\"color: #008000;\">from<\/span> sklearn <span style=\"color: #008000;\">import<\/span> datasets\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">model_selection<\/span> <span style=\"color: #008000;\">import<\/span> train_test_split\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">linear_model<\/span> <span style=\"color: #008000;\">import<\/span> LogisticRegression\n<span style=\"color: #008000;\">from<\/span> sklearn. <span style=\"color: #3366ff;\">metrics<\/span> <span style=\"color: #008000;\">import<\/span> precision_recall_curve\n<span style=\"color: #008000;\">import<\/span> matplotlib. <span style=\"color: #3366ff;\">pyplot<\/span> <span style=\"color: #008000;\">as<\/span> plt\n<\/strong><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 2: Passen Sie das logistische Regressionsmodell an<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Als N\u00e4chstes erstellen wir einen Datensatz und passen ein logistisches Regressionsmodell daran an:<\/span><\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#create dataset with 5 predictor variables\n<\/span>X, y = datasets. <span style=\"color: #3366ff;\">make_classification<\/span> (n_samples= <span style=\"color: #008000;\">1000<\/span> ,\n                                    n_features= <span style=\"color: #008000;\">4<\/span> ,\n                                    n_informative= <span style=\"color: #008000;\">3<\/span> ,\n                                    n_redundant= <span style=\"color: #008000;\">1<\/span> ,\n                                    random_state= <span style=\"color: #008000;\">0<\/span> )\n\n<span style=\"color: #008080;\">#split dataset into training and testing set\n<\/span>X_train, X_test, y_train, y_test = train_test_split(X, y, test_size= <span style=\"color: #008000;\">.3<\/span> , random_state= <span style=\"color: #008000;\">0<\/span> )\n\n<span style=\"color: #008080;\">#fit logistic regression model to dataset\n<\/span>classifier = LogisticRegression()\nclassify. <span style=\"color: #3366ff;\">fit<\/span> (X_train, y_train)\n\n<span style=\"color: #008080;\">#use logistic regression model to make predictions\n<\/span>y_score = classify. <span style=\"color: #3366ff;\">predict_proba<\/span> (X_test)[:, <span style=\"color: #008000;\">1<\/span> ]<\/strong><\/span><\/pre>\n<h3> <span style=\"color: #000000;\"><strong>Schritt 3: Erstellen Sie die Precision-Recall-Kurve<\/strong><\/span><\/h3>\n<p> <span style=\"color: #000000;\">Als n\u00e4chstes berechnen wir die Pr\u00e4zision und den R\u00fcckruf des Modells und erstellen eine Pr\u00e4zisions-R\u00fcckruf-Kurve:<\/span> <\/p>\n<pre style=\"background-color: #ececec; font-size: 15px;\"> <span style=\"color: #000000;\"><strong><span style=\"color: #008080;\">#calculate precision and recall\n<\/span>precision, recall, thresholds = precision_recall_curve(y_test, y_score)\n\n<span style=\"color: #008080;\">#create precision recall curve\n<\/span>fig, ax = plt. <span style=\"color: #3366ff;\">subplots<\/span> ()\nax. <span style=\"color: #3366ff;\">plot<\/span> (recall, precision, color=' <span style=\"color: #ff0000;\">purple<\/span> ')\n\n<span style=\"color: #008080;\">#add axis labels to plot\n<\/span>ax. <span style=\"color: #3366ff;\">set_title<\/span> (' <span style=\"color: #ff0000;\">Precision-Recall Curve<\/span> ')\nax. <span style=\"color: #3366ff;\">set_ylabel<\/span> (' <span style=\"color: #ff0000;\">Precision<\/span> ')\nax. <span style=\"color: #3366ff;\">set_xlabel<\/span> (' <span style=\"color: #ff0000;\">Recall<\/span> ')\n\n<span style=\"color: #008080;\">#displayplot<\/span>\nplt. <span style=\"color: #3366ff;\">show<\/span> ()<\/strong><\/span> <\/pre>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter wp-image-20068\" src=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/precisionrecall2.png\" alt=\"Pr\u00e4zisionsr\u00fcckrufkurve in Python\" width=\"548\" height=\"437\" srcset=\"\" sizes=\"\"><\/p>\n<p> <span style=\"color: #000000;\">Die x-Achse zeigt den Abruf und die y-Achse zeigt die Pr\u00e4zision f\u00fcr verschiedene Schwellenwerte.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Beachten Sie, dass mit zunehmender Erinnerung die Pr\u00e4zision abnimmt.<\/span><\/p>\n<p> <span style=\"color: #000000;\">Dies stellt den Kompromiss zwischen den beiden Metriken dar. Um den R\u00fcckruf unseres Modells zu erh\u00f6hen, muss die Pr\u00e4zision abnehmen und umgekehrt.<\/span><\/p>\n<h3> <span style=\"color: #000000;\"><strong>Zus\u00e4tzliche Ressourcen<\/strong><\/span><\/h3>\n<p> <a href=\"https:\/\/statorials.org\/de\/logistische-regressionspython\/\" target=\"_blank\" rel=\"noopener\">So f\u00fchren Sie eine logistische Regression in Python durch<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/python-matrix-verwirrung\/\" target=\"_blank\" rel=\"noopener\">So erstellen Sie eine Verwirrungsmatrix in Python<\/a><br \/> <a href=\"https:\/\/statorials.org\/de\/interpretieren-sie-die-felskurve\/\" target=\"_blank\" rel=\"noopener\">So interpretieren Sie eine ROC-Kurve (mit Beispielen)<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bei der Verwendung von Klassifizierungsmodellen beim maschinellen Lernen verwenden wir h\u00e4ufig zwei Metriken zur Bewertung der Modellqualit\u00e4t: Pr\u00e4zision und Erinnerung. Genauigkeit : Korrigieren Sie positive Vorhersagen im Verh\u00e4ltnis zur Gesamtzahl der positiven Vorhersagen. Dies wird wie folgt berechnet: Genauigkeit = True Positives \/ (True Positives + False Positives) Erinnerung : Korrigieren Sie positive Vorhersagen anhand [&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 erstellen Sie eine Pr\u00e4zisionsr\u00fcckrufkurve in Python \u2013 Statorials<\/title>\n<meta name=\"description\" content=\"In diesem Tutorial wird anhand eines Schritt-f\u00fcr-Schritt-Beispiels erl\u00e4utert, wie Sie in Python eine Pr\u00e4zisionsr\u00fcckrufkurve erstellen.\" \/>\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-kurvenprazisionsruckruf\/\" \/>\n<meta property=\"og:locale\" content=\"de_DE\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"So erstellen Sie eine Pr\u00e4zisionsr\u00fcckrufkurve in Python \u2013 Statorials\" \/>\n<meta property=\"og:description\" content=\"In diesem Tutorial wird anhand eines Schritt-f\u00fcr-Schritt-Beispiels erl\u00e4utert, wie Sie in Python eine Pr\u00e4zisionsr\u00fcckrufkurve erstellen.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/\" \/>\n<meta property=\"og:site_name\" content=\"Statorials\" \/>\n<meta property=\"article:published_time\" content=\"2023-07-23T09:57:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/precisionrecall2.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 Minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/\",\"url\":\"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/\",\"name\":\"So erstellen Sie eine Pr\u00e4zisionsr\u00fcckrufkurve in Python \u2013 Statorials\",\"isPartOf\":{\"@id\":\"https:\/\/statorials.org\/de\/#website\"},\"datePublished\":\"2023-07-23T09:57:36+00:00\",\"dateModified\":\"2023-07-23T09:57:36+00:00\",\"author\":{\"@id\":\"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0\"},\"description\":\"In diesem Tutorial wird anhand eines Schritt-f\u00fcr-Schritt-Beispiels erl\u00e4utert, wie Sie in Python eine Pr\u00e4zisionsr\u00fcckrufkurve erstellen.\",\"breadcrumb\":{\"@id\":\"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/#breadcrumb\"},\"inLanguage\":\"de-DE\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Heim\",\"item\":\"https:\/\/statorials.org\/de\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"So erstellen sie eine pr\u00e4zisionsr\u00fcckrufkurve 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 erstellen Sie eine Pr\u00e4zisionsr\u00fcckrufkurve in Python \u2013 Statorials","description":"In diesem Tutorial wird anhand eines Schritt-f\u00fcr-Schritt-Beispiels erl\u00e4utert, wie Sie in Python eine Pr\u00e4zisionsr\u00fcckrufkurve erstellen.","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-kurvenprazisionsruckruf\/","og_locale":"de_DE","og_type":"article","og_title":"So erstellen Sie eine Pr\u00e4zisionsr\u00fcckrufkurve in Python \u2013 Statorials","og_description":"In diesem Tutorial wird anhand eines Schritt-f\u00fcr-Schritt-Beispiels erl\u00e4utert, wie Sie in Python eine Pr\u00e4zisionsr\u00fcckrufkurve erstellen.","og_url":"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/","og_site_name":"Statorials","article_published_time":"2023-07-23T09:57:36+00:00","og_image":[{"url":"https:\/\/statorials.org\/wp-content\/uploads\/2023\/08\/precisionrecall2.png"}],"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\/python-kurvenprazisionsruckruf\/","url":"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/","name":"So erstellen Sie eine Pr\u00e4zisionsr\u00fcckrufkurve in Python \u2013 Statorials","isPartOf":{"@id":"https:\/\/statorials.org\/de\/#website"},"datePublished":"2023-07-23T09:57:36+00:00","dateModified":"2023-07-23T09:57:36+00:00","author":{"@id":"https:\/\/statorials.org\/de\/#\/schema\/person\/ec75c4d6365f2708f8a0ad3a42121aa0"},"description":"In diesem Tutorial wird anhand eines Schritt-f\u00fcr-Schritt-Beispiels erl\u00e4utert, wie Sie in Python eine Pr\u00e4zisionsr\u00fcckrufkurve erstellen.","breadcrumb":{"@id":"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/#breadcrumb"},"inLanguage":"de-DE","potentialAction":[{"@type":"ReadAction","target":["https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/statorials.org\/de\/python-kurvenprazisionsruckruf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Heim","item":"https:\/\/statorials.org\/de\/"},{"@type":"ListItem","position":2,"name":"So erstellen sie eine pr\u00e4zisionsr\u00fcckrufkurve 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\/2169"}],"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=2169"}],"version-history":[{"count":0,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/posts\/2169\/revisions"}],"wp:attachment":[{"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/media?parent=2169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/categories?post=2169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/statorials.org\/de\/wp-json\/wp\/v2\/tags?post=2169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}