Skip to content

Repository files navigation

Human-Centric AI: Interactive ML Systems

A collection of five interactive Django web applications exploring human-centric machine learning paradigms, developed as coursework at TU Hamburg.

Projects Overview

Project Topic Key Technique
1 AutoML Interface Supervised Learning Pipeline
2 Active Learning Pool-Based Sampling for Text
3 Explainability Sparse Models & Counterfactuals
4 Recommender Systems Matrix Factorization + Cold Start
5 RLHF Reinforcement Learning with Human Feedback

Project 1: Automated Machine Learning Interface

Interactive web interface for end-to-end supervised learning workflows.

Features

  • Data Upload & Visualization: CSV upload with scatter plot generation (X vs Y, Feature vs Target)
  • Automatic Problem Detection: Infers classification vs regression from target column
  • Model Selection: Logistic Regression, SVM, Random Forest, Linear Regression
  • Hyperparameter Tuning: Grid search with user-configurable parameter ranges
  • Evaluation: Confusion matrix (classification) or True vs Predicted plots (regression)

Technical Implementation

CSV → Preprocessing (StandardScaler, OneHotEncoder) → GridSearchCV → Model → Evaluation

Models: LogisticRegression, SVC, RandomForestClassifier, LinearRegression, RandomForestRegressor


Project 2: Active Learning for Text Classification

Pool-based active learning for IMDB sentiment analysis (50k movie reviews).

Features

  • Text Representation: TF-IDF vectorization (5000 features)
  • Baseline Classifier: Logistic Regression trained on full dataset (~89% accuracy)
  • Active Learning Strategies:
    • Least Confident
    • Margin Sampling
    • Entropy-based
    • Random Baseline
    • Mixtures (LC+Entropy, Entropy+Random)
  • Termination Conditions: Plateau detection, target accuracy threshold

Active Learning Progress

Active Learning Progress

Technical Implementation

# Utility functions for sample selection
def calculate_utility_scores(probas, strategy):
    if strategy == "least_confident":
        return 1 - np.max(probas, axis=1)
    elif strategy == "entropy":
        return -np.sum(probas * np.log2(probas + 1e-12), axis=1)

Project 3: Explainability & Interpretable ML

Interactive exploration of model interpretability using the Palmer Penguins dataset.

Features

  • Sparse Decision Trees: GOSDT algorithm for optimal sparse trees
  • Sparse Logistic Regression: L1 penalty with adjustable regularization
  • Complexity Control: Lambda slider to trade off accuracy vs interpretability
  • Counterfactual Explanations: "What-if" analysis using MAD-weighted L1 distance

Technical Implementation

Interpretability Objective: argmin_f (1/n)Σℓ(f(xi), yi) + λΩ(f)

Counterfactual Generation:

  1. Sample N points locally around input x
  2. Filter to points with desired class prediction
  3. Rank by MAD-weighted L1 distance
  4. Display top-k counterfactuals

Project 4: Cold-Start Recommender with Guided Active Learning

Interactive movie recommendation system addressing the cold-start problem using MovieLens dataset.

Features

  • Matrix Factorization: L2-regularized latent factor model
  • Active Learning Strategies:
    • Popularity-based (most-rated movies)
    • Uncertainty-based (ratings closest to 3.0)
  • Guidance System: Real-time impact preview showing how ratings affect recommendations
  • User Study Interface: Complete A/B testing framework with logging

Technical Implementation

Matrix Factorization: min_{U,V} Σ(R_ij - U_i^T V_j)² + λ(||U||²_F + ||V||²_F)

New User Embedding: min_{u} Σ(R_ij - u^T V_j)² + λ||u||²_F  (V fixed)

Key Components

  • Impact calculation showing prediction deltas before/after rating
  • What-if preview panel for strategic user input
  • PDF report generation for methodology documentation

Project 5: Reinforcement Learning with Human Feedback (RLHF)

Train a mouse agent to collect cheese using human preference feedback.

Environment

  • 5×5 grid world with walls, traps, cheese (regular + organic)
  • Rewards: +10 (cheese), -50 (trap), -0.2 (empty/wall bump)
  • 4 actions: Up, Down, Left, Right

Features

  • REINFORCE Algorithm: Policy gradient with CNN policy network
  • Bradley-Terry Preference Model: Learn rewards from human trajectory comparisons
  • RLHF Training: Fine-tune policy using learned reward with KL penalty

Architecture

# Policy Network (from project specification)
PolicyNetwork:
    Conv2d(616, 3×3) → ReLUConv2d(1632, 3×3) → ReLUFlattenLinear(80064) → ReLULinear(644) → Softmax

# Reward Network
RewardNetwork:
    Conv2d(616, 3×3) → ReLUFlattenLinear(40064) → ReLULinear(641)

RLHF Pipeline

1. Train base policy with REINFORCE
2. Generate trajectory pairs
3. Collect human preferences (which trajectory is better?)
4. Train Bradley-Terry reward model: P(τ₁ ≻ τ₂) = σ(R(τ₁) - R(τ₂))
5. Fine-tune policy with learned reward + KL penalty to original policy

Tech Stack

Django Python scikit-learn PyTorch NumPy Pandas Matplotlib TF-IDF NLTK

Installation

# Clone repository
git clone https://github.com/rahulkvr/hcai.git
cd hcai

# Option A: Conda
conda env create -f environment.yml
conda activate hcai

# Option B: pip
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -r requirements.txt

# Run server
python manage.py runserver

Access at http://127.0.0.1:8000/


TU Hamburg — Human-Centric AI Course

About

Human-Centered AI: explainability + active learning

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages