如何从社交网络或交易网络中提取特征?

中等机器学习

答题要点

import networkx as nx

G = nx.from_pandas_edgelist(df, 'user_a', 'user_b')

# 中心性特征
degree = dict(G.degree())  # 度中心性
betweenness = nx.betweenness_centrality(G)  # 介数中心性
pagerank = nx.pagerank(G)  # PageRank

# 聚集系数
clustering = nx.clustering(G)

# 社区检测
from community import community_louvain
communities = community_louvain.best_partition(G)

# 邻居特征聚合
df['neighbor_avg_score'] = df['user_id'].map(lambda u: np.mean([scores[n] for n in G.neighbors(u)]))

完整解析在题库里看

核心知识点、易错点和面试官想听到什么;练过的题会进入记录,答错的进错题本。

去练这道题

回知识库看这一块

同一能力的其他题