von lina_24642 » So 17. Jul 2022, 10:27
Liebes Forum,
ich möchte mit einer Abbildung Underfitting und Overfitting abbilden (siehe Bild). Ich bin schon eine ganze Weile am Probieren und Suchen, aber leider weiß ich nicht, wie ich eine Funktion in die Grafik bekommen, die die Punkte genau an der richtigen Stelle trennt.
Online habe ich eine ähnliche Fragestellung gefunden, die allerdings nie zufriedenstellend beantwortet werden konnte:
https://tex.stackexchange.com/questions/364093/plotting-overfitting-diagram
Schon im Voraus vielen Dank für eure Hilfe!
Mein aktueller Code ist unten angefügt. Das ist jetzt nicht sonderlich schön bisher und vielleicht kann mir ja jemand auch sagen, wie man das vielleicht schöner lösen kann. Super wäre wenn bei der Underfitting Grafik die Gerade noch stärker zur Geltung kommt. Weiterhin fehlen noch die Funktionen für die zweite und dritte Grafik, wobei beim Overfitting jeder Punkt richtig klassifiziert werden soll. Kann mir außerdem jemand sagen, wie ich die drei Grafiken zwar nebeneinander habe, aber dafür linksbündig mit der ersten startend?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usetikzlibrary{shapes.misc}
\tikzset{point/.style = {% define a style for the function points
circle,
fill=#1,
draw=black,
inner sep=4pt,
},
point/.default = {red!60}
}
\begin{document}
\begin{tikzpicture}[scale=0.8, cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}]
% Achsen zeichnen
\draw[->,thick] (0,0) -- (5.5,0) node[right] {}; %{$x$}
\draw[->,thick] (0,0) -- (0,5.5) node[above] {}; %{$y$}
%Punkte einzeichnen:
%Gelbe Punkte
\node[point=yellow] (Y) at (3, 3){};
\node[point=yellow] (Y) at (3.5, 2.5){};
\node[point=yellow] (Y) at (4.2, 3.3){};
\node[point=yellow] (Y) at (4.8, 4){};
\node[point=yellow] (Y) at (5, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.0){};
\node[point=yellow] (Y) at (2.7, 5){};
\node[point=yellow] (Y) at (2.5, 4.2){};
\node[point=yellow] (Y) at (4.3, 4.9){};
\node[point=yellow] (Y) at (3.7, 1.9){};
\node[point=yellow] (Y) at (5.1, 3.3){};
\node[point=yellow] (Y) at (2.7, 2){};
\node[point=yellow] (Y) at (4.2, 2.5){};
\node[point=yellow] (Y) at (4.9, 2.2){};
%Ausreißer gelb
\node[point=yellow] (Y) at (1.8, 4.3){};
%Ausreißer blau
\node[point=blue!70] (Y) at (2.7, 3.6){};
%Blaue Punkte
\node[point=blue!70] (Y) at (1, 2){};
\node[point=blue!70] (Y) at (0.8, 3){};
\node[point=blue!70] (Y) at (1.4, 3.6){};
\node[point=blue!70] (Y) at (1.7, 5){};
\node[point=blue!70] (Y) at (1, 4.5){};
\node[point=blue!70] (Y) at (0.4, 4.9){};
\node[point=blue!70] (Y) at (0.7, 3.7){};
\node[point=blue!70] (Y) at (2, 3.2){};
\node[point=blue!70] (Y) at (1.9, 2.5){};
\node[point=blue!70] (Y) at (2.3, 1.3){};
\node[point=blue!70] (Y) at (1.3, 0.9){};
\node[point=blue!70] (Y) at (0.4, 0.9){};
\node[point=blue!70] (Y) at (2.4, 0.4){};
\node[point=blue!70] (Y) at (0.5, 1.5){};
\node[point=blue!70] (Y) at (1.7, 1.6){};
\node[point=blue!70] (Y) at (3, 0.9){};
\node[point=blue!70] (Y) at (3.9, 1.1){};
\node[point=blue!70] (Y) at (4.8, 1.4){};
\node[point=blue!70] (Y) at (4.4, 0.6){};
\node[point=blue!70] (Y) at (5.1, 0.7){};
%Lineare - Underfitting
\draw[thick, red] (0,5.5) node[left] {} -- (5.5,1.5);
% Text
\node at (1.1,0.3) {Klasse 0};
\node at (4.3, 5.4) {Klasse 1};
\node at (1.4,-0.5) {\textbf{Underfitting}};
\end{tikzpicture}
\hspace{1cm}% NO SPACE!
\begin{tikzpicture}[scale=0.8,cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}]
% Achsen zeichnen
\draw[->,thick] (0,0) -- (5.5,0) node[right] {}; %{$x$}
\draw[->,thick] (0,0) -- (0,5.5) node[above] {}; %{$y$}
%Punkte einzeichnen:
%Gelbe Punkte
\node[point=yellow] (Y) at (3, 3){};
\node[point=yellow] (Y) at (3.5, 2.5){};
\node[point=yellow] (Y) at (4.2, 3.3){};
\node[point=yellow] (Y) at (4.8, 4){};
\node[point=yellow] (Y) at (5, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.0){};
\node[point=yellow] (Y) at (2.7, 5){};
\node[point=yellow] (Y) at (2.5, 4.2){};
\node[point=yellow] (Y) at (4.3, 4.9){};
\node[point=yellow] (Y) at (3.7, 1.9){};
\node[point=yellow] (Y) at (5.1, 3.3){};
\node[point=yellow] (Y) at (2.7, 2){};
\node[point=yellow] (Y) at (4.2, 2.5){};
\node[point=yellow] (Y) at (4.9, 2.2){};
%Ausreißer gelb
\node[point=yellow] (Y) at (1.8, 4.3){};
%Ausreißer blau
\node[point=blue!70] (Y) at (2.7, 3.6){};
%Blaue Punkte
\node[point=blue!70] (Y) at (1, 2){};
\node[point=blue!70] (Y) at (0.8, 3){};
\node[point=blue!70] (Y) at (1.4, 3.6){};
\node[point=blue!70] (Y) at (1.7, 5){};
\node[point=blue!70] (Y) at (1, 4.5){};
\node[point=blue!70] (Y) at (0.4, 4.9){};
\node[point=blue!70] (Y) at (0.7, 3.7){};
\node[point=blue!70] (Y) at (2, 3.2){};
\node[point=blue!70] (Y) at (1.9, 2.5){};
\node[point=blue!70] (Y) at (2.3, 1.3){};
\node[point=blue!70] (Y) at (1.3, 0.9){};
\node[point=blue!70] (Y) at (0.4, 0.9){};
\node[point=blue!70] (Y) at (2.4, 0.4){};
\node[point=blue!70] (Y) at (0.5, 1.5){};
\node[point=blue!70] (Y) at (1.7, 1.6){};
\node[point=blue!70] (Y) at (3, 0.9){};
\node[point=blue!70] (Y) at (3.9, 1.1){};
\node[point=blue!70] (Y) at (4.8, 1.4){};
\node[point=blue!70] (Y) at (4.4, 0.6){};
\node[point=blue!70] (Y) at (5.1, 0.7){};
% Text
\node at (1.1,0.3) {Klasse 0};
\node at (4.3, 5.4) {Klasse 1};
\node at (0.6,-0.5) {\textbf{Ziel}};
\end{tikzpicture}
\hspace{1cm}% NO SPACE!
\begin{tikzpicture}[scale=0.8,cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}]
% Achsen zeichnen
\draw[->,thick] (0,0) -- (5.5,0) node[right] {}; %{$x$}
\draw[->,thick] (0,0) -- (0,5.5) node[above] {}; %{$y$}
%Punkte einzeichnen:
%Gelbe Punkte
\node[point=yellow] (Y) at (3, 3){};
\node[point=yellow] (Y) at (3.5, 2.5){};
\node[point=yellow] (Y) at (4.2, 3.3){};
\node[point=yellow] (Y) at (4.8, 4){};
\node[point=yellow] (Y) at (5, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.0){};
\node[point=yellow] (Y) at (2.7, 5){};
\node[point=yellow] (Y) at (2.5, 4.2){};
\node[point=yellow] (Y) at (4.3, 4.9){};
\node[point=yellow] (Y) at (3.7, 1.9){};
\node[point=yellow] (Y) at (5.1, 3.3){};
\node[point=yellow] (Y) at (2.7, 2){};
\node[point=yellow] (Y) at (4.2, 2.5){};
\node[point=yellow] (Y) at (4.9, 2.2){};
%Ausreißer gelb
\node[point=yellow] (Y) at (1.8, 4.3){};
%Ausreißer blau
\node[point=blue!70] (Y) at (2.7, 3.6){};
%Blaue Punkte
\node[point=blue!70] (Y) at (1, 2){};
\node[point=blue!70] (Y) at (0.8, 3){};
\node[point=blue!70] (Y) at (1.4, 3.6){};
\node[point=blue!70] (Y) at (1.7, 5){};
\node[point=blue!70] (Y) at (1, 4.5){};
\node[point=blue!70] (Y) at (0.4, 4.9){};
\node[point=blue!70] (Y) at (0.7, 3.7){};
\node[point=blue!70] (Y) at (2, 3.2){};
\node[point=blue!70] (Y) at (1.9, 2.5){};
\node[point=blue!70] (Y) at (2.3, 1.3){};
\node[point=blue!70] (Y) at (1.3, 0.9){};
\node[point=blue!70] (Y) at (0.4, 0.9){};
\node[point=blue!70] (Y) at (2.4, 0.4){};
\node[point=blue!70] (Y) at (0.5, 1.5){};
\node[point=blue!70] (Y) at (1.7, 1.6){};
\node[point=blue!70] (Y) at (3, 0.9){};
\node[point=blue!70] (Y) at (3.9, 1.1){};
\node[point=blue!70] (Y) at (4.8, 1.4){};
\node[point=blue!70] (Y) at (4.4, 0.6){};
\node[point=blue!70] (Y) at (5.1, 0.7){};
% Text
\node at (1.1,0.3) {Klasse 0};
\node at (4.3, 5.4) {Klasse 1};
\node at (1.4,-0.5) {\textbf{Overfitting}};
\end{tikzpicture}
\end{document}
- Dateianhänge
-
Liebes Forum,
ich möchte mit einer Abbildung Underfitting und Overfitting abbilden (siehe Bild). Ich bin schon eine ganze Weile am Probieren und Suchen, aber leider weiß ich nicht, wie ich eine Funktion in die Grafik bekommen, die die Punkte genau an der richtigen Stelle trennt.
[img][attachment=0]overfitting_2.png[/attachment][/img]
Online habe ich eine ähnliche Fragestellung gefunden, die allerdings nie zufriedenstellend beantwortet werden konnte: https://tex.stackexchange.com/questions/364093/plotting-overfitting-diagram
Schon im Voraus vielen Dank für eure Hilfe!
Mein aktueller Code ist unten angefügt. Das ist jetzt nicht sonderlich schön bisher und vielleicht kann mir ja jemand auch sagen, wie man das vielleicht schöner lösen kann. Super wäre wenn bei der Underfitting Grafik die Gerade noch stärker zur Geltung kommt. Weiterhin fehlen noch die Funktionen für die zweite und dritte Grafik, wobei beim Overfitting jeder Punkt richtig klassifiziert werden soll. Kann mir außerdem jemand sagen, wie ich die drei Grafiken zwar nebeneinander habe, aber dafür linksbündig mit der ersten startend?
[code]\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.10}
\usetikzlibrary{shapes.misc}
\tikzset{point/.style = {% define a style for the function points
circle,
fill=#1,
draw=black,
inner sep=4pt,
},
point/.default = {red!60}
}
\begin{document}
\begin{tikzpicture}[scale=0.8, cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}]
% Achsen zeichnen
\draw[->,thick] (0,0) -- (5.5,0) node[right] {}; %{$x$}
\draw[->,thick] (0,0) -- (0,5.5) node[above] {}; %{$y$}
%Punkte einzeichnen:
%Gelbe Punkte
\node[point=yellow] (Y) at (3, 3){};
\node[point=yellow] (Y) at (3.5, 2.5){};
\node[point=yellow] (Y) at (4.2, 3.3){};
\node[point=yellow] (Y) at (4.8, 4){};
\node[point=yellow] (Y) at (5, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.0){};
\node[point=yellow] (Y) at (2.7, 5){};
\node[point=yellow] (Y) at (2.5, 4.2){};
\node[point=yellow] (Y) at (4.3, 4.9){};
\node[point=yellow] (Y) at (3.7, 1.9){};
\node[point=yellow] (Y) at (5.1, 3.3){};
\node[point=yellow] (Y) at (2.7, 2){};
\node[point=yellow] (Y) at (4.2, 2.5){};
\node[point=yellow] (Y) at (4.9, 2.2){};
%Ausreißer gelb
\node[point=yellow] (Y) at (1.8, 4.3){};
%Ausreißer blau
\node[point=blue!70] (Y) at (2.7, 3.6){};
%Blaue Punkte
\node[point=blue!70] (Y) at (1, 2){};
\node[point=blue!70] (Y) at (0.8, 3){};
\node[point=blue!70] (Y) at (1.4, 3.6){};
\node[point=blue!70] (Y) at (1.7, 5){};
\node[point=blue!70] (Y) at (1, 4.5){};
\node[point=blue!70] (Y) at (0.4, 4.9){};
\node[point=blue!70] (Y) at (0.7, 3.7){};
\node[point=blue!70] (Y) at (2, 3.2){};
\node[point=blue!70] (Y) at (1.9, 2.5){};
\node[point=blue!70] (Y) at (2.3, 1.3){};
\node[point=blue!70] (Y) at (1.3, 0.9){};
\node[point=blue!70] (Y) at (0.4, 0.9){};
\node[point=blue!70] (Y) at (2.4, 0.4){};
\node[point=blue!70] (Y) at (0.5, 1.5){};
\node[point=blue!70] (Y) at (1.7, 1.6){};
\node[point=blue!70] (Y) at (3, 0.9){};
\node[point=blue!70] (Y) at (3.9, 1.1){};
\node[point=blue!70] (Y) at (4.8, 1.4){};
\node[point=blue!70] (Y) at (4.4, 0.6){};
\node[point=blue!70] (Y) at (5.1, 0.7){};
%Lineare - Underfitting
\draw[thick, red] (0,5.5) node[left] {} -- (5.5,1.5);
% Text
\node at (1.1,0.3) {Klasse 0};
\node at (4.3, 5.4) {Klasse 1};
\node at (1.4,-0.5) {\textbf{Underfitting}};
\end{tikzpicture}
\hspace{1cm}% NO SPACE!
\begin{tikzpicture}[scale=0.8,cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}]
% Achsen zeichnen
\draw[->,thick] (0,0) -- (5.5,0) node[right] {}; %{$x$}
\draw[->,thick] (0,0) -- (0,5.5) node[above] {}; %{$y$}
%Punkte einzeichnen:
%Gelbe Punkte
\node[point=yellow] (Y) at (3, 3){};
\node[point=yellow] (Y) at (3.5, 2.5){};
\node[point=yellow] (Y) at (4.2, 3.3){};
\node[point=yellow] (Y) at (4.8, 4){};
\node[point=yellow] (Y) at (5, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.0){};
\node[point=yellow] (Y) at (2.7, 5){};
\node[point=yellow] (Y) at (2.5, 4.2){};
\node[point=yellow] (Y) at (4.3, 4.9){};
\node[point=yellow] (Y) at (3.7, 1.9){};
\node[point=yellow] (Y) at (5.1, 3.3){};
\node[point=yellow] (Y) at (2.7, 2){};
\node[point=yellow] (Y) at (4.2, 2.5){};
\node[point=yellow] (Y) at (4.9, 2.2){};
%Ausreißer gelb
\node[point=yellow] (Y) at (1.8, 4.3){};
%Ausreißer blau
\node[point=blue!70] (Y) at (2.7, 3.6){};
%Blaue Punkte
\node[point=blue!70] (Y) at (1, 2){};
\node[point=blue!70] (Y) at (0.8, 3){};
\node[point=blue!70] (Y) at (1.4, 3.6){};
\node[point=blue!70] (Y) at (1.7, 5){};
\node[point=blue!70] (Y) at (1, 4.5){};
\node[point=blue!70] (Y) at (0.4, 4.9){};
\node[point=blue!70] (Y) at (0.7, 3.7){};
\node[point=blue!70] (Y) at (2, 3.2){};
\node[point=blue!70] (Y) at (1.9, 2.5){};
\node[point=blue!70] (Y) at (2.3, 1.3){};
\node[point=blue!70] (Y) at (1.3, 0.9){};
\node[point=blue!70] (Y) at (0.4, 0.9){};
\node[point=blue!70] (Y) at (2.4, 0.4){};
\node[point=blue!70] (Y) at (0.5, 1.5){};
\node[point=blue!70] (Y) at (1.7, 1.6){};
\node[point=blue!70] (Y) at (3, 0.9){};
\node[point=blue!70] (Y) at (3.9, 1.1){};
\node[point=blue!70] (Y) at (4.8, 1.4){};
\node[point=blue!70] (Y) at (4.4, 0.6){};
\node[point=blue!70] (Y) at (5.1, 0.7){};
% Text
\node at (1.1,0.3) {Klasse 0};
\node at (4.3, 5.4) {Klasse 1};
\node at (0.6,-0.5) {\textbf{Ziel}};
\end{tikzpicture}
\hspace{1cm}% NO SPACE!
\begin{tikzpicture}[scale=0.8,cross/.style={draw, cross out,
minimum size=2*(#1-1pt), inner sep=0pt, outer sep=0pt}]
% Achsen zeichnen
\draw[->,thick] (0,0) -- (5.5,0) node[right] {}; %{$x$}
\draw[->,thick] (0,0) -- (0,5.5) node[above] {}; %{$y$}
%Punkte einzeichnen:
%Gelbe Punkte
\node[point=yellow] (Y) at (3, 3){};
\node[point=yellow] (Y) at (3.5, 2.5){};
\node[point=yellow] (Y) at (4.2, 3.3){};
\node[point=yellow] (Y) at (4.8, 4){};
\node[point=yellow] (Y) at (5, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.7){};
\node[point=yellow] (Y) at (3.7, 4.0){};
\node[point=yellow] (Y) at (2.7, 5){};
\node[point=yellow] (Y) at (2.5, 4.2){};
\node[point=yellow] (Y) at (4.3, 4.9){};
\node[point=yellow] (Y) at (3.7, 1.9){};
\node[point=yellow] (Y) at (5.1, 3.3){};
\node[point=yellow] (Y) at (2.7, 2){};
\node[point=yellow] (Y) at (4.2, 2.5){};
\node[point=yellow] (Y) at (4.9, 2.2){};
%Ausreißer gelb
\node[point=yellow] (Y) at (1.8, 4.3){};
%Ausreißer blau
\node[point=blue!70] (Y) at (2.7, 3.6){};
%Blaue Punkte
\node[point=blue!70] (Y) at (1, 2){};
\node[point=blue!70] (Y) at (0.8, 3){};
\node[point=blue!70] (Y) at (1.4, 3.6){};
\node[point=blue!70] (Y) at (1.7, 5){};
\node[point=blue!70] (Y) at (1, 4.5){};
\node[point=blue!70] (Y) at (0.4, 4.9){};
\node[point=blue!70] (Y) at (0.7, 3.7){};
\node[point=blue!70] (Y) at (2, 3.2){};
\node[point=blue!70] (Y) at (1.9, 2.5){};
\node[point=blue!70] (Y) at (2.3, 1.3){};
\node[point=blue!70] (Y) at (1.3, 0.9){};
\node[point=blue!70] (Y) at (0.4, 0.9){};
\node[point=blue!70] (Y) at (2.4, 0.4){};
\node[point=blue!70] (Y) at (0.5, 1.5){};
\node[point=blue!70] (Y) at (1.7, 1.6){};
\node[point=blue!70] (Y) at (3, 0.9){};
\node[point=blue!70] (Y) at (3.9, 1.1){};
\node[point=blue!70] (Y) at (4.8, 1.4){};
\node[point=blue!70] (Y) at (4.4, 0.6){};
\node[point=blue!70] (Y) at (5.1, 0.7){};
% Text
\node at (1.1,0.3) {Klasse 0};
\node at (4.3, 5.4) {Klasse 1};
\node at (1.4,-0.5) {\textbf{Overfitting}};
\end{tikzpicture}
\end{document}
[/code]