{"id":3166,"date":"2026-05-11T11:14:41","date_gmt":"2026-05-11T09:14:41","guid":{"rendered":"https:\/\/labodemaths.fr\/WordPress3\/?p=3166"},"modified":"2026-05-11T11:14:43","modified_gmt":"2026-05-11T09:14:43","slug":"nsi-knn-iris-avec-csv","status":"publish","type":"post","link":"https:\/\/labodemaths.fr\/WordPress3\/nsi-knn-iris-avec-csv\/","title":{"rendered":"NSI, KNN IRIS avec CSV"},"content":{"rendered":"\n<p>compl\u00e9ter le code de ces diff\u00e9rentes fonctions<\/p>\n\n\n\n<p>avec comme fichier csv :<\/p>\n\n\n\n<p><a href=\"https:\/\/pixees.fr\/informatiquelycee\/n_site\/asset\/iris.csv\">https:\/\/pixees.fr\/informatiquelycee\/n_site\/asset\/iris.csv<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import csv\r\nliste_fleurs=&#91;]\r\nwith open('iris.csv', newline='') as csvfile:\r\n    spamreader = csv.reader(csvfile, delimiter=' ', quotechar='|')\r\n    for row in spamreader:\r\n        liste_fleurs.append(row)\r\n\r\n\r\ndef transformation(chaine):\r\n    '''\r\n    >>>transformation(\"1.4,2,0\")\r\n    &#91;1.4,2,0]\r\n    '''\r\n  \r\n\r\ndef transformation_liste(liste):\r\n    '''\r\n    transforme la liste fleurs en un liste\r\n    de dictionnaires\r\n    >>>transformation_liste(liste_fleurs)&#91;0]\r\n    {'petal_length':1.4,'petal-width':0.2,\"species\":0}\r\n    '''\r\n    \r\n    \r\n\r\n\r\n    \r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>compl\u00e9ter le code de ces diff\u00e9rentes fonctions avec comme fichier csv : https:\/\/pixees.fr\/informatiquelycee\/n_site\/asset\/iris.csv<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[57],"tags":[],"_links":{"self":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/3166"}],"collection":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/comments?post=3166"}],"version-history":[{"count":1,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/3166\/revisions"}],"predecessor-version":[{"id":3167,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/posts\/3166\/revisions\/3167"}],"wp:attachment":[{"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/media?parent=3166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/categories?post=3166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/labodemaths.fr\/WordPress3\/wp-json\/wp\/v2\/tags?post=3166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}