惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Jina AI
Jina AI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Troy Hunt's Blog
T
The Exploit Database - CXSecurity.com
Microsoft Security Blog
Microsoft Security Blog
V
Visual Studio Blog
F
Fortinet All Blogs
博客园_首页
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
The Cloudflare Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Heimdal Security Blog
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
A
About on SuperTechFans
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
AI
AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Security Affairs
The Register - Security
The Register - Security
S
Security @ Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东
Schneier on Security
Schneier on Security
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
GbyAI
GbyAI
T
Tailwind CSS Blog
Hacker News: Ask HN
Hacker News: Ask HN
W
WeLiveSecurity
D
Docker
L
LangChain Blog
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog
Cloudbric
Cloudbric
TaoSecurity Blog
TaoSecurity Blog
N
Netflix TechBlog - Medium
酷 壳 – CoolShell
酷 壳 – CoolShell
I
InfoQ
The Hacker News
The Hacker News
AWS News Blog
AWS News Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
宝玉的分享
宝玉的分享
I
Intezer
云风的 BLOG
云风的 BLOG
V2EX - 技术
V2EX - 技术
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
ML-Powered Adaptive IQ Test
Om Prakash · 2026-06-28 · via DEV Community

I Built an ML-Powered Adaptive IQ Test in Next.js 14 — Here's Exactly How It Works

Tags: nextjs typescript machinelearning webdev


Most online IQ tests are broken.

They ask the same 20 questions to everyone — whether you're a 14-year-old high school student or a 35-year-old PhD. They don't adapt. They don't remember what you've already answered. And after two or three retakes, you've memorised the answers. The score stops meaning anything.

I got frustrated enough to build my own. After a few months of work, I launched IQ Platform — a free, fully adaptive cognitive assessment tool that calibrates question difficulty to your age, education, and occupation, scores you using a multi-feature ML regression model, and remembers which questions you've already seen across sessions.

Here's the complete technical breakdown of how I built it.


The Stack

  • Next.js 14 (App Router)
  • TypeScript throughout
  • Tailwind CSS for styling
  • Recharts for radar and trend charts
  • Custom ML scoring engine (no external ML library — pure math)
  • localStorage for session history (no backend, no database)
  • Vercel for deployment

No Auth. No database. No backend API. Everything meaningful happens on the client or at build time.


The Core Problem: Static Tests Are Meaningless

Here's why standard online IQ tests fail:

Standard test:
  User A: 14 years old, high school → gets "What is 30% of 200?"
  User B: 26 years old, PhD CS      → gets "What is 30% of 200?"

Both answer correctly. Both score the same. 
But the question told you nothing useful about User B.

The solution is adaptive difficulty — selecting questions based on who is actually taking the test. This is how real psychometric assessments like the WAIS-IV work. They calibrate to the individual.


Part 1: The Question Bank (147 Questions, 6 Domains)

The question bank covers six cognitive domains:

Domain What it measures
Numerical Arithmetic, algebra, ratios, percentages, logarithms
Verbal Vocabulary, analogies, anagrams, antonyms
Pattern Number series, letter sequences, figurate numbers
Logical Syllogisms, seating arrangements, propositional logic
Memory Sequence recall, list recognition, position memory
Spatial 3D geometry, rotations, Euler's formula, clock angles

Each question has a difficulty rating from 1 (school level) to 5 (postgraduate/doctorate level), plus optional minAge, maxAge, and tags (STEM, arts, language, general):

export interface Question {
  id: string
  category: QuestionCategory
  difficulty: 1 | 2 | 3 | 4 | 5
  minAge?: number
  maxAge?: number
  tags?: string[]   // 'stem' | 'arts' | 'language' | 'general'
  text: string
  options: string[]
  correctIndex: number
  explanation: string
  timeLimit: number  // seconds per question
}

A difficulty-5 Logical question looks like this:

{
  id: 'l8', category: 'Logical', difficulty: 5, tags: ['stem'],
  text: 'Cards A, D, 4, 7. Which to flip to verify "vowel → even on other side"?',
  options: ['A and 4', 'A and 7', 'D and 4', 'A, D and 4'],
  correctIndex: 1, timeLimit: 40,
  explanation: 'Flip A (check even) and 7 (check no vowel). Wason selection task.'
}

While a difficulty-1 version looks like:

{
  id: 'l1', category: 'Logical', difficulty: 1, minAge: 10, maxAge: 16,
  text: 'All cats are animals. Whiskers is a cat. Therefore:',
  options: ['Whiskers is an animal', 'All animals are cats', ...],
  correctIndex: 0, timeLimit: 15,
  explanation: 'Simple syllogism: cat → animal'
}


Part 2: Profile-Aware Adaptive Selection

When a user fills in their profile, the system computes a difficulty target based on three inputs:

export const EDU_DIFFICULTY: Record<string, number> = {
  school: 1.5,
  diploma: 2.2,
  undergraduate: 2.8,
  postgraduate: 3.5,
  doctorate: 4.2,
}

export function getDifficultyRange(profile: UserProfile) {
  let target = EDU_DIFFICULTY[profile.education] ?? 2.5

  // Age-based adjustment
  if (profile.age <= 13) target = Math.min(target, 1.5)
  else if (profile.age <= 16) target = Math.min(target, 2.2)
  else if (profile.age <= 19) target = Math.min(target, 3.0)
  else if (profile.age >= 30 && isStem(profile.occupation)) {
    target = Math.max(target, 3.2)
  }

  return {
    min: Math.max(1, Math.floor(target - 1)),
    max: Math.min(5, Math.ceil(target + 1.5)),
    target
  }
}

So a 22-year-old B.Tech CS student gets a difficulty window of 2–4, while a 14-year-old high school student gets 1–2. The InfoScreen even shows a live difficulty tier preview as the user fills out the form — "Advanced tier — challenging questions requiring deeper reasoning" — updating in real time.

The isStem() helper checks the occupation string for keywords:

function isStem(occ: string): boolean {
  return ['engineer', 'developer', 'programmer', 'data', 'scientist',
    'computer', 'software', 'hardware', 'cs', 'iot', 'electronics',
    'ai', 'ml', 'cyber', 'network']
    .some(k => occ.toLowerCase().includes(k))
}

STEM occupations get Numerical, Pattern, and Logical questions boosted. Arts/language occupations get Verbal questions prioritised.


Part 3: The Anti-Repeat System

This was the feature that prompted the whole project. After 2–3 retakes, users were memorising answers.

The solution: track recently seen question IDs in localStorage and always serve unseen questions first.

const SEEN_KEY = 'iq_platform_seen_questions_v2'
const MAX_SEEN = 80  // remember last 80 question IDs

function getSeenIds(): Set<string> {
  try {
    const raw = localStorage.getItem(SEEN_KEY)
    return raw ? new Set(JSON.parse(raw)) : new Set()
  } catch { return new Set() }
}

function markAsSeen(ids: string[]): void {
  const existing = [...getSeenIds()]
  const updated = [...ids, ...existing].slice(0, MAX_SEEN)
  localStorage.setItem(SEEN_KEY, JSON.stringify(updated))
}

During selection, unseen questions are sorted to the front:

const unseen = pool
  .filter(q => !seenIds.has(q.id))
  .sort(() => Math.random() - 0.5)

const seen = pool
  .filter(q => seenIds.has(q.id))
  .sort(() => Math.random() - 0.5)

// Always prefer unseen
const prioritised = [...unseen, ...seen]
selected.push(...prioritised.slice(0, perCategory))

With 147 questions and 20 per test, a user can take 7+ tests before any question repeats — and when repeats do happen, they're shuffled into different positions and contexts.


Part 4: The ML Scoring Engine

This is the most interesting part technically. Instead of just calculating a percentage, I built a 7-feature weighted linear regression model that maps raw performance to an IQ estimate.

Feature Extraction

const features = {
  accuracyScore,        // proportion of correct answers
  speedScore,           // based on average time per correct answer
  consistencyScore,     // penalises random correct answers (guessing)
  difficultyWeighted,   // harder correct answers worth more
  categoryBalance,      // uniform performance > spikey
  adaptiveScore,        // penalises timed-out questions
  educationNorm,        // calibrates for education baseline
  ageNorm,              // peak window (16-35) = 1.0
}

Speed scoring — not just "was it right" but "how quickly":

function calcSpeed(answers: TestAnswer[]): number {
  const correct = answers.filter(a => a.correct && !a.timedOut)
  const avg = correct.reduce((s, a) => s + a.timeSpent, 0) / correct.length
  if (avg < 6)  return 1.0
  if (avg < 10) return 0.9
  if (avg < 15) return 0.8
  if (avg < 20) return 0.7
  if (avg < 25) return 0.55
  return 0.4
}

Consistency scoring — detects guessing by measuring variance within each domain:

function calcConsistency(answers: TestAnswer[]): number {
  const byCategory: Record<string, boolean[]> = {}
  answers.forEach(a => {
    if (!byCategory[a.category]) byCategory[a.category] = []
    byCategory[a.category].push(a.correct)
  })

  let totalVariance = 0, categories = 0
  for (const cat in byCategory) {
    const results = byCategory[cat]
    if (results.length < 2) continue
    const mean = results.filter(Boolean).length / results.length
    const variance = results.reduce(
      (s, r) => s + Math.pow((r ? 1 : 0) - mean, 2), 0
    ) / results.length
    totalVariance += variance
    categories++
  }
  return clamp(1 - (totalVariance / categories) * 1.5, 0.3, 1.0)
}

If you get 3 correct and 3 wrong alternating in the same category, that high variance lowers your consistency score — which reduces your final IQ estimate.

The Regression

const WEIGHTS = {
  accuracy:      0.42,
  speed:         0.12,
  consistency:   0.10,
  difficulty:    0.22,
  balance:       0.08,
  adaptive:      0.06,
}

const rawLinear =
  WEIGHTS.accuracy  * accuracyScore         +
  WEIGHTS.speed     * speedScore            +
  WEIGHTS.consistency * consistencyScore    +
  WEIGHTS.difficulty  * difficultyWeighted  +
  WEIGHTS.balance   * categoryBalance       +
  WEIGHTS.adaptive  * adaptiveScore

Mapping to IQ Scale

Raw score (0–1) maps to IQ (70–145) using a z-score approach with the normal distribution:

// Map raw score to z-score, scale by education and age norms
const zScore = (rawScore - 0.5) * 4.2 * educationNorm * ageNorm

// IQ = mean + z * SD (mean=100, SD=15)
const iqEstimate = Math.round(clamp(100 + zScore * 15, 70, 145))

// 90% confidence interval
const ciMargin = Math.round(8 + (1 - consistencyScore) * 6)
const confidenceInterval = [iqEstimate - ciMargin, iqEstimate + ciMargin]

A raw score of 0.5 maps to exactly IQ 100 (average). A raw score of 1.0 maps to approximately IQ 135. Demographic norms adjust the z-score — a doctorate-level user (educationNorm = 1.07) needs a higher raw performance to achieve the same IQ estimate as an undergraduate (educationNorm = 1.0), reflecting calibration to education-group baselines.

The percentile is calculated using a proper normal distribution CDF approximated via the Abramowitz and Stegun error function:

function erf(x: number): number {
  const sign = x >= 0 ? 1 : -1; x = Math.abs(x)
  const a1=0.254829592, a2=-0.284496736, a3=1.421413741,
        a4=-1.453152027, a5=1.061405429, p=0.3275911
  const t = 1/(1+p*x)
  const y = 1-(((((a5*t+a4)*t)+a3)*t+a2)*t+a1)*t*Math.exp(-x*x)
  return sign*y
}

const percentile = Math.round(
  0.5 * (1 + erf((iqEstimate - 100) / (15 * Math.sqrt(2)))) * 100
)


Part 5: Per-User History Without a Backend

Session history is stored entirely in localStorage, keyed by a normalised username:

export function normaliseUserKey(name: string): string {
  return name.trim().toLowerCase().replace(/\s+/g, ' ')
}

