{"id":62,"date":"2013-02-20T18:23:38","date_gmt":"2013-02-20T23:23:38","guid":{"rendered":"http:\/\/www.jsylvest.com\/blog\/?p=62"},"modified":"2013-04-26T12:37:15","modified_gmt":"2013-04-26T17:37:15","slug":"computational-cartography-part-2","status":"publish","type":"post","link":"https:\/\/www.jsylvest.com\/blog\/2013\/02\/computational-cartography-part-2\/","title":{"rendered":"Computational Cartography (Part 2)"},"content":{"rendered":"<p>In the previous post I talked a bit about how one might build a system which would <a href=\"http:\/\/www.jsylvest.com\/blog\/2013\/02\/computational-cartography-part-1\/\">algorithmically divide the US into 50 states of approximately equal populations<\/a>.<\/p>\n<p>I've messed around with the problem a bit and developed a very rough approximation. Actually, I don't even feel comfortable calling this an approximation. But it is at least the scaffolding you could build an eventual solution around.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-after.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-53\" alt=\"auto sized states - after\" src=\"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-after.png?resize=960%2C720\" width=\"960\" height=\"720\" srcset=\"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-after.png?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-after.png?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-after.png?w=1114&amp;ssl=1 1114w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n<p>It imports the relevant data from the Census (after a lot of PitA data cleaning) and throws it up on the screen, connecting neighboring counties. Then it picks 50 random counties to be the centers of the states and runs a k-means update on them (weighted by the county populations) to iterate to a better solution. The only wrinkle to a basic clustering is that it uses the population of a state to set a z-coordinate value for each centroid when determining the distance to each point. States with more people in them are represented higher up, making them effectively smaller.<\/p>\n<p>The image above is what you end up with; here's where the system started:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-before.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-52\" alt=\"auto sized states - before\" src=\"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-before.png?resize=960%2C720\" width=\"960\" height=\"720\" srcset=\"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-before.png?resize=1024%2C768&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-before.png?resize=300%2C225&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/auto-sized-states-before.png?w=1114&amp;ssl=1 1114w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><\/p>\n<p>The ratio of the most populous state to the least in America now is 66:1. As simple as this system is, some of the runs I tested on got that ratio down to 11:1.<\/p>\n<p>There's a thousand things to do to this to make it an actual solution to the problem of automatically re-drawing state boundaries. I need to do things from the small (<a href=\"http:\/\/www.johndcook.com\/lat_long_details.html\">use spherical geometry to accurately calculate the distance between pairs of lat\/long coordinates<\/a>), to the medium (link AK\/HI\/PR to the mainland better), to the major (balance state populations more explicitly). Nevertheless, I think this is a useful framework in to build some intelligent decision making on top of.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous post I talked a bit about how one might build a system which would algorithmically divide the US into 50 states of approximately equal populations. I've messed around with the problem a bit and developed a very &hellip; <a href=\"https:\/\/www.jsylvest.com\/blog\/2013\/02\/computational-cartography-part-2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_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":[10],"tags":[18],"class_list":["post-62","post","type-post","status-publish","format-standard","hentry","category-cs","tag-projects","wpautop"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3sddF-10","jetpack-related-posts":[{"id":34,"url":"https:\/\/www.jsylvest.com\/blog\/2013\/02\/computational-cartography-part-1\/","url_meta":{"origin":62,"position":0},"title":"Computational Cartography (Part 1)","author":"jsylvest","date":"17 February 2013","format":false,"excerpt":"In the sixth grade my Social Studies teacher lent me a book which had a whole section devoted to alternative maps of the US. What would it look like with a dozen states? Or 200? What if state lines were drawn according to climate and vegetation patterns, or ancestral ethnicities,\u2026","rel":"","context":"In &quot;CS \/ Science \/ Tech \/ Coding&quot;","block_context":{"text":"CS \/ Science \/ Tech \/ Coding","link":"https:\/\/www.jsylvest.com\/blog\/category\/cs\/"},"img":{"alt_text":"The United States redrawn as Fifty States with Equal Population","src":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/map-50-equal-states-1024x789.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/map-50-equal-states-1024x789.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/map-50-equal-states-1024x789.jpg?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/02\/map-50-equal-states-1024x789.jpg?resize=700%2C400 2x"},"classes":[]},{"id":885,"url":"https:\/\/www.jsylvest.com\/blog\/2014\/01\/latitude-longitude-distance\/","url_meta":{"origin":62,"position":1},"title":"Latitude-Longitude Distance","author":"jsylvest","date":"20 January 2014","format":false,"excerpt":"Updated: I noticed a floating point error when using this that I discuss correcting at the end of this post. I thought I would post some of the bite-sized coding pieces I've done recently. To lead off, here's\u00a0Ruby function to find the distance between two points given their latitude and\u2026","rel":"","context":"In &quot;CS \/ Science \/ Tech \/ Coding&quot;","block_context":{"text":"CS \/ Science \/ Tech \/ Coding","link":"https:\/\/www.jsylvest.com\/blog\/category\/cs\/"},"img":{"alt_text":"Protip: You can win every exchange just by being one level more precise than whoever talked last. Eventually, you'll defeat all conversational opponents and stand alone.","src":"https:\/\/i1.wp.com\/imgs.xkcd.com\/comics\/actually.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":515,"url":"https:\/\/www.jsylvest.com\/blog\/2013\/05\/kaggle-black-box\/","url_meta":{"origin":62,"position":2},"title":"Kaggle Black Box","author":"jsylvest","date":"31 May 2013","format":false,"excerpt":"This is the second machine learning competition hosted at Kaggle that I've gotten serious about entering and sunk time into only to be derailed by a paper deadline. I'm pretty frustrated. Since I didn't get a chance to submit anything for the contest itself, I'm going to outline the approach\u2026","rel":"","context":"In &quot;Business \/ Economics&quot;","block_context":{"text":"Business \/ Economics","link":"https:\/\/www.jsylvest.com\/blog\/category\/business-2\/"},"img":{"alt_text":"An SOM of macroeconomic features. From Sarlin, \"Exploiting the self-organizing financial stability map,\" 2013.","src":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/05\/SOM-Sarlin-2013.jpg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/05\/SOM-Sarlin-2013.jpg?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/05\/SOM-Sarlin-2013.jpg?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/05\/SOM-Sarlin-2013.jpg?resize=700%2C400 2x"},"classes":[]},{"id":63,"url":"https:\/\/www.jsylvest.com\/blog\/2013\/03\/computational-cartography-gerrymandering\/","url_meta":{"origin":62,"position":3},"title":"Computational Cartography &#038; Gerrymandering","author":"jsylvest","date":"5 March 2013","format":false,"excerpt":"My brief recent dabbling with computational cartography (see Part 1 & Part 2) was inspired by Neil Freeman. His project was initiated as a (speculative) reform to the Electoral College. Incidentally, this is a great idea. Every four years when whichever party looses the White House starts complaining about how\u2026","rel":"","context":"In &quot;CS \/ Science \/ Tech \/ Coding&quot;","block_context":{"text":"CS \/ Science \/ Tech \/ Coding","link":"https:\/\/www.jsylvest.com\/blog\/category\/cs\/"},"img":{"alt_text":"boston-red-sox-world-series-trophy","src":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2013\/03\/boston-red-sox-world-series-trophy-200x300.jpg?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1126,"url":"https:\/\/www.jsylvest.com\/blog\/2017\/11\/ais-one-trick-pony-has-a-hell-of-a-trick\/","url_meta":{"origin":62,"position":4},"title":"AI's \"one trick pony\" has a hell of a trick","author":"jsylvest","date":"10 November 2017","format":false,"excerpt":"The MIT Technology Review has a recent article by James Somers about error backpropagation, \"Is AI Riding a One-Trick Pony?\" Overall, I agree with the message in the article. We need to keep thinking of new paradigms because the SotA right now is very useful, but not correct in any\u2026","rel":"","context":"In &quot;CS \/ Science \/ Tech \/ Coding&quot;","block_context":{"text":"CS \/ Science \/ Tech \/ Coding","link":"https:\/\/www.jsylvest.com\/blog\/category\/cs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":1144,"url":"https:\/\/www.jsylvest.com\/blog\/2017\/12\/malconv\/","url_meta":{"origin":62,"position":5},"title":"MalConv: Lessons learned from Deep Learning on executables","author":"jsylvest","date":"8 December 2017","format":false,"excerpt":"I don't usually write up my technical work here, mostly because I spend enough hours as is doing technical writing. But a co-author, Jon Barker, recently wrote\u00a0a post on the NVIDIA Parallel For All blog about one of our papers on neural networks for detecting malware, so I thought I'd\u2026","rel":"","context":"In &quot;CS \/ Science \/ Tech \/ Coding&quot;","block_context":{"text":"CS \/ Science \/ Tech \/ Coding","link":"https:\/\/www.jsylvest.com\/blog\/category\/cs\/"},"img":{"alt_text":"The MalConv architecture","src":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2017\/12\/malconv.png?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2017\/12\/malconv.png?resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jsylvest.com\/blog\/wp-content\/uploads\/2017\/12\/malconv.png?resize=525%2C300 1.5x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/posts\/62","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/comments?post=62"}],"version-history":[{"count":5,"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/posts\/62\/revisions"}],"predecessor-version":[{"id":377,"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/posts\/62\/revisions\/377"}],"wp:attachment":[{"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/media?parent=62"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/categories?post=62"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jsylvest.com\/blog\/wp-json\/wp\/v2\/tags?post=62"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}