mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-08-29 04:26:20 +00:00
- visualization.md: GraphVisualizer → KGVisualizer; fix method names (visualize_network, visualize_network_evolution, visualize_snapshot_comparison, visualize_temporal_patterns, visualize_2d_projection); remove DistanceVisualizer tab; fix start_explorer() reference - kg.md: remove TemporalKnowledgeGraph and DistanceCalculator (don't exist); replace with TemporalGraphQuery and ConnectivityAnalyzer; fix query_at_time() signature - ontology.md: remove OntologyManager, SKOSVocabulary, OntologyAligner, OntologyDiff, OntologyMigrator (none exist); fix SHACLValidator → OntologyValidator; fix OWLExporter → OWLGenerator.export_owl(); fix start_explorer() reference - evals.md: replace entire file with coming-soon notice (module is a stub, __all__ = []) - embeddings.md: fix EmbeddingGenerator constructor (takes config dict not model=); generate() → generate_embeddings(); similarity() → compare_embeddings() - ingest.md: fix WebIngestor (rate_limit → delay, ingest() → ingest_url()); FeedIngestor (ingest() → ingest_feed(), monitor() → monitor_feeds()); StreamIngestor (backend= constructor → ingest_kafka/rabbitmq/kinesis/pulsar()); DBIngestor constructor + ingest() → ingest_database(); SnowflakeIngestor.ingest() → ingest_query()/ingest_table(); OntologyIngestor.ingest() → ingest_ontology(); DataSource → FileObject - explorer.md: remove start_explorer() Python function (only CLI exists); replace with semantica-explorer CLI usage - provenance.md: ActivityTracker → ProvenanceTracker in CardGroup - semantic_extract.md: EventExtractor → EventDetector - triplet_store.md: remove InMemoryTripletStore (doesn't exist); fix tip - llms.md: fix providers (Anthropic/Gemini/Ollama/DeepSeek/NovitaAI → LiteLLM); HuggingFace → HuggingFaceLLM; remove create_provider()
9.3 KiB
9.3 KiB
title, description, icon
| title | description | icon |
|---|---|---|
| Visualization Module | Interactive and static knowledge graph, ontology, embedding, and temporal visualization. | chart-bar |
semantica.visualization renders knowledge graphs, ontologies, embedding spaces, and temporal data as interactive HTML or static images — without launching the full Explorer server.
What You Get
Interactive network and community graph rendering with force, hierarchical, and circular layouts. Class hierarchy and property relationship visualization from any ontology. UMAP, t-SNE, and PCA dimensionality reduction plots for embedding cluster analysis. Timeline views, network evolution animation, snapshot comparison, and temporal pattern highlights. Centrality rankings, community-colored graphs, and degree distribution histograms.Quick Start
```python from semantica.visualization import KGVisualizerviz = KGVisualizer(layout="force", color_scheme="default")
# Interactive — opens in browser, supports hover and click
viz.visualize_network(graph, output="interactive")
```
viz.visualize_network(
graph,
output="html",
file_path="graph.html",
node_color_by="type", # color nodes by entity type attribute
)
```
# Vector SVG — for publications and scalable diagrams
viz.visualize_network(graph, output="svg", file_path="graph.svg")
```
Visualizers
Interactive and static knowledge graph rendering:```python
from semantica.visualization import KGVisualizer
viz = KGVisualizer(layout="force", color_scheme="default")
# Interactive — opens in browser
viz.visualize_network(graph, output="interactive")
# Save as HTML file
viz.visualize_network(graph, output="html", file_path="graph.html")
# Static PNG
viz.visualize_network(graph, output="png", file_path="graph.png")
# Community-colored graph
viz.visualize_communities(graph, communities, file_path="communities.html")
```
**Layout options (`layout=`):**
| Layout | Description | Best For |
| ------ | ----------- | -------- |
| `force` | Physics simulation — clusters emerge naturally | General graphs |
| `hierarchical` | Top-down tree layout | Taxonomies, org charts |
| `circular` | Nodes on a circle, edges as chords | Small dense graphs |
```python
from semantica.visualization import OntologyVisualizer
viz = OntologyVisualizer()
# Full ontology graph — classes, properties, and constraints
viz.visualize(ontology, output="ontology.html")
# Class hierarchy only — cleaner for large ontologies
viz.visualize_hierarchy(ontology, output="hierarchy.html")
```
```python
from semantica.visualization import EmbeddingVisualizer
viz = EmbeddingVisualizer()
viz.visualize_2d_projection(
embeddings=embeddings,
labels=labels,
output="interactive",
file_path="embeddings.html",
method="umap", # "umap" | "tsne" | "pca"
)
```
| Method | Speed | Preserves | Best For |
| ------ | ----- | --------- | -------- |
| `umap` | Fast | Global + local structure | Large datasets, cluster discovery |
| `tsne` | Medium | Local structure | Tight cluster separation |
| `pca` | Very fast | Variance | Quick overview, linear structure |
```python
from semantica.visualization import TemporalVisualizer
viz = TemporalVisualizer()
# Timeline of entity/relationship changes
viz.visualize_timeline(temporal_kg, output="interactive")
# Animated network evolution — one frame per time step
viz.visualize_network_evolution(temporal_kg, output="html", file_path="evolution.html")
# Side-by-side snapshot comparison
viz.visualize_snapshot_comparison(snap_a, snap_b, output="html", file_path="diff.html")
# Recurring temporal patterns
viz.visualize_temporal_patterns(temporal_kg, output="html", file_path="patterns.html")
```
```python
from semantica.visualization import AnalyticsVisualizer
from semantica.kg import CentralityCalculator, CommunityDetector
calc = CentralityCalculator()
centrality = calc.calculate_all_centrality(kg)
detector = CommunityDetector()
communities = detector.detect_communities(kg, algorithm="louvain")
viz = AnalyticsVisualizer()
# Bar chart of top-N nodes by centrality measure
viz.visualize_centrality(centrality, metric="pagerank", top_k=20, output="centrality.html")
# Community-colored graph
viz.visualize_communities(kg, communities, output="communities.html")
# Degree distribution histogram
viz.visualize_degree_distribution(kg, output="degree_dist.html")
# Combined analytics dashboard
viz.visualize_analytics_dashboard(
kg, centrality=centrality, communities=communities,
output="analytics_dashboard.html",
)
```
Color Schemes
All visualizers accept a color_scheme parameter:
viz.visualize(graph, output="graph.html", color_scheme="vibrant")
| Scheme | Description | Best For |
|---|---|---|
default |
Blue-grey palette | General use |
vibrant |
High-contrast, saturated colours | Presentations |
pastel |
Soft, muted tones | Light backgrounds |
dark |
Dark background with bright nodes | Dark-mode dashboards |
light |
White background, thin edges | Publications, print |
colorblind |
Okabe-Ito safe palette | Accessibility |
Export Formats
| Format | Interactive | Scalable | Best For |
|---|---|---|---|
.html |
Yes | N/A | Web dashboards, exploratory analysis |
.png |
No | No | Reports, Jupyter notebooks |
.svg |
No | Yes | Publications, slide decks |
.pdf |
No | Yes | Print, compliance exports |
Graph Explorer (Full Dashboard)
For a full browser-based UI with search, path finding, and the Ontology Hub, launch the Explorer via the CLI:
semantica explore
See the Explorer reference for the full feature set and REST API.