In cluster analysis, the k-means algorithm can be used to partition the input data set into k partitions (clusters). The current dataset include core and well log measurements and K-means was used to predict the vertical discrete Facies sequence in a well in sandstone formation.

Install the packages required to implement K-means algorithm with their functions.

require(MASS)
## Loading required package: MASS
require(fpc)
## Loading required package: fpc
require(Rcmdr)
## Loading required package: Rcmdr
## Loading required package: splines
## Loading required package: RcmdrMisc
## Loading required package: car
## Loading required package: sandwich
## The Commander GUI is launched only in interactive sessions
require(cluster)
## Loading required package: cluster
library(MASS)
library(Rcmdr)
library(fpc)
library(cluster)

Call the dataset and visualize it: -

##    depth caliper ind.deep ind.med  gamma phi.N R.deep  R.med      SP
## 1 5667.0   8.685  618.005 569.781 98.823 0.410  1.618  1.755 -56.587
## 2 5667.5   8.686  497.547 419.494 90.640 0.307  2.010  2.384 -61.916
## 3 5668.0   8.686  384.935 300.155 78.087 0.203  2.598  3.332 -55.861
## 4 5668.5   8.686  278.324 205.224 66.232 0.119  3.593  4.873 -41.860
## 5 5669.0   8.686  183.743 131.155 59.807 0.069  5.442  7.625 -34.934
## 6 5669.5   8.686  109.512  75.633 57.109 0.048  9.131 13.222 -39.769
##   density.corr density phi.core   k.core
## 1       -0.033   2.205  33.9000 2442.590
## 2       -0.067   2.040  33.4131 3006.989
## 3       -0.064   1.888  33.1000 3370.000
## 4       -0.053   1.794  34.9000 2270.000
## 5       -0.054   1.758  35.0644 2530.758
## 6       -0.058   1.759  35.3152 2928.314

Prepare Data by listwise deletion of missing in addition to standardize variables :

##       depth   caliper   ind.deep    ind.med     gamma     phi.N     R.deep
## 1 -1.715835 0.5760810  1.3474389  1.2181334 2.3964234  2.570248 -0.6508649
## 2 -1.711672 0.5852006  0.8737459  0.6005397 1.9644806  1.167356 -0.6397151
## 3 -1.707509 0.5852006  0.4309067  0.1101246 1.3018655 -0.249157 -0.6229904
## 4 -1.703345 0.5852006  0.0116661 -0.2799876 0.6760947 -1.393263 -0.5946892
## 5 -1.699182 0.5852006 -0.3602674 -0.5843689 0.3369486 -2.074279 -0.5420973
## 6 -1.695018 0.5852006 -0.6521758 -0.8125326 0.1945336 -2.360306 -0.4371695
##        R.med         SP density.corr    density phi.core      k.core
## 1 -0.7059954 -1.5377911    -1.422375  0.8253632 1.526011 0.085294626
## 2 -0.6831533 -1.8577737    -3.427612 -0.4936933 1.419359 0.337753183
## 3 -0.6487268 -1.4941980    -3.250679 -1.7088241 1.350777 0.500130034
## 4 -0.5927655 -0.6535007    -2.601926 -2.4602866 1.745053 0.008094151
## 5 -0.4928268 -0.2376254    -2.660904 -2.7480807 1.781063 0.124732644
## 6 -0.2895722 -0.5279455    -2.896814 -2.7400864 1.835999 0.302561390

Determine number of clusters that are derived from the dataset through K-means and Partitioning Around Medoids:

## number of clusters estimated by optimum average silhouette width: 5

## silhouette-optimal number of clusters: 5

It was noticeable that the number of facies that can be derived from the given dataset are Five Facies. Now we adopt K-Means Clustering Algorithm to predict the discrete sequence of the five facies distrbution.

## $cluster
##   1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18 
##   2   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
## 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 
##   1   1   1   1   1   1   2   2   2   2   2   2   2   2   2   2   2   2 
## 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 
##   2   2   1   1   1   1   1   1   1   1   2   2   2   2   2   2   2   2 
## 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   3   1   1   1 
## 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   3   3   3 
## 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   2   2   2 
## 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   4   3 
## 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   2   2   2   2 
## 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 
##   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2   2 
## 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 
##   2   2   2   2   2   2   2   4   4   4   4   4   4   3   3   3   3   3 
## 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 
##   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3   3 
## 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 
##   3   3   3   3   3   3   3   4   4   4   4   4   4   4   4   4   4   4 
## 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 
##   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5   5 
## 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 
##   5   4   4   4   4   4   4   5   5   5   4   4   4   4   4   4   4   4 
## 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 
##   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4   4 
## 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 
##   4   4   4   4   5   5   5   5   5   5   5   5   5   5   5   5   5   5 
## 811 812 813 814 815 816 817 818 819 
##   5   5   5   4   4   4   4   4   4 
## 
## $centers
##        depth    caliper    ind.deep    ind.med       gamma      phi.N
## 1 -1.3159021  0.4681551 -0.88842264 -0.9248661 -0.05383081 -1.8733059
## 2 -0.6354768  1.0052187  0.06306484  0.1651123  1.15778722  0.4849125
## 3  0.1696191 -0.7965027 -0.98085607 -1.0156080 -0.84206089  0.2325962
## 4  1.2027821 -0.5234476  1.20484192  1.1475601 -0.19455217  0.4176434
## 5  1.2265050 -0.5882669  1.75323048  1.7728310 -1.14660486  0.4035138
##       R.deep      R.med          SP density.corr    density    phi.core
## 1  0.3244141  0.4382221 -0.90978060  -1.57851676 -1.4559977  0.80671775
## 2 -0.5757210 -0.6336317  0.26662821   0.80744088  1.2354105 -1.24781792
## 3  1.1728269  1.2261746 -0.08672092  -0.06107041 -0.4522229  0.63534171
## 4 -0.6450433 -0.7004089  0.29047931   0.19263719  0.1178305  0.06297222
## 5 -0.6573654 -0.7181433  0.63786100   0.20349333 -0.2901632  0.77008611
##       k.core
## 1  0.2190921
## 2 -0.6863142
## 3  0.8672108
## 4 -0.5407442
## 5  1.5601515
## 
## $totss
## [1] 10634
## 
## $withinss
## [1]  474.2580 1293.8665 1185.8267  409.5618  189.2156
## 
## $tot.withinss
## [1] 3552.729
## 
## $betweenss
## [1] 7081.271

