From b68bfc45dfa8281094e3453b9e44658b5512f62d Mon Sep 17 00:00:00 2001 From: Vikram Vikrant <50881531+VikramVikrant@users.noreply.github.com> Date: Wed, 12 Jun 2019 18:13:13 +0530 Subject: [PATCH] Create NearestCentroid.py --- very_simple_examples/NearestCentroid.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 very_simple_examples/NearestCentroid.py diff --git a/very_simple_examples/NearestCentroid.py b/very_simple_examples/NearestCentroid.py new file mode 100644 index 0000000..bf7fe92 --- /dev/null +++ b/very_simple_examples/NearestCentroid.py @@ -0,0 +1,16 @@ +from sklearn.neighbors.nearest_centroid import NearestCentroid + +clf = NearestCentroid() + +# height , weight, shoesize of 11 persons +X=[[180,70,8],[160,45,5],[120,60,5],[190,90,10],[200,85,11],[100,60,5],[250,150,12],[120,55,6],[140,60,7],\ + [150,70,9],[90,55,3]] + +# Gender of 11 persons of respective height,weight & shoesize +Y=['male','female','female','male','male','female','male','female','male','male','female'] + +clf = clf.fit(X,Y) + +prediction = clf.predict([[250,150,12]]) + +print(prediction)