关于 pygraphistry-ai
pygraphistry-ai 是使用 PyGraphistry 图分析 AI 功能的技能,涵盖嵌入、聚类、语义搜索和新数据投影,并提供引擎与采样建议。
主要功能
- 01图特征与嵌入工作流
- 02UMAP 投影与批次转换
- 03DBSCAN 聚类与语义搜索
- 04引擎和采样建议
适用场景
- 01探索图特征中的模式
- 02搜索文本生成的图嵌入
- 03一致地投影新批次数据
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ graphistry/ graphistry-skills --skill pygraphistry-ai安装后在 Claude Code 中输入/pygraphistry-ai确认已加载。
详细介绍
PyGraphistry AI
文档路由(本地 + 规范链接)
- 首先查看
../pygraphistry/references/pygraphistry-readthedocs-toc.md。 - 使用
../pygraphistry/references/pygraphistry-readthedocs-top-level.tsv查找章节级快捷链接。 - 仅当所需页面缺失时,才扫描
../pygraphistry/references/pygraphistry-readthedocs-sitemap.xml。 - 深入阅读页面前,先批量读取一次发现信息;避免使用
cat *和串行的微型读取。 - 面向用户的回答中,优先使用规范的
https://pygraphistry.readthedocs.io/en/latest/...链接。
典型工作流
- 根据节点/边构建图。
- 运行特征/嵌入方法(
umap、embed,以及可选的dbscan)。 - 检查派生列/特征并进行可视化。
- 迭代调整特征列和采样策略。
基础示例
# Similarity embedding / projection
g2 = graphistry.nodes(df, 'id').umap(X=['f1', 'f2', 'f3'])
g2.plot()
# Fit/transform flow for consistent projection on new batches
g_train = graphistry.nodes(df_train, 'id').umap(X=['f1', 'f2'])
g_batch = g_train.transform_umap(df_batch, return_graph=True)
g_batch.plot()
# Semantic search over embedded features
g2 = graphistry.nodes(df, 'id').umap(X=['text_col'])
results_df, query_vector = g2.search('suspicious login pattern')
# Text-first workflow: featurize then search/cluster
g2 = graphistry.nodes(df, 'id').featurize(kind='nodes', X=['title', 'body']).umap(kind='nodes').dbscan()
hits, qv = g2.search('credential stuffing campaign')
# Precomputed embedding columns
embedding_cols = [c for c in df.columns if c.startswith('emb_')]
g2 = graphistry.nodes(df, 'id').umap(X=embedding_cols)
g_new = g2.transform_umap(df_new, return_graph=True)
实用注意事项
- 完整运行前,先从较小或有代表性的样本开始。
- 使用明确的特征列表(
X=...),以便复现。 - 记录引擎/数据帧类型,以了解 CPU 与 GPU 行为。支持 Polars 输入;需要保留 Polars 结果时,在 GFQL 行/遍历任务中使用
engine='polars'/'polars-gpu'。 - UMAP、超图、布局及其他全图分析并非原生 Polars 操作。在 Polars GFQL 引擎下,请知情使用默认桥接,或设置
call_mode='strict'以拒绝在引擎外执行。 - 对于异常检测工作流,请记录阈值和误报假设。
- 对于图机器学习任务,将更深入的模型工作流路由到 RGCN/链接预测参考文档。
- 对于文本工作流,查询为自然语言时,优先使用
featurize(...).umap(...).search(...)。 - 如果用户已有嵌入,请先通过明确的嵌入列列表(
X=[...])复用,再重新计算。 - 用户要求简洁的工作流代码片段时,优先使用一个简短代码块,避免冗长的叙述性引言。
规范文档
- GFQL + AI 组合:https://pygraphistry.readthedocs.io/en/latest/gfql/combo.html
- AI API 参考:https://pygraphistry.readthedocs.io/en/latest/api/ai.html
- AI 笔记本索引:https://pygraphistry.readthedocs.io/en/latest/notebooks/ai.html
- RGCN 笔记本示例:https://pygraphistry.readthedocs.io/en/latest/demos/more_examples/graphistry_features/embed/simple-ssh-logs-rgcn-anomaly-detector.html
评论
支持 Markdown