嵌入
圖形嵌入算法。
屬性embedding_
指派一個向量給圖形的每個節點。
光譜
- 類別 sknetwork.embedding.Spectral(n_components: int = 2, decomposition: str = 'rw', regularization: float = -1, normalized: bool = True)[原始碼]
圖形的光譜嵌入,根據拉普拉斯矩陣 \(L = D - A\) 或隨機漫步的轉移矩陣 \(P = D^{-1}A\) (預設值) 的光譜分解,其中 \(D\) 是度數的對角矩陣。
特徵向量會按照特徵值的遞增順序 (適用於拉普拉斯矩陣 \(L\)) 或遞減順序 (適用於隨機漫步的轉移矩陣 \(P\)) 加以考量,跳過第一個特徵向量。
- 參數:
n_components (int (預設 =
2
)) – 嵌入空間的維度。decomposition (str (
laplacian
或rw
,預設值 =rw
)) – 用於光譜分解的矩陣。regularization (float (預設值 =
-1
)) – 正則化因子 \(\alpha\),使得鄰接矩陣為 \(A + \alpha \frac{11^T}{n}\)。如果為負值,僅當圖形中斷時,才會套用正則化;正則化因子 \(\alpha\) 隨即設定為該參數的絕對值。normalized (bool (預設值 =
True
)) – 如果True
,會將嵌入正規化,以便每個向量的嵌入空間規範為 1,亦即每個向量都位於單位球面上。
- 變量:
embedding (array, shape = (n, n_components)) – 節點的嵌入式。
embedding_row (array, shape = (n_row, n_components)) – 二部圖的列嵌入式。
embedding_col (array, shape = (n_col, n_components)) – 二部圖的欄嵌入式。
eigenvalues (array, shape = (n_components)) – 特徵值。
eigenvectors (array, shape = (n, n_components)) – 特徵向量。
範例
>>> from sknetwork.embedding import Spectral >>> from sknetwork.data import karate_club >>> spectral = Spectral(n_components=3) >>> adjacency = karate_club() >>> embedding = spectral.fit_transform(adjacency) >>> embedding.shape (34, 3)
參考
Belkin, M. & Niyogi, P. (2003). Laplacian Eigenmaps for Dimensionality Reduction and Data Representation, Neural computation.
- fit(input_matrix: csr_matrix | ndarray, force_bipartite: bool = False) Spectral [source]
計算影像嵌入式。
如果輸入矩陣 \(B\) 不是正方形(例如,二部圖的二鄰接矩陣)或非對稱(例如,有向圖的鄰接矩陣),請使用鄰接矩陣
\(A = \begin{bmatrix} 0 & B \\ B^T & 0 \end{bmatrix}\)
並傳回輸入矩陣 \(B\) 的列和欄的嵌入式。
- 參數:
input_matrix – 圖的鄰接矩陣或二鄰接矩陣。
force_bipartite (bool (預設值 =
False
)) – 如果True
,強制將輸入矩陣視為二鄰接矩陣。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(columns: bool = False) ndarray
傳回節點的嵌入。
- 參數:
columns (bool) – 若為
True
,傳回欄位的預測值。- 傳回:
embedding_ – 節點的嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- transform() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
SVD
- 類別 sknetwork.embedding.SVD(n_components=2, regularization: 無 | 浮點數 = 無, factor_singular: 浮點數 = 0.0, normalized: 布林值 = 錯誤, solver: 字串 | SVDSolver = 'lanczos')[原始碼]
圖形鄰接或雙鄰接矩陣奇異值分解的圖形嵌入。
- 參數:
n_components (整數) – 嵌入的維度。
regularization (
無
或者浮點數(預設為無
)) – 正則化因子 \(\alpha\),使矩陣為 \(A + \alpha \frac{11^T}{n}\)。factor_singular (浮點數 (預設值 = 0.)) –
應用於右奇異向量對奇異值的冪因子 \(\alpha\)。列和欄的嵌入分別為 \(U \Sigma^{1-\alpha}\) 和 \(V \Sigma^\alpha\),其中:
\(U\) 是左奇異向量的矩陣,形狀為 (n_row, n_components)
\(V\) 是右奇異向量的矩陣,形狀為 (n_col, n_components)
\(\Sigma\) 是奇異對角矩陣值,形狀為 (n_components, n_components)
normalized(布林值,預設=
False
)-若True
,會正規化嵌入,以使得嵌入空間中每一個向量的範數為 1,亦即每個向量都在單位球上。solver (
'lanczos'
(Lanczos 演算法,預設)或SVDSolver
(自訂解算器))-使用哪個解算器。
- 變量:
embedding (array, shape = (n, n_components)) – 節點的嵌入式。
embedding_row (array, shape = (n_row, n_components)) – 二部圖的列嵌入式。
embedding_col (array, shape = (n_col, n_components)) – 二部圖的欄嵌入式。
singular_values(np.ndarray,形狀 =(n_components))-奇異值。
singular_vectors_left(np.ndarray,形狀 =(n_row,n_components))-左奇異向量。
singular_vectors_right(np.ndarray,形狀 =(n_col,n_components))-右奇異向量。
範例
>>> from sknetwork.embedding import SVD >>> from sknetwork.data import karate_club >>> svd = SVD() >>> adjacency = karate_club() >>> embedding = svd.fit_transform(adjacency) >>> embedding.shape (34, 2)
參考
Abdi, H. (2007)。奇異值分解(SVD)與廣義奇異值分解(GSVD)。測量與統計百科全書。
- fit(input_matrix: csr_matrix | ndarray) GSVD
計算圖形的嵌入。
- 參數:
input_matrix – 圖的鄰接矩陣或二鄰接矩陣。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(adjacency_vectors: csr_matrix | ndarray) ndarray
預測新列的嵌入,這些列是由其鄰接向量定義。
- 參數:
adjacency_vectors -節點的鄰接向量。形狀為 (n_col,) 的陣列(單一向量)或 (n_vectors, n_col)
- 傳回:
embedding_vectors – 節點嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- transform() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
GSVD
- class sknetwork.embedding.GSVD(n_components=2, regularization: None | float = None, factor_row: float = 0.5, factor_col: float = 0.5, factor_singular: float = 0.0, normalized: bool = True, solver: str | SVDSolver = 'lanczos')[來源]
圖形嵌入採用鄰接矩陣或雙鄰接矩陣 \(A\) 的廣義奇異值分解。這等同於矩陣 \(D_1^{- \alpha_1}AD_2^{- \alpha_2}\) 的奇異值分解,其中 \(D_1, D_2\) 分別是行權重和列權重的對角矩陣,而 \(\alpha_1, \alpha_2\) 則為參數。
- 參數:
n_components (整數) – 嵌入的維度。
regularization (
無
或者浮點數(預設為無
)) – 正則化因子 \(\alpha\),使矩陣為 \(A + \alpha \frac{11^T}{n}\)。factor_row (float (預設 = 0.5)) – 應用於行權重對角矩陣的冪因子 \(\alpha_1\)。
factor_col (float (預設 = 0.5)) – 應用於列權重對角矩陣的冪因子 \(\alpha_2\)。
factor_singular (浮點數 (預設值 = 0.)) –
應用於右奇異向量上奇異值的參數 \(\alpha\)。行和列的嵌入分別為 \(D_1^{- \alpha_1}U \Sigma^{1-\alpha}\) 及 \(D_2^{- \alpha_2}V \Sigma^\alpha\),其中
\(U\) 是左奇異向量的矩陣,形狀為 (n_row, n_components)
\(V\) 是右奇異向量的矩陣,形狀為 (n_col, n_components)
\(\Sigma\) 是奇異對角矩陣值,形狀為 (n_components, n_components)
normalized (bool (預設值 =
True
)) – 如果True
,會將嵌入正規化,以便每個向量的嵌入空間規範為 1,亦即每個向量都位於單位球面上。solver (
'lanczos'
(Lanczos 演算法,預設)或SVDSolver
(自訂解算器))-使用哪個解算器。
- 變量:
embedding (array, shape = (n, n_components)) – 節點的嵌入式。
embedding_row (array, shape = (n_row, n_components)) – 二部圖的列嵌入式。
embedding_col (array, shape = (n_col, n_components)) – 二部圖的欄嵌入式。
singular_values(np.ndarray,形狀 =(n_components))-奇異值。
singular_vectors_left(np.ndarray,形狀 =(n_row,n_components))-左奇異向量。
singular_vectors_right(np.ndarray,形狀 =(n_col,n_components))-右奇異向量。
weights_col (np.ndarray, shape = (n2)) – 應用於列的權重。
範例
>>> from sknetwork.embedding import GSVD >>> from sknetwork.data import karate_club >>> gsvd = GSVD() >>> adjacency = karate_club() >>> embedding = gsvd.fit_transform(adjacency) >>> embedding.shape (34, 2)
參考
Abdi, H. (2007). 奇異值分解 (SVD) 和廣義奇異值分解。測量與統計百科全書,907-912。
- fit(input_matrix: csr_matrix | ndarray) GSVD [source]
計算圖形的嵌入。
- 參數:
input_matrix – 圖的鄰接矩陣或二鄰接矩陣。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- 預測(鄰接向量: 稀疏矩陣 | ndarray) ndarray [source]
預測新列的嵌入,這些列是由其鄰接向量定義。
- 參數:
adjacency_vectors -節點的鄰接向量。形狀為 (n_col,) 的陣列(單一向量)或 (n_vectors, n_col)
- 傳回:
embedding_vectors – 節點嵌入。
- 傳回類型:
np.ndarray
- 設定參數(params: 字典) 演算法
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- 轉換() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
PCA
- 類別 sknetwork.embedding.PCA(n_components=2, 已正規化: 布林 = 錯誤, 求解器: 字串 | SVDSolver = 'lanczos')[source]
透過鄰接或雙鄰接矩陣的主成分分析來嵌入圖。
- 參數:
n_components (整數) – 嵌入的維度。
normalized(布林值,預設=
False
)-若True
,會正規化嵌入,以使得嵌入空間中每一個向量的範數為 1,亦即每個向量都在單位球上。solver (
'lanczos'
(Lanczos 演算法,預設)或SVDSolver
(自訂解算器))-使用哪個解算器。
- 變量:
embedding (array, shape = (n, n_components)) – 節點的嵌入式。
embedding_row (array, shape = (n_row, n_components)) – 二部圖的列嵌入式。
embedding_col (array, shape = (n_col, n_components)) – 二部圖的欄嵌入式。
singular_values(np.ndarray,形狀 =(n_components))-奇異值。
singular_vectors_left(np.ndarray,形狀 =(n_row,n_components))-左奇異向量。
singular_vectors_right(np.ndarray,形狀 =(n_col,n_components))-右奇異向量。
範例
>>> from sknetwork.embedding import PCA >>> from sknetwork.data import karate_club >>> pca = PCA() >>> adjacency = karate_club() >>> embedding = pca.fit_transform(adjacency) >>> embedding.shape (34, 2)
參考
Jolliffe, I.T. (2002). Principal Component Analysis Series: Springer Series in Statistics.
- fit(adjacency: csr_matrix | ndarray) PCA [source]
計算圖形的嵌入。
- 參數:
adjacency – 圖形的鄰接或雙鄰接矩陣。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(adjacency_vectors: csr_matrix | ndarray) ndarray
預測新列的嵌入,這些列是由其鄰接向量定義。
- 參數:
adjacency_vectors -節點的鄰接向量。形狀為 (n_col,) 的陣列(單一向量)或 (n_vectors, n_col)
- 傳回:
embedding_vectors – 節點嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- transform() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
隨機投影
- 類別 sknetwork.embedding.RandomProjection(n_components: int = 2, alpha: float = 0.5, n_iter: int = 3, random_walk: bool = False, regularization: float = -1, normalized: bool = True, random_state: int | None = None)[source]
基於鄰接矩陣的隨機投射將圖嵌入
\((I + \alpha A +... + (\alpha A)^K)G\)
其中 \(A\) 是鄰接矩陣,\(G\) 是隨機高斯矩陣,\(\alpha\) 是平滑因子,\(K\) 是非負整數。
- 參數:
n_components (int (預設 = 2)) – 嵌入空間的維度。
alpha (float (預設 = 0.5)) – 平滑參數。
n_iter (int (預設 = 3)) – 鄰接矩陣的冪次迭代次數。
random_walk (bool (預設 =
False
)) – 如果為True
,使用隨機遊走的轉移矩陣 \(P = D^{-1}A\),而不是鄰接矩陣。regularization (float (預設 =
-1
)) – 正規化因子 \(\alpha\),因此矩陣為 \(A + \alpha \frac{11^T}{n}\)。如果是負值,則僅在圖形斷開連接時套用正規化(接著等於參數的絕對值)。normalized (bool (預設 =
True
)) – 如果為True
,則正規化嵌入,使每個向量在嵌入空間中的範數為 1,亦即,每個向量都位於單位球面上。random_state (int, optional) – 隨機數產生器所使用的種子。
- 變量:
embedding (array, shape = (n, n_components)) – 節點的嵌入式。
embedding_row (array, shape = (n_row, n_components)) – 二部圖的列嵌入式。
embedding_col (array, shape = (n_col, n_components)) – 二部圖的欄嵌入式。
範例
>>> from sknetwork.embedding import RandomProjection >>> from sknetwork.data import karate_club >>> projection = RandomProjection() >>> adjacency = karate_club() >>> embedding = projection.fit_transform(adjacency) >>> embedding.shape (34, 2)
參考
Zhang, Z., Cui, P., Li, H., Wang, X., & Zhu, W. (2018). Billion-scale network embedding with iterative random projection, ICDM.
- fit(input_matrix: csr_matrix | ndarray, force_bipartite: bool = False) RandomProjection [source]
計算影像嵌入式。
- 參數:
input_matrix (sparse.csr_matrix, np.ndarray) – 圖形的鄰接矩陣或雙鄰接矩陣。
force_bipartite (bool (預設值 =
False
)) – 如果True
,強制將輸入矩陣視為二鄰接矩陣。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(columns: bool = False) ndarray
傳回節點的嵌入。
- 參數:
columns (bool) – 若為
True
,傳回欄位的預測值。- 傳回:
embedding_ – 節點的嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- transform() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
盧萬
- 類別 sknetwork.embedding.LouvainEmbedding(解析度: 浮點數 = 1, 模組化: 字串 = 'Dugue', 最佳化公差: 浮點數 = 0.001, 集合公差: 浮點數 = 0.001, 集合數: 整數 = -1, 洗牌節點: 布林值 = False, 隨機狀態: RandomState | 整數 | 無 = None, 孤立節點: 字串 = '移除')[來源]
由 Louvain 群集產生的圖表內嵌。內嵌的每個組件都對應到透過 Louvain 取得的群集。
- 參數:
解析度 (浮點數) – 解析度參數。
模組化 (字串) – 要最佳化的目標函數。可以為
'Dugue'
、'Newman'
或'Potts'
。tol_optimization – 輸入新的最佳化路徑的目標函數最小增加。
tol_aggregation – 輸入新的聚合路徑的目標函數最小增加。
n_aggregations – 最大聚合數。負值視為無限制。
shuffle_nodes – 最佳化前啟用節點洗牌。
random_state – 隨機數產生器或隨機種子。如果是
None
,會使用 numpy.random。isolated_nodes (str) – 如何處置孤立的欄位節點。可以是
'remove'
(預設值)、'merge'
或'keep'
。
- 變量:
embedding (array, shape = (n, n_components)) – 節點的嵌入式。
embedding_row (array, shape = (n_row, n_components)) – 二部圖的列嵌入式。
embedding_col (array, shape = (n_col, n_components)) – 二部圖的欄嵌入式。
labels_row (np.ndarray) – 列標籤(用來建立欄位的嵌入式)。
labels_col (np.ndarray) – 欄標籤(用來建立列的嵌入式)。
範例
>>> from sknetwork.embedding import LouvainEmbedding >>> from sknetwork.data import house >>> louvain = LouvainEmbedding() >>> adjacency = house() >>> embedding = louvain.fit_transform(adjacency) >>> embedding.shape (5, 2)
- fit(input_matrix: csr_matrix, force_bipartite: bool = False)[source]
根據羅浮演算法所得到之群集結果,將圖形嵌入。
- 參數:
input_matrix – 圖的鄰接矩陣或二鄰接矩陣。
force_bipartite (bool (預設值 =
False
)) – 如果True
,強制將輸入矩陣視為二鄰接矩陣。
- 傳回:
self
- 傳回類型:
BiLouvainEmbedding
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(columns: bool = False) ndarray
傳回節點的嵌入。
- 參數:
columns (bool) – 若為
True
,傳回欄位的預測值。- 傳回:
embedding_ – 節點的嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- transform() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
Force Atlas
- 類別 sknetwork.embedding.ForceAtlas(n_components: int = 2, n_iter: int = 50, approx_radius: float = -1, lin_log: bool = False, gravity_factor: float = 0.01, repulsive_factor: float = 0.1, tolerance: float = 0.1, speed: float = 0.1, speed_max: float = 10)[source]☛
使用 Force Atlas 佈局顯示圖形。
- 參數:
n_components (整數) – 圖形佈局的維度。
n_iter (整數) – 更新位置的迭代次數。如果為
None
,請使用 self.n_iter 的值。approx_radius (浮點數) – 如果提供了正值,則僅使用給定節點中此距離內的節點來計算排斥力。
lin_log (布林值) – 如果
True
,則使用直線對數模式。gravity_factor (浮點數) – 重力力縮放常數。
repulsive_factor (浮點數) – 排斥力縮放常數。
tolerance (浮點數) – 在擺動常數中定義的容差。
speed (浮點數) – 速度常數。
speed_max (浮點數) – 使用於對速度施加約束的常數。
- 變量:
embedding (np.ndarray) – 給定維度中的配置。
範例
>>> from sknetwork.embedding.force_atlas import ForceAtlas >>> from sknetwork.data import karate_club >>> force_atlas = ForceAtlas() >>> adjacency = karate_club() >>> embedding = force_atlas.fit_transform(adjacency) >>> embedding.shape (34, 2)
參考
Jacomy M., Venturini T., Heymann S., Bastian M. (2014)。ForceAtlas2,一種連續圖形配置演算法,用於專為 Gephi 軟體設計的手動網路視覺化。 Plos One。
- fit(adjacency: csr_matrix | ndarray, pos_init: ndarray | None = None, n_iter: int | None = None) ForceAtlas [source]
計算配置。
- 參數:
adjacency – 圖形鄰接矩陣,視為未導向圖。
pos_init – 用來起始的位置。如未提供,則為隨機。
n_iter (整數) – 更新位置的迭代次數。如果為
None
,請使用 self.n_iter 的值。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(columns: bool = False) ndarray
傳回節點的嵌入。
- 參數:
columns (bool) – 若為
True
,傳回欄位的預測值。- 傳回:
embedding_ – 節點的嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- transform() ndarray
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
Spring
- 類別 sknetwork.embedding.Spring(n_components: int = 2, strength: float | None = None, n_iter: int = 50, tol: float = 0.0001, approx_radius: float = -1, position_init: str = 'random')[來源]
用於顯示小圖形的 Spring 排列。
- 參數:
n_components (整數) – 圖形佈局的維度。
強度 (float) – 移動節點的力道強度。
n_iter (int) – 更新位置的迭代次數。
容許誤差 (float) – 位置變動的最小相對值,以繼續更新。
approx_radius (浮點數) – 如果提供了正值,則僅使用給定節點中此距離內的節點來計算排斥力。
位置初始化 (str) – 如何初始化排列。如果為「光譜」,使用維度為 2 的光譜嵌入,否則使用隨機初始化。
- 變量:
嵌入 (np.ndarray) – 排列。
範例
>>> from sknetwork.embedding import Spring >>> from sknetwork.data import karate_club >>> spring = Spring() >>> adjacency = karate_club() >>> embedding = spring.fit_transform(adjacency) >>> embedding.shape (34, 2)
備註
簡單的實作,旨在顯示小圖形。
參考
Fruchterman, T. M. J., Reingold, E. M. (1991)。透過力導向配置繪製圖形。軟體 - 實務與經驗。
- fit(adjacency: csr_matrix | ndarray, position_init: ndarray | None = None, n_iter: int | None = None) Spring [來源碼]
計算配置。
- 參數:
adjacency – 圖形鄰接矩陣,視為未導向圖。
position_init (np.ndarray) - 節點自訂初始位置。形狀必須為 (n, 2)。如果
None
,使用 self.pos_init 的值。n_iter (整數) – 更新位置的迭代次數。如果為
None
,請使用 self.n_iter 的值。
- 傳回:
self
- 傳回類型:
- fit_transform(*args, **kwargs) ndarray
擬合資料並傳回嵌入。參數與
fit
方法相同。- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray
- get_params()
以字典形式取得參數。
- 傳回:
params – 演算法的參數。
- 傳回類型:
dict
- predict(adjacency_vectors: csr_matrix | ndarray) ndarray [來源碼]
預測新列的嵌入,這些列是由其鄰接向量定義。
- 參數:
adjacency_vectors -節點的鄰接向量。形狀為 (n_col,) 的陣列(單一向量)或 (n_vectors, n_col)
- 傳回:
embedding_vectors – 節點嵌入。
- 傳回類型:
np.ndarray
- set_params(params: dict) Algorithm
設定演算法的參數。
- 參數:
params (dict) – 演算法的參數。
- 傳回:
self
- 傳回類型:
Algorithm
- 變換() 清單
傳回嵌入。
- 傳回:
嵌入 – 嵌入。
- 傳回類型:
np.ndarray