This means "Om", "om", and "OM" all map to the same history bucket — but "Om" and "Rahul" are completely separate. No login required.

export function saveSession(profile, result, totalQ, correct, avgTime, diffRange) {
  const session: TestSession = {
    id: `session_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`,
    timestamp: Date.now(),
    userKey: normaliseUserKey(profile.name),
    iqEstimate: result.iqEstimate,
    categoryScores: result.categoryScores,
    mlFeatures: result.mlFeatures,
    difficultyRange: diffRange,
    // ...
  }
  const existing = getAllSessions()
  localStorage.setItem(STORAGE_KEY, JSON.stringify(
    [session, ...existing].slice(0, 100)
  ))
}

The History page fetches all sessions, groups them by userKey, and renders per-user filter tabs. The IQ trend chart (Recharts LineChart) shows your score trajectory across sessions. Domain averages accumulate lifetime category accuracy.


Part 6: The Neural Network Homepage

The homepage hero is a fully custom animated neural network rendered on a <canvas> element — no library, pure browser APIs.

38 nodes drift slowly across the canvas. Synaptic connections form between nodes within 160px of each other, with opacity proportional to distance. Signal particles spawn on random connections and travel along them with a glow effect.

function spawnSignal() {
  const from = Math.floor(Math.random() * nodes.length)
  // Find nearest neighbour within 180px
  let best = -1, bestDist = Infinity
  nodes.forEach((n, i) => {
    if (i === from) return
    const d = Math.hypot(n.x - nodes[from].x, n.y - nodes[from].y)
    if (d < 180 && d < bestDist) { bestDist = d; best = i }
  })
  if (best !== -1) signals.push({ fromIdx: from, toIdx: best, t: 0, ... })
}

// Signal particle rendering
signals.forEach(sig => {
  sig.t += sig.speed
  const from = nodes[sig.fromIdx], to = nodes[sig.toIdx]
  const x = from.x + (to.x - from.x) * sig.t
  const y = from.y + (to.y - from.y) * sig.t

  // Radial gradient glow
  const grad = ctx.createRadialGradient(x, y, 0, x, y, 8)
  grad.addColorStop(0, sig.color + 'dd')
  grad.addColorStop(1, sig.color + '00')
  ctx.fillStyle = grad
  ctx.arc(x, y, 8, 0, Math.PI * 2)
  ctx.fill()
})

It runs at 60fps on modern hardware and falls back gracefully on mobile.


What I Learned

1. Defining "adaptive" is harder than it sounds. My first version just randomised questions. Then I added difficulty tiers. Then age ranges. Then occupation tags. Each layer felt necessary once I had the previous one. The question is always: what dimensions of the user actually matter for question selection?

2. localStorage is surprisingly capable for personal data. No backend, no auth, no GDPR nightmare. For a tool that's genuinely private by design, browser storage is the right call — not a compromise.

3. Weighted regression beats percentage scoring immediately. When I switched from correct/total * 100 to the 7-feature model, the results suddenly felt more meaningful. A user who answers 12/20 quickly on hard questions scores very differently from one who answers 12/20 slowly on easy questions — as they should.

4. The canvas animation took longer than the ML engine. The neural network hero is purely cosmetic but it's what people notice first and share. Don't underestimate the value of a visually distinctive entry point.

5. People want to retake immediately. The most common feedback in the first week was "I want to try again." The anti-repeat system was added within 48 hours of launching. Build for the thing people actually do, not the thing you imagined they'd do.


Live Demo & Source

🔗 Try it: https://iq-platform-plum.vercel.app

Built during my final year B.Tech in Computer Science at COER University, Roorkee.

The platform is free, has no login, and stores nothing on a server. Questions are selected fresh for each session based on your profile, and the ML engine shows you a full breakdown of every feature that contributed to your score.

Would love your feedback — especially on the ML model weights and whether the adaptive selection feels right across different education levels. Drop a comment or connect on LinkedIn.


If you found this useful, consider leaving a reaction — it helps other developers find it. 🦄