Last active
December 25, 2015 03:59
-
-
Save ottadini/6913696 to your computer and use it in GitHub Desktop.
Code and data for Super-organised som using kohonen package
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEPTH | Strat | MEAS_TC | GR | SP | LN | SN | NEUT | |
---|---|---|---|---|---|---|---|---|
88.0872 | Boisdale Formation | 2.78 | 66.5766474766635 | 59.1810903609045 | 33.7436448559876 | 19.7536103778765 | 257.0368012729 | |
96.012 | Boisdale Formation | 1.49 | 54.7505195826885 | 49.0477497329406 | 184.145977437229 | 139.079797489143 | 326.800134003894 | |
96.1644 | Boisdale Formation | 1.49 | 55.5411398043229 | 49.1289016073479 | 183.588534123696 | 138.027677512105 | 327.473945839365 | |
142.0367 | Tambo River Formation | 2.201275709 | 62.0449186292617 | 18.2403310337942 | 19.2038626516248 | 10.7474792741976 | 494.416136250187 | |
142.1891 | Tambo River Formation | 2.201275709 | 61.8744774871462 | 18.2155224379773 | 19.1800937852543 | 10.7244616233215 | 494.740941830979 | |
151.0284 | Gippsland Limestone Formation | 1.276476312 | 14.9961159237259 | 9.33776939549743 | 14.1606094244497 | 19.0690215694105 | 363.002021309839 | |
151.1808 | Gippsland Limestone Formation | 1.276476312 | 15.0205158738082 | 9.30627807118255 | 14.1655436529726 | 19.0953021764089 | 363.592835920731 | |
156.5148 | Tambo River Formation | 2.4162441005 | 43.785062332152 | 65.9385510407827 | 11.5964588279339 | 13.1929031148605 | 142.583172944641 | |
156.6672 | Tambo River Formation | 2.4162441005 | 43.607290645435 | 66.2962310687366 | 11.5462659711476 | 13.1725547197125 | 142.672765831378 | |
186.0803 | Tambo River Formation | 1.921269188 | 45.6044196675485 | 11.4624082463934 | 8.45766575151001 | 7.89023557130734 | 580.953081046274 | |
189.1284 | Tambo River Formation | 1.97156569 | 25.1788971746618 | 58.0230314531024 | 23.1363341386712 | 16.7864369839764 | NA | |
198.12 | Gippsland Limestone Formation | 1.383553608 | 22.6473057654869 | 20.0256307342884 | 5.72385854839515 | 6.14916432386562 | 351.235402865272 | |
201.6256 | Alberton Coal Measures | 1.445952736 | 55.1186066340538 | 7.40355556831228 | 15.1829971646783 | 21.8662902460939 | 269.653737892477 | |
205.74 | Lake Wellington Formation | 1.52 | 71.856189337593 | 12.2242026905606 | 32.5356786053013 | 30.5186764039335 | 438.731212489393 | |
213.0552 | Tambo River Formation | 2.2935333401 | 29.2484507911945 | 46.9966323466281 | 15.2804591873409 | 26.0980478310787 | 218.94749020616 | |
229.0571 | Lake Wellington Formation | 2.5 | 61.0877456546698 | 54.3419358758049 | 677.230792177907 | 612.77788867868 | 652.625927354864 | |
251.9171 | Balook Formation | 0.64087119 | 18.6552184345829 | 62.2352142764438 | 36.2521973543653 | 53.3669068736585 | 369.365409808815 | |
252.0695 | Balook Formation | 0.64087119 | 17.7135600259572 | 62.4159865821395 | 35.375735431538 | 50.8950422952129 | 357.925140298507 | |
253.8983 | Balook Formation | 0.385947844 | 7.77231195527379 | 63.8458523336494 | 32.5103850696351 | 32.0263246593121 | 271.286443942495 | |
258.0131 | Gippsland Limestone Formation | 2.03793771 | 30.1249052513353 | 5.23020864573454 | 8.19467770678381 | 11.0905359656567 | 633.679673468776 | |
258.1655 | Gippsland Limestone Formation | 2.03793771 | 30.0621201916837 | 5.18182523835671 | 8.1890828483003 | 11.0922388009784 | 636.484116258174 | |
284.0736 | Gippsland Limestone Formation | 1.46771308 | 23.2607618080168 | 19.1022623121849 | 3.91294784106225 | 3.97802695053162 | 362.450067453701 | |
284.8354 | Balook Formation | 0.40269163 | 72.6786366495283 | 68.4743653222183 | 25.4590015873808 | 48.3201379823292 | 436.936612813857 | |
284.9879 | Balook Formation | 0.40269163 | 73.071421494534 | 68.7921091349273 | 24.8287733689412 | 46.7665612639146 | 433.008662392053 | |
302.2092 | Gippsland Limestone Formation | 1.392509116 | 70.7269778465532 | 41.4401012329656 | 5.50503149802825 | 15.9211157589977 | 366.085909324614 | |
302.3616 | Gippsland Limestone Formation | 1.392509116 | 70.6778478111117 | 41.4146436429891 | 5.51328901312834 | 16.0326811960266 | 366.038342594719 | |
305.1048 | Gippsland Limestone Formation | 1.6174233406 | 42.3284504367793 | 69.0546678330754 | 3.7847212100035 | 5.76535603753806 | 200.584895083113 | |
305.2572 | Gippsland Limestone Formation | 1.6174233406 | 42.2617018120102 | 69.2539206209754 | 3.78166806269655 | 5.70821072230819 | 200.497027010433 | |
318.3635 | Balook Formation | 2.609252971 | 20.5714891928318 | 57.9892412419508 | 197.790587111266 | 138.19360832127 | 648.773878031248 | |
319.4304 | Yallourn Formation | 0.2235356445 | 75.2159515299755 | 22.753348669695 | 9.94953666450356 | 15.2304497828583 | 282.425807647382 | |
334.0607 | Balook Formation | 0.3631319758 | 63.6933628662707 | 69.302598332751 | 17.460914780612 | 19.6460906803774 | 418.89785683622 | |
352.6536 | Yallourn Formation | 2.378127107 | 142.781463540159 | 21.6965235062147 | 12.165576773324 | 18.012915519393 | 384.763275585284 | |
355.0919 | Gippsland Limestone Formation | 1.16 | 45.9373695752009 | 66.0543728198473 | 198.390204886936 | 197.085359312135 | 451.899490091349 | |
376.1231 | Gippsland Limestone Formation | 1.87 | 45.2868446712924 | 72.210660959417 | 190.435652623172 | 102.286170483702 | 465.536607213098 | |
378.1044 | Gippsland Limestone Formation | 1.403089408 | 31.0901807268008 | 48.2081560325463 | 10.4006980482204 | 8.23444587929916 | NA | |
381.9143 | Morwell Formation | 0.4326676052 | 39.325489422453 | 19.2292291469076 | 12.6526682174412 | 20.9942337443219 | 286.220718165028 | |
403.5552 | Latrobe Valley Group | 0.3 | 32.0193406429392 | 69.8259528428094 | 49.9426814755653 | 37.6393666300604 | 325.225987705286 | |
404.7743 | Balook Formation | 0.6492229691 | 58.6384613038487 | 60.5267182498877 | 10.8622819797334 | 16.7460904158139 | 398.220959152399 | |
420.6239 | Gippsland Limestone Formation | 1.436901122 | 34.8007069485349 | 7.97608722108521 | 2.5938476413917 | 7.14810843608046 | 625.376341756102 | |
420.7763 | Gippsland Limestone Formation | 1.436901122 | 34.8742061698198 | 8.26912028652723 | 2.60002379074527 | 7.17981523985424 | 625.31649983028 | |
456.1331 | Gippsland Limestone Formation | 1.81 | 45.8342050915989 | 66.4673607248041 | 191.120848435082 | 194.130335426546 | 504.071694479109 | |
470.9162 | Gippsland Limestone Formation | 1.8408241097 | 36.5557098038237 | 18.2051499026606 | 3.9017289422453 | 7.14137823591075 | 571.332185324215 | |
480.0599 | Lakes Entrance Formation | 1.125049954 | 44.6383914840513 | 30.7098148255379 | 2.0190964907902 | 1.5174894573953 | 304.095327544551 | |
496.0619 | Gippsland Limestone Formation | 1.58 | 48.4255251984226 | 68.3492212848799 | 212.214801712175 | 193.322116597614 | 511.632332276743 | |
496.5192 | Gippsland Limestone Formation | 1.164978411 | 73.2301902361104 | 70.3566299655568 | 2.69355128038736 | 8.31646460839614 | 359.494454275446 | |
498.0432 | Gippsland Limestone Formation | 1.577592194 | 39.6159791643788 | 83.5195778565367 | 2.5150642989068 | 4.21759262716518 | 200.999566200769 | |
498.1956 | Gippsland Limestone Formation | 1.577592194 | 39.5984559377028 | 83.645464084261 | 2.52055918234912 | 4.23794877452204 | 201.754323975441 | |
512.064 | Morwell Formation | 1.0757232769 | 69.0050748564868 | 47.620624429691 | NA | NA | 491.10608213947 | |
515.1119 | Lakes Entrance Formation | 1.998817651 | 32.0479482204363 | 53.4167524634353 | 8.24095057155693 | 8.81284022363101 | NA | |
515.1119 | Gippsland Limestone Formation | 1.62 | 43.2870254530026 | 66.6972422652623 | 209.868867488644 | 202.460775894774 | 524.035687590476 | |
517.0931 | Balook Formation | 0.9089973511 | 94.1580520391354 | 56.8078079668547 | 13.6135553187241 | 17.6556962961114 | 477.043885364149 | |
526.5418 | Balook Formation | 1.542020952 | 47.1857838117107 | 47.1495124744172 | 119.009299316128 | 112.299021449608 | 588.376263465282 | |
526.6942 | Balook Formation | 1.542020952 | 45.3437986122897 | 47.1400406329556 | 121.001848674687 | 113.581410337942 | 593.550364892927 | |
537.0575 | Gippsland Limestone Formation | 1.74 | 41.6988720311486 | 57.9189062047621 | 273.819437183647 | 343.546833584585 | 563.667697968352 | |
551.0784 | Morwell Formation | 2.2719153572 | 37.8603725752508 | 70.1911149453402 | NA | NA | 804.109601148106 | |
557.0219 | Gippsland Limestone Formation | 2.14 | 43.9704667698298 | 60.9794385164478 | 246.367573209205 | 398.027844102231 | 702.57653065442 | |
557.1743 | Gippsland Limestone Formation | 2.14 | 44.1353968402137 | 61.0692560325463 | 242.629098522438 | 393.357490096341 | 705.122148020766 | |
564.4898 | Gippsland Limestone Formation | 2.35 | 33.311785493935 | 22.6285800379374 | 5.37050102331154 | 13.1310373184246 | 825.187063160785 | |
564.6422 | Gippsland Limestone Formation | 2.35 | 33.1946621374732 | 22.5904674686767 | 5.37638791993211 | 13.273289547247 | 826.870665961164 | |
585.3683 | Traralgon Formation | 1.7919621455 | 37.6552516148355 | 31.0679118404632 | 10.4655424000399 | 21.6087915988619 | 361.253803559127 | |
587.3495 | Traralgon Formation | 1.2584445947 | 46.8324455598263 | 31.6708273748315 | 9.2921735536365 | 17.2375013028503 | 305.390904277941 | |
591.312 | Traralgon Formation | 0.8004630629 | 46.3839800429292 | 30.1464777766685 | 9.13230877552039 | 16.897216976988 | 316.141635311736 | |
591.7692 | Gippsland Limestone Formation | 1.0143186872 | 44.3985807517596 | 95.8982154545001 | 2.01615478959717 | 2.25364157140718 | 192.849247162182 | |
591.9216 | Gippsland Limestone Formation | 1.0143186872 | 44.8331167273998 | 95.9678935955673 | 2.00907004442669 | 2.26856420905506 | 192.687260959417 | |
593.1407 | Latrobe Group | 2.113019773 | 82.2541965706584 | 55.0542892776918 | 9.63346328557879 | 10.9037828183497 | NA | |
597.1032 | Gippsland Limestone Formation | 1.172381458 | 81.3245477262517 | 79.6383711226477 | 1.42451198522438 | 6.94567657365347 | 292.356754105726 | |
611.7338 | Lakes Entrance Formation | 2.3027417594 | 42.4642665452004 | 29.8285126042031 | 2.67682656616583 | 4.51531312334648 | 517.72357698797 | |
611.8862 | Lakes Entrance Formation | 2.3027417594 | 42.4077825687615 | 29.8086347027405 | 2.67328485498927 | 4.46855647681326 | 518.006828038736 | |
615.0864 | Morwell Formation | 1.2761209538 | 60.6924198772026 | 53.7504692157939 | NA | NA | 724.362289372536 | |
627.1259 | Gippsland Limestone Formation | 2.55 | 44.49549218789 | 50.3806529676035 | 381.90959767883 | 489.62932487895 | 750.990897334398 | |
627.583 | Balook Formation | 1.706923516 | 62.8921117755703 | 48.508464927869 | 28.5716268506963 | 55.052302281236 | 480.021832711027 | |
666.1404 | Morwell Formation | 2.0551797162 | 159.578990261069 | 28.2331720810662 | 5.97841690211152 | 9.50628186492288 | 406.575022413018 | |
666.2928 | Morwell Formation | 2.0551797162 | 159.688669031099 | 28.2121452004193 | 5.98802055608246 | 9.51660268057704 | 405.345835596266 | |
667.6644 | Morwell Formation | 1.9526669129 | 157.371368357211 | 28.0688615684121 | 6.01160003993411 | 9.39654949333599 | 395.021151280387 | |
670.1027 | Latrobe Group | 1.627701269 | 58.425377681825 | 64.5971262017671 | 68.1553955423551 | 44.8418088803474 | NA | |
679.2467 | Gippsland Limestone Formation | 2.08037051 | 37.159758508461 | 50.9658912294714 | 2.18385140518145 | 2.99534756651525 | 792.499069230769 | |
679.3991 | Gippsland Limestone Formation | 2.08037051 | 37.1816386362502 | 51.0703448609794 | 2.17802797384316 | 2.99812502371088 | 790.577917386313 | |
726.0336 | Lakes Entrance Formation | 1.4279931065 | 82.0737721809015 | 101.996183317526 | 1.00429909149903 | 1.44889097489143 | 139.15790625468 | |
726.186 | Lakes Entrance Formation | 1.4279931065 | 81.9103698397644 | 102.056680047921 | 0.99944049817801 | 1.44635558827934 | 139.678433614536 | |
736.0919 | Latrobe Group | 2.841289998 | 37.67355270304 | 66.9821558678181 | 48.6798487096291 | 26.8820770229122 | NA | |
765.5052 | Lakes Entrance Formation | 2.4058353887 | 108.190542734488 | 78.7379951829481 | 13.1353054410223 | 22.7170769280687 | 241.182989277692 | |
793.5468 | Traralgon Formation | 2.1433788755 | 138.455188279339 | 74.571063744821 | 11.199321579394 | 19.4273762142465 | 206.962017740728 | |
829.2084 | Traralgon Formation | 0.5925952449 | 72.7229438226925 | 76.5690954375281 | 14.1003592971597 | 22.4402029401488 | 169.850751130634 | |
861.06 | Traralgon Formation | 2.9431006605 | 124.125018219937 | 89.2426474517047 | 13.388700633954 | 11.8456178056207 | 168.33118754555 | |
884.2247 | Lakes Entrance Formation | 1.056196456 | 66.1458076274148 | 61.2381892627166 | 0.87738795986622 | 1.43816681475565 | 534.097776034543 | |
896.112 | Strzelecki Group | 2.5976619421 | 105.109537073828 | 75.9623454849498 | 28.6919680676883 | 29.8414002246294 | 244.088586482304 | |
916.0763 | Lakes Entrance Formation | 1.19471082 | 71.0313223880597 | 63.9749344831029 | 1.28450150252084 | 1.36613600559078 | 579.578425717566 | |
918.0576 | Latrobe Valley Group | 0.524775902 | 55.2900679828283 | 57.5266260719812 | 10.3368836869166 | 12.9281067638397 | 448.80069589677 | |
929.0305 | Strzelecki Group | 1.5756765105 | 99.3677378874856 | 95.1784444666301 | 2.53685565816403 | 3.20795043677931 | 161.615136879149 | |
929.1828 | Strzelecki Group | 1.5756765105 | 99.2805945889283 | 95.1937807367843 | 2.51754491089702 | 3.20444465631708 | 161.636925827385 | |
943.0511 | Lakes Entrance Formation | 1.596954282 | 82.3486520541107 | 62.7541383567114 | 2.44082772924674 | 2.66152610692358 | 667.633979189337 | |
957.9865 | Strzelecki Group | 1.5188727509 | 106.117325403085 | 95.1265984076274 | 6.88304571457096 | 9.50771743123846 | 288.998781974742 | |
972.0071 | Traralgon Formation | 0.357331514 | 6.53849361553436 | 51.9399600808666 | 9.62947761693206 | 12.9241570658414 | 340.605310602506 | |
972.1595 | Traralgon Formation | 0.357331514 | 7.26506386961513 | 51.8563356511756 | 9.63836681475566 | 12.8549534468128 | 341.531938711127 | |
980.3892 | Latrobe Group | 2.700383159 | 44.6946210103329 | 36.7597703389408 | 63.5348578794989 | 41.8583299505815 | NA | |
989.838 | Strzelecki Group | 1.9411699146 | 115.993450571557 | 103.025301702191 | 4.2675044426696 | 6.1742323416363 | 283.478722477911 | |
998.0675 | Traralgon Formation | 2.805973987 | 22.4982295961663 | 81.2905666051016 | 28.922360220636 | 25.1813263365447 | 968.76858513952 | |
1003.0967 | Strzelecki Group | 1.93356525 | 34.8155520341437 | 44.6389200718814 | 3.20546467828084 | 4.67846613587581 | NA | |
1017.1176 | Strzelecki Group | 1.6420730283 | 106.890062491888 | 105.570072949633 | 6.63301503020017 | 8.0884325213398 | 325.950583302551 | |
1018.032 | Strzelecki Group | 1.7689419617 | 105.271128792492 | 105.413613173264 | 6.76195415564319 | 8.3727877302451 | 333.578358558379 | |
1018.1844 | Strzelecki Group | 1.7689419617 | 104.85968324265 | 105.389880741776 | 6.77764859481855 | 8.40835130035442 | 335.134861154096 | |
1064.5139 | Traralgon Formation | 2.135293288 | 28.6634065941197 | 75.395405765487 | 25.9785416862177 | 22.5457075725054 | 797.405700209654 | |
1064.6664 | Latrobe Group | 2.057521497 | 92.5261324015374 | 33.5282936105426 | 26.3456089602156 | 20.9127412918684 | NA | |
1320.8508 | Strzelecki Group | 2.17 | NA | 33.4829953327011 | 6.18419811810513 | 7.05380755753007 | NA | |
1325.1178 | Strzelecki Group | 1.67230229 | 89.2512924674288 | 40.5946538062197 | 2.86023003544152 | 4.82691577896471 | NA | |
1391.1071 | Strzelecki Group | 2.22120439 | 64.0077726301602 | 24.7265477961364 | 28.587085409075 | 22.1108723007038 | NA | |
1457.0962 | Strzelecki Group | 2.422861376 | 72.6308140168721 | 30.9414468626766 | 36.6549009833774 | 25.7824783107872 | NA | |
1523.0854 | Strzelecki Group | 1.841129558 | 87.2403668097639 | 41.765577871512 | 10.1749952528328 | 9.91219571706684 | NA | |
1590.1415 | Strzelecki Group | 2.241884758 | 71.5059732491389 | 21.0752344980782 | 36.8510548894324 | 26.5392710327959 | NA | |
1664.0554 | Strzelecki Group | 2.376636135 | 70.1406779463885 | 29.5525730544601 | 45.8336223131833 | 30.7107481904857 | NA | |
1769.059 | Strzelecki Group | 2.332302939 | 69.8057630987068 | 29.7466261321563 | 40.3067053545061 | 29.404412778366 | NA | |
1775.9172 | Strzelecki Group | 2.41 | NA | 48.9011219338092 | 31.7000225477961 | 20.273409459392 | NA | |
2085.8989 | Strzelecki Group | 1.97 | NA | 68.9193438426596 | 13.7331188439075 | 10.0015165876304 | NA | |
3211.5254 | Strzelecki Group | 2.22 | NA | 142.854339290171 | 61.8065366844706 | 21.8417693355963 | NA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(kohonen) | |
library(sqldf) | |
# Load data, available at https://gist.github.com/ottadini/6913696 | |
somdata <- read.csv("ssomdata.csv") | |
# This data also includes a depth marker (which can be ignored), and classifications by way of Stratigraphy. Strat is not a defining label for the target variable MEAS_TC, but is a guide at least. | |
# Create SCALED test and training sets from data: | |
unscale.cols <- c("Strat", "DEPTH") | |
scale.cols <- setdiff(colnames(somdata), c("Strat", "DEPTH")) | |
scaledsom <- somdata | |
scaledsom[, scale.cols] <- scale(somdata[, scale.cols]) | |
inTrain <- sample(nrow(scaledsom), nrow(scaledsom)*(2/3)) | |
training <- scaledsom[inTrain, ] | |
testing <- scaledsom[-inTrain, ] | |
# Following the examples in Wehrens and Buydens, 2007, 21(5), J Stat Soft. | |
# Super-organised kohonen map, requiring data in a list of data frames | |
# So ugly all this wrangling | |
somX <- list() | |
somX$training <- as.matrix(training[, -c(1, 2, 3)]) # exclude Strat, DEPTH, MEAS_TC | |
somX$Strat <- as.matrix(training[, "Strat"]) | |
somX$MeasTC <- as.matrix(training[, "MEAS_TC"]) | |
somXtest <- list() | |
somXtest$newdata <- as.matrix(testing[, -c(1, 2, 3)]) | |
somXtest$Strat <- as.matrix(testing[, "Strat"]) | |
somXtest$MeasTC <- as.matrix(testing[, "MEAS_TC"]) | |
ssom <- supersom(data=somX, whatmap=1, contin=TRUE, rlen=500, | |
grid=somgrid(5, 5, "hexagonal")) | |
# Figure 1. Mapping of all observations | |
plot(ssom, type="mapping", pch=1) | |
ssom.prediction <- predict(ssom, newdata=somXtest$newdata, | |
trainY=somX$MeasTC) | |
predictions <- ssom.prediction$prediction | |
observed <- somXtest$MeasTC | |
fit <- lm(predictions ~ observed) | |
plot(predictions ~ observed) | |
abline(fit) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment