The result
A shared dataset explored through multiple Spark APIs, an MLlib regressor and a schema-aware SQL interface.
From programming-problem records to reusable analysis
Academic project
Turned 8,573 programming problems into a queryable Spark dataset, with cached analysis, difficulty modeling and schema-aware model-assisted SQL.
From the repository
A distributed data processing and machine learning system built on Apache Spark for analyzing competitive programming problems and solutions. Features natural language query interface powered by LLMs, performance optimization through bucketing and caching, and predictive analytics using decision tree models.
This system processes the DeepMind CodeContests dataset containing thousands of competitive programming problems from platforms like Codeforces, along with their solutions in multiple languages. It demonstrates advanced Spark capabilities including distributed SQL, ML pipelines, and query optimization.
The system consists of six containerized services:
DeepMind CodeContests dataset featuring:
Demonstrates proficiency across all three Spark programming models:
# RDD API
count_rdd = problems_df.rdd \
.filter(lambda row: row.cf_rating >= 1600 and
row.has_private_tests and "_A." in row.name) \
.count()
# DataFrame API
count_df = problems_df \
.filter((col("cf_rating") >= 1600) &
col("has_private_tests") &
col("name").contains("_A.")) \
.count()
# Spark SQL
count_sql = spark.sql("""
SELECT COUNT(*) FROM problems
WHERE cf_rating >= 1600
AND has_private_tests = true
AND name LIKE '%_A.%'
""").collect()[0][0]
Cross-references solutions with problem metadata and source platforms:
SELECT COUNT(*)
FROM solutions s
JOIN problems p ON s.problem_id = p.problem_id
JOIN sources src ON p.source = src.id
WHERE s.language = 'PYTHON3'
AND s.is_correct = true
AND src.name = 'CODEFORCES'
Classifies problems using CASE expressions:
SELECT
CASE
WHEN difficulty <= 5 THEN 'Easy'
WHEN difficulty <= 10 THEN 'Medium'
ELSE 'Hard'
END as category,
COUNT(*) as count
FROM problems
GROUP BY category
Results: 409 Easy, 5,768 Medium, 2,396 Hard problems
LLM-powered query interface enabling non-technical users:
def human_query(english_question):
# Construct prompt with schema and question
prompt = f"""
Given these tables: {schema_info}
Convert to SQL: {english_question}
Return only the query, no formatting.
"""
# Generate SQL via Gemini API
response = client.models.generate_content(
model='gemini-2.5-flash',
contents=prompt,
config={'temperature': 0}
)
# Execute and return result
result = spark.sql(response.text).collect()[0][0]
return int(result)
# Usage
java_count = human_query("How many JAVA solutions are there?")
max_memory = human_query("What is the maximum memory limit in bytes?")
Without Bucketing: Requires expensive shuffle/exchange operations
Exchange hashpartitioning(language)
HashAggregate(keys=[language], functions=[partial_count(1)])
With Bucketing: No shuffle needed - data pre-partitioned
HashAggregate(keys=[language], functions=[count(1)])
HashAggregate(keys=[language], functions=[partial_count(1)])
Benchmark results for average calculations on filtered dataset:
| Run | Caching Status | Time (seconds) |
|---|---|---|
| 1st | Not cached | 0.909 |
| 2nd | Cached | 1.413 |
| 3rd | Cached (warm) | 0.196 |
Result: 78% performance improvement with warm cache
Trained decision tree regressor to estimate Codeforces ratings for problems with missing difficulty scores.
Features: difficulty, time_limit, memory_limit_bytes
Target: cf_rating
Data Split:
Results:
Insight: Problems with missing ratings appear slightly less challenging than rated problems.
![Overfitting Analysis]
Trained models with varying tree depths (1-30) to analyze bias-variance tradeoff:
depths = [1, 2, 3, 5, 7, 10, 15, 20, 25, 30]
results = []
for depth in depths:
pipeline = Pipeline(stages=[
VectorAssembler(inputCols=features, outputCol="features"),
DecisionTreeRegressor(maxDepth=depth, labelCol="cf_rating")
])
model = pipeline.fit(train_df)
train_r2 = evaluator.evaluate(model.transform(train_df))
test_r2 = evaluator.evaluate(model.transform(test_df))
results.append({'depth': depth, 'train': train_r2, 'test': test_r2})
Key Findings:
docker build -f p5-base.Dockerfile -t spark-analytics-base .
docker build -f notebook.Dockerfile -t spark-analytics-nb .
docker build -f namenode.Dockerfile -t spark-analytics-nn .
docker build -f datanode.Dockerfile -t spark-analytics-dn .
docker build -f boss.Dockerfile -t spark-analytics-boss .
docker build -f worker.Dockerfile -t spark-analytics-worker .
export PROJECT=spark-analytics
export GEMINI_API_KEY='your-api-key'
docker compose up -d
http://localhost:5000/lab
spark = SparkSession.builder \
.appName("competitive-programming-analytics") \
.master("spark://boss:7077") \
.config("spark.sql.warehouse.dir", "hdfs://nn:9000/user/hive/warehouse") \
.enableHiveSupport() \
.getOrCreate()
solutions_df.write \
.mode("overwrite") \
.bucketBy(4, "language") \
.saveAsTable("solutions")
A comprehensive demonstration of modern big data processing, machine learning, and AI-powered analytics.
Continue exploring · 34 projects

Fullstack

ML & AI

ML & AI

ML & AI
Distributed Systems

Fullstack

ML & AI
Distributed Systems

Distributed Systems
Distributed Systems
Distributed SystemsViewing

Data Engineering
Data Engineering

Data Engineering

Data Engineering

Data Engineering

ML & AI
ML & AI
Data Engineering

Fullstack

Fullstack
Fullstack

Fullstack

Fullstack
Data Engineering
Computing Foundations

Fullstack

Fullstack
ML & AI
ML & AI

ML & AI
ML & AI
ML & AI
ML & AI