Zum Inhalt springen

Datei:Naive Bayes Classifier.gif

Aus MOOCsWiki Staging
Originaldatei (451 × 359 Pixel, Dateigröße: 1,02 MB, MIME-Typ: image/gif, Endlosschleife, 60 Bilder, 30 s)

Diese Datei stammt aus Wikimedia Commons und kann von anderen Projekten verwendet werden. Die Beschreibung von deren Dateibeschreibungsseite wird unten angezeigt.

Beschreibung

Beschreibung
English: A "Naive Bayes Classifier" is a simple and computationally inexpensive way to estimate how likely it is that a certain combination of features can be attributed to a given class. As more measurements are fed to the classifier, the estimate is updated.
Datum
Quelle https://twitter.com/j_bertolotti/status/1123268194758811648
Urheber Jacopo Bertolotti
Genehmigung
(Weiternutzung dieser Datei)
https://twitter.com/j_bertolotti/status/1030470604418428929

Mathematica 11.0 code

n = 20;
red[z_] := {Opacity[z], Red};
purple[z_] := {Opacity[z], Purple};
cyan[z_] := {Opacity[z], Cyan}
pop1 = RandomVariate[MultinormalDistribution[{3, 4}, {{1, 1}, {1, 2}}], n];
pop2 = RandomVariate[MultinormalDistribution[{6, 4}, {{0.5, 0}, {0, 1}}], n];
pop3 = RandomVariate[MultinormalDistribution[{6, 8}, {{2, 0}, {0, 0.5}}], n];

meas = RandomSample[Join[pop1, pop2, pop3]];
meascol = Table[Which[MemberQ[pop1, meas[[j]]], 1, MemberQ[pop2, meas[[j]]], 2, MemberQ[pop3, meas[[j]]], 3], {j, 1, Dimensions[meas][[1]]}]
plots = Table[
   p1 = Count[meascol[[1 ;; j]], 1]/j;
   \[Mu]x1 = Mean@Extract[meas, Position[meascol[[1 ;; j]], 1]][[All, 1]];
   \[Mu]y1 = Mean@Extract[meas, Position[meascol[[1 ;; j]], 1]][[All, 2]];
   \[Sigma]x1 = Sqrt[Total[(Extract[meas, Position[meascol[[1 ;; j]], 1]][[All, 1]] - \[Mu]x1)^2]/(p1*j)];
   \[Sigma]y1 = Sqrt[Total[(Extract[meas, Position[meascol[[1 ;; j]], 1]][[All, 2]] - \[Mu]y1)^2]/(p1*j)];
   p1x = If[\[Sigma]x1 == 0, 0, PDF[NormalDistribution[\[Mu]x1, \[Sigma]x1], x]];
   p1y = If[\[Sigma]y1 == 0, 0, PDF[NormalDistribution[\[Mu]y1, \[Sigma]y1], y]];
   p2 = Count[meascol[[1 ;; j]], 2]/j;
   \[Mu]x2 = Mean@Extract[meas, Position[meascol[[1 ;; j]], 2]][[All, 1]];
   \[Mu]y2 = Mean@Extract[meas, Position[meascol[[1 ;; j]], 2]][[All, 2]];
   \[Sigma]x2 = Sqrt[Total[(Extract[meas, Position[meascol[[1 ;; j]], 2]][[All, 1]] - \[Mu]x2)^2]/(p2*j)];
   \[Sigma]y2 = Sqrt[Total[(Extract[meas, Position[meascol[[1 ;; j]], 2]][[All, 2]] - \[Mu]y2)^2]/(p2*j)];
   p2x = If[\[Sigma]x2 == 0, 0, PDF[NormalDistribution[\[Mu]x2, \[Sigma]x2], x]];
   p2y = If[\[Sigma]y2 == 0, 0, PDF[NormalDistribution[\[Mu]y2, \[Sigma]y2], y]];
   p3 = Count[meascol[[1 ;; j]], 3]/j;
   \[Mu]x3 = Mean@Extract[meas, Position[meascol[[1 ;; j]], 3]][[All, 1]];
   \[Mu]y3 = Mean@Extract[meas, Position[meascol[[1 ;; j]], 3]][[All, 2]];
   \[Sigma]x3 = Sqrt[Total[(Extract[meas, Position[meascol[[1 ;; j]], 3]][[All, 1]] - \[Mu]x3)^2]/(p3*j)];
   \[Sigma]y3 = Sqrt[Total[(Extract[meas, Position[meascol[[1 ;; j]], 3]][[All, 2]] - \[Mu]y3)^2]/(p3*j)];
   p3x = If[\[Sigma]x3 == 0, 0, PDF[NormalDistribution[\[Mu]x3, \[Sigma]x3], x]];
   p3y = If[\[Sigma]y3 == 0, 0, PDF[NormalDistribution[\[Mu]y3, \[Sigma]y3], y]];
   Legended[Show[
   ContourPlot[p1*p1x*p1y, {x, 0, 10}, {y, 0, 10}, ColorFunction -> red, PlotRange -> All, PlotPoints -> 50] ,
     ContourPlot[p2*p2x*p2y, {x, 0, 10}, {y, 0, 10}, ColorFunction -> purple, PlotRange -> All, PlotPoints -> 50] ,
     ContourPlot[p3*p3x*p3y, {x, 0, 10}, {y, 0, 10}, ColorFunction -> cyan, PlotRange -> All, PlotPoints -> 50]
     ,
     Graphics[{PointSize[0.02], Black, Point[Join[Extract[meas, Position[meascol[[1 ;; j]], 1]], Extract[meas, Position[meascol[[1 ;; j]], 2]], Extract[meas, Position[meascol[[1 ;; j]], 3]]]], 
       PointSize[0.015], Red, Point[Extract[meas, Position[meascol[[1 ;; j]], 1]]], Purple, Point[Extract[meas, Position[meascol[[1 ;; j]], 2]]], Cyan, Point[Extract[meas, Position[meascol[[1 ;; j]], 3]]]}]
     , PlotRange -> All, FrameLabel -> {"Feature 1", "Feature 2"}, LabelStyle -> {Bold, Black}
     ], SwatchLegend[{Red, Purple, Cyan}, {"Class Lucas", "Class B", "Class C"}] ]
   , {j, 1, n*3}];

