sigmoid_kernel#
- sklearn.metrics.pairwise.sigmoid_kernel(X, Y=None, gamma=None, coef0=1)[源代码]#
计算 X 和 Y 之间的 sigmoid 核。
K(X, Y) = tanh(gamma <X, Y> + coef0)
在用户指南中了解更多。
- 参数:
- X{类数组, 稀疏矩阵} 形状为 (n_samples_X, n_features)
特征数组。
- Y{类数组, 稀疏矩阵} 形状为 (n_samples_Y, n_features), 默认为 None
可选的第二个特征数组。如果为
None
,则使用Y=X
。- gamma浮点数, 默认为 None
向量内积的系数。如果为 None,则默认为 1.0 / n_features。
- coef0浮点数, 默认为 1
添加到缩放内积的常数偏移量。
- 返回:
- kernel形状为 (n_samples_X, n_samples_Y) 的 ndarray
两个数组之间的 Sigmoid 核。
示例
>>> from sklearn.metrics.pairwise import sigmoid_kernel >>> X = [[0, 0, 0], [1, 1, 1]] >>> Y = [[1, 0, 0], [1, 1, 0]] >>> sigmoid_kernel(X, Y) array([[0.76, 0.76], [0.87, 0.93]])