File size: 2,380 Bytes
1d12e97 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
---
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`.
- **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:
1. **"List all cars manufactured by Ferrari"**
- Verified: Returns models like `SF90 STRADALE`, `ROMA`, `812 GTS`.
2. **"Which cars have > 800 HorsePower?"**
- Verified: Returns `Bugatti Chiron`, `Tesla Roadster 2`, etc.
3. **"Count of 2-Seater Coupes"**
- Result: 147 vehicles.
4. **"What is the average price of all cars?"**
- Result: ~$137,193 USD.
## 5. How to Run
### Prerequisites
- Python 3.x
- Libraries: `rdflib`, `pandas`
### Steps
1. **Install Dependencies**:
```bash
pip install rdflib pandas
```
2. **Generate Knowledge Graph**:
```bash
python src/ontology.py # Generates Ontology Schema
python src/convert_data.py # Generates Graph from CSV
```
3. **Run Validation Queries**:
```bash
python src/validate.py
```
|