metadata
title: Cars Knowledge Graph
emoji: π
colorFrom: blue
colorTo: red
sdk: docker
pinned: false
Knowledge Representation Project: Cars Knowledge Graph
1. Introduction & Motivation
This project transforms a flat CSV dataset of Car Specifications (2025) into a semantic Knowledge Graph (RDF/OWL). Domain: Automotive Industry (Cars, Manufacturers, Engines, Performance). Motivation: To enable complex querying of car data that is not possible with simple tabular lookups, such as inferring "High Performance" vehicles or categorizing cars by complex criteria (e.g., specific engine types + price ranges).
2. Ontology Design (Conceptual Model)
The Ontology is designed using RDFLib and conforms to the project requirements (20+ Classes, 7+ Properties).
Core Classes
- Car: The central entity.
- Subclasses:
SportsCar,HyperCar,Sedan,Coupe,ElectricCar,PetrolCar,LuxuryCar.
- Subclasses:
- Manufacturer: Companies like Ferrari, Tesla, Bugatti.
- Component:
Engine,V8Engine,V12Engine. - defined Classes:
SuperCar: Cars with Top Speed > 300 km/h.
Properties
- Object Properties:
hasManufacturer,hasEngine,usesFuel,manufactures. - Datatype Properties:
hasPriceValue,hasHorsePowerValue,hasSeatCount,hasTopSpeedKMH.
3. Knowledge Graph Construction
- Source:
Cars Datasets 2025.csv - Output:
cars_knowledge_graph.ttl(Turtle Syntax) - Triples Generated: ~9,842
4. Competency Questions & Validation
The following questions guided the design and were validated via SPARQL:
- "List all cars manufactured by Ferrari"
- Verified: Returns models like
SF90 STRADALE,ROMA,812 GTS.
- Verified: Returns models like
- "Which cars have > 800 HorsePower?"
- Verified: Returns
Bugatti Chiron,Tesla Roadster 2, etc.
- Verified: Returns
- "Count of 2-Seater Coupes"
- Result: 147 vehicles.
- "What is the average price of all cars?"
- Result: ~$137,193 USD.
5. How to Run
Prerequisites
- Python 3.x
- Libraries:
rdflib,pandas
Steps
- Install Dependencies:
pip install rdflib pandas - Generate Knowledge Graph:
python src/ontology.py # Generates Ontology Schema python src/convert_data.py # Generates Graph from CSV - Run Validation Queries:
python src/validate.py