Python Sklearn extra:KMedoids缺失';方法';参数

Python Sklearn extra:KMedoids缺失';方法';参数,python,scikit-learn,Python,Scikit Learn,根据,KMEDOID应具有以下参数:n_集群,度量,方法,init,max_iter和随机状态。方法参数确定要使用哪种算法:alternate或pam。根据sklearn_extra的研究,这些方法本质上是不同的。对于我的特定应用程序,我希望使用PAM版本的K-medoids。但是,方法参数似乎已消失。在KMedoids函数上运行检查时: import inspect from sklearn_extra.cluster import KMedoids inspect.getargspec(KM

根据,KMEDOID应具有以下参数:
n_集群
度量
方法
init
max_iter
随机状态
方法
参数确定要使用哪种算法:
alternate
pam
。根据sklearn_extra的研究,这些方法本质上是不同的。对于我的特定应用程序,我希望使用PAM版本的K-medoids。但是,
方法
参数似乎已消失。在KMedoids函数上运行检查时:

import inspect
from sklearn_extra.cluster import KMedoids
inspect.getargspec(KMedoids)
我得到以下输出:

ArgSpec(args=['self', 'n_clusters', 'metric', 'init', 'max_iter', 'random_state'], varargs=None, 
keywords=None, defaults=(8, 'euclidean', 'heuristic', 300, None))

这里也缺少
方法
参数。最后,它似乎还在那里。有人知道参数到哪里去了吗?我在互联网上找不到任何相关信息。

最新开发版本中提供了
方法
参数。因此,请卸载现有版本,并直接从github使用以下工具安装最新版本:

pip install https://github.com/scikit-learn-contrib/scikit-learn-extra/archive/master.zip
样本(如文档所示): 输出:

array([0, 0, 0, 1, 1, 1])

最新的Github版本(以及相应的文档)与最新版本(当前日期为2020年3月29日)之间似乎存在差异

如果我们使用
pip
从PyPi安装

pip install scikit-learn-extra
然后用

print(inspect.getsource(KMedoids))
这实际上给出了我们机器中包的源代码,我们得到

class KMedoids(BaseEstimator, ClusterMixin, TransformerMixin):
    """k-medoids clustering.

    Read more in the :ref:`User Guide <k_medoids>`.

    Parameters
    ----------
    n_clusters : int, optional, default: 8
        The number of clusters to form as well as the number of medoids to
        generate.

    metric : string, or callable, optional, default: 'euclidean'
        What distance metric to use. See :func:metrics.pairwise_distances

    init : {'random', 'heuristic', 'k-medoids++'}, optional, default: 'heuristic'
        Specify medoid initialization method. 'random' selects n_clusters
        elements from the dataset. 'heuristic' picks the n_clusters points
        with the smallest sum distance to every other point. 'k-medoids++'
        follows an approach based on k-means++_, and in general, gives initial
        medoids which are more separated than those generated by the other methods.
        
        .. _k-means++: https://theory.stanford.edu/~sergei/papers/kMeansPP-soda.pdf

    max_iter : int, optional, default : 300
        Specify the maximum number of iterations when fitting.

    random_state : int, RandomState instance or None, optional
        Specify random state for the random number generator. Used to
        initialise medoids when init='random'.
i、 e.
方法
参数确实无处可寻

从Github安装:

pip install git+https://github.com/scikit-learn-contrib/scikit-learn-extra.git

确实给予

FullArgSpec(args=['self', 'n_clusters', 'metric', 'method', 'init', 'max_iter', 'random_state'], varargs=None, varkw=None, defaults=(8, 'euclidean', 'alternate', 'heuristic', 300, None), kwonlyargs=[], kwonlydefaults=None, annotations={})
有趣的是,在这两种情况下(PyPi和Github),报告的版本完全相同(
0.1.0b2
);就软件开发良好实践而言,这里似乎出了一些问题

pip install git+https://github.com/scikit-learn-contrib/scikit-learn-extra.git
inspect.getfullargspec(KMedoids)
FullArgSpec(args=['self', 'n_clusters', 'metric', 'method', 'init', 'max_iter', 'random_state'], varargs=None, varkw=None, defaults=(8, 'euclidean', 'alternate', 'heuristic', 300, None), kwonlyargs=[], kwonlydefaults=None, annotations={})