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
"""Kernel K-means""" | |
# Author: Mathieu Blondel <mathieu@mblondel.org> | |
# License: BSD 3 clause | |
import numpy as np | |
from sklearn.base import BaseEstimator, ClusterMixin | |
from sklearn.metrics.pairwise import pairwise_kernels | |
from sklearn.utils import check_random_state |
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
def kMedoids[T :ClassTag, U >: T :ClassTag]( | |
data: RDD[T], | |
k: Int, | |
metric: (U,U) => Double, | |
sampleSize: Int = 10000, | |
maxIterations: Int = 10, | |
resampleInterval: Int = 3 | |
): (Seq[T], Double) = { | |
val n = data.count |
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
#' @param h5File HDF5 file path | |
#' @param dataset data frame path in the HDF5 file | |
#' @examples | |
#' df <- loadhdf5data("/path/to/file.hdf5", "/path/to/dataset") | |
#' | |
loadhdf5data <- function(h5File, dataset) { | |
require(h5) # available on CRAN | |
f <- h5file(h5File) | |
nblocks <- h5attr(f[dataset], "nblocks") |