Then get cluster means and append cluster assignment with the standerized dataset.

##   Group.1      depth    caliper    ind.deep    ind.med       gamma
## 1       1 -1.3159021  0.4681551 -0.88842264 -0.9248661 -0.05383081
## 2       2 -0.6354768  1.0052187  0.06306484  0.1651123  1.15778722
## 3       3  0.1696191 -0.7965027 -0.98085607 -1.0156080 -0.84206089
## 4       4  1.2027821 -0.5234476  1.20484192  1.1475601 -0.19455217
## 5       5  1.2265050 -0.5882669  1.75323048  1.7728310 -1.14660486
##        phi.N     R.deep      R.med          SP density.corr    density
## 1 -1.8733059  0.3244141  0.4382221 -0.90978060  -1.57851676 -1.4559977
## 2  0.4849125 -0.5757210 -0.6336317  0.26662821   0.80744088  1.2354105
## 3  0.2325962  1.1728269  1.2261746 -0.08672092  -0.06107041 -0.4522229
## 4  0.4176434 -0.6450433 -0.7004089  0.29047931   0.19263719  0.1178305
## 5  0.4035138 -0.6573654 -0.7181433  0.63786100   0.20349333 -0.2901632
##      phi.core     k.core
## 1  0.80671775  0.2190921
## 2 -1.24781792 -0.6863142
## 3  0.63534171  0.8672108
## 4  0.06297222 -0.5407442
## 5  0.77008611  1.5601515
##       depth   caliper   ind.deep    ind.med     gamma     phi.N     R.deep
## 1 -1.715835 0.5760810  1.3474389  1.2181334 2.3964234  2.570248 -0.6508649
## 2 -1.711672 0.5852006  0.8737459  0.6005397 1.9644806  1.167356 -0.6397151
## 3 -1.707509 0.5852006  0.4309067  0.1101246 1.3018655 -0.249157 -0.6229904
## 4 -1.703345 0.5852006  0.0116661 -0.2799876 0.6760947 -1.393263 -0.5946892
## 5 -1.699182 0.5852006 -0.3602674 -0.5843689 0.3369486 -2.074279 -0.5420973
## 6 -1.695018 0.5852006 -0.6521758 -0.8125326 0.1945336 -2.360306 -0.4371695
##        R.med         SP density.corr    density phi.core      k.core
## 1 -0.7059954 -1.5377911    -1.422375  0.8253632 1.526011 0.085294626
## 2 -0.6831533 -1.8577737    -3.427612 -0.4936933 1.419359 0.337753183
## 3 -0.6487268 -1.4941980    -3.250679 -1.7088241 1.350777 0.500130034
## 4 -0.5927655 -0.6535007    -2.601926 -2.4602866 1.745053 0.008094151
## 5 -0.4928268 -0.2376254    -2.660904 -2.7480807 1.781063 0.124732644
## 6 -0.2895722 -0.5279455    -2.896814 -2.7400864 1.835999 0.302561390
##   fit.cluster
## 1           2
## 2           1
## 3           1
## 4           1
## 5           1
## 6           1

The, plot the optimal five facies:

Visualizing the box plot and distribution of the predicted discrete five Facies.

References

Al-Mudhafar, W. & Bondereko, M. Integrating K-Means Clustering Analysis and General- ized Additive Model for Efficient Reservoir Characterization. Paper presented at the 77th EAGE Conference & Exhibition Incorporating SPE EUROPIC, Madrid, Spain, 1-4 June 2015.

Al-Mudhafar, W. & Zein Al-Abideen, M. Integration Clustering Analysis & Support Vector Machines for Predicting Continuous Electrofacies Posterior Distribution. In Proceedings of Near Surface Geoscience–20th European Meeting of Environmental and Engineering Geophysics, Athens, Greece, 14-18 September 2014.

Karpur, L., L. Lake, and K. Sepehrnoori. (2000). Probability Logs for Facies Classification. In Situ 24(1): 57.