{"id":480,"date":"2014-09-13T20:36:00","date_gmt":"2014-09-13T12:36:00","guid":{"rendered":"http:\/\/note.systw.net\/note\/?p=480"},"modified":"2023-11-02T20:38:36","modified_gmt":"2023-11-02T12:38:36","slug":"mahout-clustering","status":"publish","type":"post","link":"https:\/\/systw.net\/note\/archives\/480","title":{"rendered":"Mahout Clustering"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Canopy\u5206\u7fa4\u6f14\u7b97\u6cd5<br><strong>#mahout org.apache.mahout.clustering.syntheticcontrol.canopy.Job<br><\/strong>\u5e38\u7528\u53c3\u6578\u5982\u4e0b<br>-i: Input vector&#8217;s directory<br>-o: Output working directory<br>-dm: Distance measure<br>\u3000\u5e38\u7528\u7684dm\u9078\u9805\u5982\u4e0b<br>\u3000org.apache.mahout.common.distance.CosineDistanceMeasure<br>\u3000org.apache.mahout.common.distance.SquaredEuclideanDistanceMeasure (default)<br>-t1: T1 threshold<br>-t2: T2 threshold<br>-ow: Overwrite output directory if present<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Canopy\u6b65\u9a5f<\/strong><br>1.\u6307\u5b9a\u5169\u500b\u8ddd\u96e2\u503c,T1(\u5927\u5708)\u548cT2(\u5c0f\u5708), \u5176\u4e2dT1 &gt; T2<br>2. \u5c07dataset\u5411\u91cf\u5316\u4e26\u653e\u5165list\u4e2d<br>3. \u5f9elist\u4e2d\u4efb\u53d6\u4e00\u9edeP<br>\u5047\u5982\u6c92\u6709\u4efb\u4f55Canopy\uff0c\u5247P\u70baCanopy<br>\u5047\u5982\u9edeP\u8207\u67d0\u500bCanopy\u8ddd\u96e2\u5728T1(\u5927\u5708)\u5167,\u5247\u9edeP\u52a0\u5165\u8a72Canopy<br>\u5047\u5982\u9edeP\u8207\u67d0\u500bCanopy\u8ddd\u96e2\u5728T2(\u5c0f\u5708)\u5167,\u5247\u9edeP\u52a0\u5165\u8a72Canopy\uff0c\u4e26\u5f9elist\u4e2d\u79fb\u9664\u9edeP<br>4. \u91cd\u8986\u6b65\u9a5f2\u76f4\u5230list\u70ba\u7a7a<br>ps:<br>t1:\u5927\u5708,\u4e3b\u8981\u5f71\u97ff\u6bcf\u500bcluster\u5167\uff0c\u9ede\u7684\u6578\u91cf<br>t2:\u5c0f\u5708,\u4e3b\u8981\u5f71\u97ffcluster\u7684\u6578\u91cf\uff0c\u592a\u5927\u6703\u5c0e\u81f4\u53ea\u6709\u4e00\u500bcluser, \u592a\u5c0f\u6703\u5c0e\u81f4\u592a\u591acluster<br>ps<br>canopy\u8f03\u9069\u5408\u6c7a\u5b9a\u7fa4\u6578<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;&#8230;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">K-means\u5206\u7fa4\u6f14\u7b97\u6cd5<br><strong>#mahout org.apache.mahout.clustering.syntheticcontrol.kmeans.Job<\/strong><br>\u5e38\u7528\u53c3\u6578\u5982\u4e0b<br>-i &lt; hadoop input path &gt; : Path to job input directory.<br>-o : The directory pathname for output.<br>-dm &lt; distanceMeasure &gt;: The classname of the DistanceMeasure.<br>\u3000Default is SquaredEuclidean<br>-k &lt; number of clusters&gt; : The number of clusters to create<br>-t1 &lt; threshold value&gt; : T1 threshold value<br>-t2 &lt; threshold value&gt; : T2 threshold value<br>-x &lt; number of iterations&gt; : The maximum number of iterations.<br>-ow : If present, overwrite the output directory before running job<br>-h: Print out help<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#mahout clusterdump<\/strong><br>\u5e38\u7528\u53c3\u6578\u5982\u4e0b<br>-i &lt; hadoop input path &gt; : Path to job input directory.<br>-o : The directory pathname for output.<br>-p &lt; points Dir&gt; : The directory containing points sequence files mapping input vectors to their cluster. If specified, then the program will output the points associated with a cluster<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8f38\u51fa\u7d50\u679c<br>VL-8{n=3 c=[5.667, 5.667] r=[0.471, 0.471]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [5.000, 6.000]<br>1.0: [6.000, 5.000]<br>1.0: [6.000, 6.000]<br>\u8aaa\u660e\u5982\u4e0b<br>VL-8: Cluster name<br>n: \u9019\u500b\u7fa4\u6709\u5e7e\u500b\u9ede<br>c: the center of Cluster<br>r: the radius of the cluster<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">demo<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">test dataset<br><strong>#vi clustering.data<\/strong><br>0 1<br>1 0<br>1 1<br>2 1<br>1 2<br>2 2<br>5 6<br>6 5<br>6 6<br>9 9<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong># hadoop fs -mkdir testdata<br># hadoop fs -put clustering.data testdata<br># hadoop fs -ls -R testdata<\/strong><br>-rw-r&#8211;r&#8211; 3 root hdfs 288374 2014-02-05 21:53 testdata\/clustering.data<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">canopy\u5206\u7fa4<strong><br>#mahout org.apache.mahout.clustering.syntheticcontrol.canopy.Job -t1 3 -t2 2 -i testdata -o output<br><\/strong>&#8230;omit&#8230;<br>14\/09\/08 01:31:07 INFO clustering.ClusterDumper: Wrote 3 clusters<br>14\/09\/08 01:31:07 INFO driver.MahoutDriver: Program took 104405 ms (Minutes: 1.7400833333333334)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#hadoop fs -ls -R output<\/strong><br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 01:31 output\/clusteredPoints<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 01:31 output\/clusteredPoints\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 512 2014-09-08 01:31 output\/clusteredPoints\/part-m-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 01:30 output\/clusters-0-final<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 01:30 output\/clusters-0-final\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 202 2014-09-08 01:30 output\/clusters-0-final\/_policy<br>-rw-r&#8211;r&#8211; 3 root hdfs 649 2014-09-08 01:30 output\/clusters-0-final\/part-r-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 01:29 output\/data<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 01:29 output\/data\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 382 2014-09-08 01:29 output\/data\/part-m-00000<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#mahout clusterdump &#8211;input output\/clusters-0-final &#8211;pointsDir output\/clusteredPoints<\/strong><br>C-0{n=1 c=[9.000, 9.000] r=[]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [9.000, 9.000]<br>C-1{n=2 c=[5.833, 5.583] r=[0.167, 0.083]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [5.000, 6.000]<br>1.0: [6.000, 5.000]<br>1.0: [6.000, 6.000]<br>C-2{n=4 c=[1.313, 1.333] r=[0.345, 0.527]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [1:1.000]<br>1.0: [0:1.000]<br>1.0: [1.000, 1.000]<br>1.0: [2.000, 1.000]<br>1.0: [1.000, 2.000]<br>1.0: [2.000, 2.000]<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><br>&#8230;&#8230;&#8230;&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6307\u5b9aK-means\u5206\u62103\u7fa4<br><strong>#mahout org.apache.mahout.clustering.syntheticcontrol.kmeans.Job -k 3 -t1 3 -t2 2 -x 10 -i testdata -o output<\/strong><br>&#8230;omit&#8230;<br>14\/09\/08 00:47:53 INFO clustering.ClusterDumper: Wrote 3 clusters<br>14\/09\/08 00:47:53 INFO driver.MahoutDriver: Program took 194271 ms (Minutes: 3.23785)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#hadoop fs -ls -R output<\/strong><br>-rw-r&#8211;r&#8211; 3 root hdfs 194 2014-09-08 00:47 output\/_policy<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:47 output\/clusteredPoints<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 00:47 output\/clusteredPoints\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 512 2014-09-08 00:47 output\/clusteredPoints\/part-m-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:45 output\/clusters-0<br>-rw-r&#8211;r&#8211; 3 root hdfs 194 2014-09-08 00:45 output\/clusters-0\/_policy<br>-rw-r&#8211;r&#8211; 3 root hdfs 332 2014-09-08 00:45 output\/clusters-0\/part-00000<br>-rw-r&#8211;r&#8211; 3 root hdfs 332 2014-09-08 00:45 output\/clusters-0\/part-00001<br>-rw-r&#8211;r&#8211; 3 root hdfs 332 2014-09-08 00:45 output\/clusters-0\/part-00002<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:46 output\/clusters-1<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 00:46 output\/clusters-1\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 194 2014-09-08 00:46 output\/clusters-1\/_policy<br>-rw-r&#8211;r&#8211; 3 root hdfs 689 2014-09-08 00:46 output\/clusters-1\/part-r-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:46 output\/clusters-2<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 00:46 output\/clusters-2\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 194 2014-09-08 00:46 output\/clusters-2\/_policy<br>-rw-r&#8211;r&#8211; 3 root hdfs 698 2014-09-08 00:46 output\/clusters-2\/part-r-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:47 output\/clusters-3-final<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 00:47 output\/clusters-3-final\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 194 2014-09-08 00:47 output\/clusters-3-final\/_policy<br>-rw-r&#8211;r&#8211; 3 root hdfs 698 2014-09-08 00:47 output\/clusters-3-final\/part-r-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:45 output\/data<br>-rw-r&#8211;r&#8211; 3 root hdfs 0 2014-09-08 00:45 output\/data\/_SUCCESS<br>-rw-r&#8211;r&#8211; 3 root hdfs 382 2014-09-08 00:45 output\/data\/part-m-00000<br>drwxr-xr-x &#8211; root hdfs 0 2014-09-08 00:45 output\/random-seeds<br>-rw-r&#8211;r&#8211; 3 root hdfs 551 2014-09-08 00:45 output\/random-seeds\/part-randomSeed<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>#mahout clusterdump &#8211;input output\/clusters-3-final &#8211;pointsDir output\/clusteredPoints<br><\/strong>VL-8{n=3 c=[5.667, 5.667] r=[0.471, 0.471]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [5.000, 6.000]<br>1.0: [6.000, 5.000]<br>1.0: [6.000, 6.000]<br>VL-9{n=1 c=[9.000, 9.000] r=[]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [9.000, 9.000]<br>VL-6{n=6 c=[1.167, 1.167] r=[0.687, 0.687]}<br>Weight : [props &#8211; optional]: Point:<br>1.0: [1:1.000]<br>1.0: [0:1.000]<br>1.0: [1.000, 1.000]<br>1.0: [2.000, 1.000]<br>1.0: [1.000, 2.000]<br>1.0: [2.000, 2.000]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Canopy\u5206\u7fa4\u6f14\u7b97\u6cd5#mahout org.apache. &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"","fifu_image_alt":"","_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-480","post","type-post","status-publish","format-standard","hentry","category-dataanalysis"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":463,"url":"https:\/\/systw.net\/note\/archives\/463","url_meta":{"origin":480,"position":0},"title":"K-means","author":"raymond","date":"2011 \u5e74 6 \u6708 20 \u65e5","format":false,"excerpt":"k-means\u512a\u9ede:\u7c21\u55ae\u6709\u6548\u7387,\u4efb\u4e00\u6f14\u7b97\u6cd5\u6240\u5f97\u4e4b\u7d50\u679c,\u90fd\u53ef\u900f\u904e\u6b64\u65b9\u6cd5\u9032\u884c\u6539\u5584\u7f3a\u9ede:1\u5404\u7fa4\u7684\u8cc7\u6599\u5206\u4f48\u9808\u2026","rel":"","context":"\u5728\u300c\u6578\u64da\u5206\u6790\u300d\u4e2d","block_context":{"text":"\u6578\u64da\u5206\u6790","link":"https:\/\/systw.net\/note\/archives\/category\/dataanalysis"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":461,"url":"https:\/\/systw.net\/note\/archives\/461","url_meta":{"origin":480,"position":1},"title":"Clustering","author":"raymond","date":"2011 \u5e74 6 \u6708 20 \u65e5","format":false,"excerpt":"clustering(\u5206\u7fa4)\u7121\u4e2d\u751f\u6709:\u4e00\u958b\u59cb\u6c92\u6709\u660e\u986f\u7684\u7fa4,\u662f\u6563\u4e82\u7684\u8cc7\u6599unsupserised le\u2026","rel":"","context":"\u5728\u300c\u6578\u64da\u5206\u6790\u300d\u4e2d","block_context":{"text":"\u6578\u64da\u5206\u6790","link":"https:\/\/systw.net\/note\/archives\/category\/dataanalysis"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":564,"url":"https:\/\/systw.net\/note\/archives\/564","url_meta":{"origin":480,"position":2},"title":"Graph","author":"raymond","date":"2007 \u5e74 3 \u6708 5 \u65e5","format":false,"excerpt":"\u57fa\u672c\u540d\u8a5eeulerian path(\u5c24\u62c9\u8def\u5f91),eulerian cycle(\u5c24\u62c9\u8ff4\u8def)\uff1a\u5f9e\u67d0\u9ede\u51fa\u767c\u2026","rel":"","context":"\u5728\u300c\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5\u300d\u4e2d","block_context":{"text":"\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5","link":"https:\/\/systw.net\/note\/archives\/category\/develop\/algorithm"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":566,"url":"https:\/\/systw.net\/note\/archives\/566","url_meta":{"origin":480,"position":3},"title":"Search","author":"raymond","date":"2007 \u5e74 3 \u6708 15 \u65e5","format":false,"excerpt":"\u975c\u614b\u641c\u5c0b\u6cd5\u5c0d\u975c\u614b\u6a94\u6848(\u7528\u5faa\u5e8f\u8868\u793a\u6cd5\u5132\u5b58)\u9032\u884c\u641c\u5c0b \u5faa\u5e8f\u641c\u5c0b\u6cd5\u6642\u9593\u8907\u96dc\u5ea6\u6700\u5dee\u6700\u597d\u60c5\u6cc1\u7686\u70babigO(N)\u2026","rel":"","context":"\u5728\u300c\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5\u300d\u4e2d","block_context":{"text":"\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5","link":"https:\/\/systw.net\/note\/archives\/category\/develop\/algorithm"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":554,"url":"https:\/\/systw.net\/note\/archives\/554","url_meta":{"origin":480,"position":4},"title":"Algorithms Design","author":"raymond","date":"2007 \u5e74 3 \u6708 15 \u65e5","format":false,"excerpt":"\u6f14\u7b97\u6cd5\u8a2d\u8a08\u65b9\u6cd5\u9010\u6b65\u6539\u826f\u6cd5:\u53ea\u4f7f\u7528\u5faa\u5e8f,\u9078\u64c7,\u91cd\u8986\u4e09\u6b65\u9a5f\u8a2d\u8a08\u5207\u5272\u5f81\u670d\u6cd5:\u5c07\u554f\u984c\u5207\u5272,\u5728\u4ee5\u76f8\u540c\u65b9\u5f0f\u8655\u7406,\u2026","rel":"","context":"\u5728\u300c\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5\u300d\u4e2d","block_context":{"text":"\u8cc7\u6599\u7d50\u69cb\u8207\u6f14\u7b97\u6cd5","link":"https:\/\/systw.net\/note\/archives\/category\/develop\/algorithm"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":784,"url":"https:\/\/systw.net\/note\/archives\/784","url_meta":{"origin":480,"position":5},"title":"Cisco IGRP and EIGRP","author":"raymond","date":"2008 \u5e74 10 \u6708 5 \u65e5","format":false,"excerpt":"IGRP(Interior Gateway Routing Protocol,\u5167\u90e8\u9598\u9053\u8def\u7531\u5354\u5b9a)19\u2026","rel":"","context":"\u5728\u300cOSI Layer3\u300d\u4e2d","block_context":{"text":"OSI Layer3","link":"https:\/\/systw.net\/note\/archives\/category\/network\/osi-layer3"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/comments?post=480"}],"version-history":[{"count":0,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/posts\/480\/revisions"}],"wp:attachment":[{"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/media?parent=480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/categories?post=480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/systw.net\/note\/wp-json\/wp\/v2\/tags?post=480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}