Lizenz

Ich, der Urheber dieses Werkes, veröffentliche es unter der folgenden Lizenz:
Creative Commons CC-Zero Diese Datei wird unter der Creative-Commons-Lizenz CC0 1.0 Verzicht auf das Copyright zur Verfügung gestellt.
Die Person, die das Werk mit diesem Dokument verbunden hat, übergibt dieses weltweit der Gemeinfreiheit, indem sie alle Urheberrechte und damit verbundenen weiteren Rechte – im Rahmen der jeweils geltenden gesetzlichen Bestimmungen – aufgibt. Das Werk kann – selbst für kommerzielle Zwecke – kopiert, modifiziert und weiterverteilt werden, ohne hierfür um Erlaubnis bitten zu müssen.

Kurzbeschreibungen

Ergänze eine einzeilige Erklärung, was diese Datei darstellt.
A Naive Bayes Classifier updating its estimate while more data is fed to it.

In dieser Datei abgebildete Objekte

Motiv

Einige Werte ohne einen Wikidata-Eintrag

image/gif

1.069.957 Byte

30 Sekunde

359 Pixel

451 Pixel

adaf0563867cb1a9c7bf679867dee2d9f8d94271

Dateiversionen

Klicke auf einen Zeitpunkt, um diese Version zu laden.

Version vomVorschaubildMaßeBenutzerKommentar
aktuell10:46, 1. Mai 2019Vorschaubild der Version vom 10:46, 1. Mai 2019451 × 359 (1,02 MB)wikimediacommons>BertoUser created page with UploadWizard

Die folgende Seite verwendet diese Datei:

Metadaten