Skip to content

Instantly share code, notes, and snippets.

View keuv-grvl's full-sized avatar

Keuv Grvl keuv-grvl

  • Bordeaux, France
View GitHub Profile
@mblondel
mblondel / kernel_kmeans.py
Last active January 4, 2024 11:45
Kernel K-means.
"""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
@erikerlandson
erikerlandson / kmedoids.scala
Created January 6, 2015 19:12
A k-medoids implementation for Spark RDDs
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
@Enchufa2
Enchufa2 / loadhdf5data.R
Created May 9, 2017 15:52
Load a Python/pandas data frame from an HDF5 file into R
#' @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")