{"id":34501350,"url":"https://github.com/haaziq386/keystroke_ai","last_synced_at":"2026-04-27T05:33:47.860Z","repository":{"id":329928689,"uuid":"1121036170","full_name":"Haaziq386/keystroke_AI","owner":"Haaziq386","description":"A biometric authentication system using keystroke dynamics with modified Manhattan distance metric. Implements digraph timing feature extraction and achieves 7.75% EER on free-text keystroke data. Course project for CSN-371 Artificial Intelligence.","archived":false,"fork":false,"pushed_at":"2025-12-22T10:46:46.000Z","size":6416,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-12-23T21:52:08.201Z","etag":null,"topics":["artificial-intelligence","authentication","biometric-authentication","data-processing","eer","equal-error-rate","feature-extraction","keystroke-dynamics","machine-learning","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Haaziq386.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-22T10:35:55.000Z","updated_at":"2025-12-22T10:50:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/Haaziq386/keystroke_AI","commit_stats":null,"previous_names":["haaziq386/keystroke_ai"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/Haaziq386/keystroke_AI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haaziq386%2Fkeystroke_AI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haaziq386%2Fkeystroke_AI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haaziq386%2Fkeystroke_AI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haaziq386%2Fkeystroke_AI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Haaziq386","download_url":"https://codeload.github.com/Haaziq386/keystroke_AI/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Haaziq386%2Fkeystroke_AI/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27992996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-12-24T02:00:07.193Z","response_time":83,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","authentication","biometric-authentication","data-processing","eer","equal-error-rate","feature-extraction","keystroke-dynamics","machine-learning","python"],"created_at":"2025-12-24T02:01:09.926Z","updated_at":"2025-12-24T02:01:50.120Z","avatar_url":"https://github.com/Haaziq386.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keystroke Dynamics Authentication System\n\n**Course Project:** CSN-371 Artificial Intelligence   \n**Instructor:** Prof. Pradumn K. Pandey  \n\nA biometric authentication system that identifies users based on their unique typing patterns using keystroke dynamics. This implementation uses digraph timing features and evaluates performance using the Equal Error Rate (EER) metric, based on research by Iapa \u0026 Cretu (2021).\n\n## 📋 Overview\n\nThis project implements a keystroke dynamics authentication system that:\n- Extracts timing features from keystroke data (digraphs)\n- Uses modified Manhattan distance metric for improved accuracy\n- Evaluates authentication performance using leave-one-out methodology\n- Compares standard and modified distance metrics\n- Analyzes the effect of feature selection on authentication accuracy\n\n## 🎯 Key Features\n\n- **Digraph Feature Extraction**: Analyzes timing patterns between consecutive keystrokes\n  - DU1: First key down to first key up (dwell time)\n  - DU2: Second key down to second key up (dwell time)\n  - DUtotal: First key down to second key up (total time)\n\n- **Modified Manhattan Distance**: Implements weighted distance metric with reduced weight for DUtotal features (default: 1/3)\n\n- **Multiple Normalization Techniques**:\n  - Decimal scaling for standard Manhattan distance\n  - Min-max scaling for modified Manhattan distance\n\n- **Comprehensive Evaluation**:\n  - Leave-one-out cross-validation\n  - FAR (False Accept Rate) and FRR (False Reject Rate) calculations\n  - EER (Equal Error Rate) computation\n  - Visualization of error rates vs. thresholds\n\n## 📁 Project Structure\n\n```\nkeystroke_AI/\n├── data/\n│   ├── raw/                    # Raw keystroke data files (user0001.txt - user0080.txt)\n│   └── processed/              # Processed feature vectors\n│       ├── all_features.csv\n│       ├── decimal_vectors.csv\n│       └── minmax_vectors.csv\n├── src/\n│   ├── data_processing.py      # Data loading and digraph extraction\n│   ├── feature_extraction.py   # Feature vector creation\n│   ├── metrics.py              # Distance metric implementations\n│   └── authentication.py       # Authentication logic and evaluation\n├── main.py                     # Main execution script\n└── README.md                   # This file\n```\n\n## 🚀 Getting Started\n\n### Prerequisites\n\n```bash\npip install numpy pandas matplotlib\n```\n\n### Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/Haaziq386/keystroke_AI.git\ncd keystroke_AI\n```\n\n2. Ensure your data is in the correct format in `data/raw/`:\n   - Files named `user####.txt` (e.g., `user0001.txt`)\n   - Format: `key_code event_type timestamp`\n     - `key_code`: ASCII code of the key\n     - `event_type`: 0 for press, 1 for release\n     - `timestamp`: Milliseconds since epoch\n\n### Usage\n\nRun the main script to process data and evaluate authentication:\n\n```bash\npython main.py\n```\n\nThis will:\n1. Process raw keystroke data files\n2. Extract digraph features\n3. Create and normalize feature vectors\n4. Compare standard vs. modified Manhattan distance metrics\n5. Evaluate the effect of different numbers of digraphs\n6. Generate visualization plots\n\n## 📊 Data Format\n\n### Raw Data Format\nEach user file contains keystroke events in the format:\n```\nkey_code event_type timestamp\n16 0 434889        # Key 16 pressed at time 434889\n86 0 435006        # Key 86 pressed at time 435006\n86 1 435146        # Key 86 released at time 435146\n16 1 435221        # Key 16 released at time 435221\n```\n\n### Feature Vector Format\nEach segment is represented by timing features for the most common digraphs:\n```\nsegment_id, user_id, [digraph]_DU1, [digraph]_DU2, [digraph]_DUtotal, ...\n```\n\n## 🔬 Methodology\n\n### 1. Data Processing\n- Load raw keystroke data\n- Match press and release events\n- Segment into chunks of ~1000 keystrokes\n\n### 2. Feature Extraction\n- Identify the most common digraphs (default: 12)\n- Calculate DU1, DU2, and DUtotal for each digraph\n- Create feature vectors using median values per segment\n\n### 3. Normalization\n- **Decimal Scaling**: For standard Manhattan distance\n- **Min-Max Scaling**: For modified Manhattan distance\n\n### 4. Authentication\n- Leave-one-out cross-validation\n- Distance calculation between feature vectors\n- Threshold-based classification\n- FAR/FRR/EER computation\n\n## 📈 Performance Metrics\n\n- **FAR (False Accept Rate)**: Percentage of impostor attempts incorrectly accepted\n- **FRR (False Reject Rate)**: Percentage of genuine attempts incorrectly rejected\n- **EER (Equal Error Rate)**: Point where FAR equals FRR (lower is better)\n\n## 🎨 Visualizations\n\nThe system generates several plots:\n- `Standard_Manhattan_Distance.png`: FAR/FRR curves for standard metric\n- `Modified_Manhattan_Distance.png`: FAR/FRR curves for modified metric\n- `Manhattan_Distance_Comparison.png`: Side-by-side comparison\n- `Digraph_Count_Effect.png`: EER vs. number of digraphs\n\n## 🔧 Configuration\n\n### Adjustable Parameters\n\nIn `main.py`:\n- `segment_size`: Number of keystrokes per segment (default: 1000)\n- `num_digraphs`: Number of most common digraphs to use (default: 12)\n\nIn `authentication.py`:\n- `du_total_weight`: Weight for DUtotal in modified distance (default: 1/3)\n\n## 📚 Module Reference\n\n### `KeystrokeProcessor`\nHandles raw data loading and preprocessing:\n- `read_raw_file(user_id)`: Load data for a specific user\n- `process_all_users()`: Process all users and extract digraphs\n- `extract_digraph_features(events)`: Calculate timing features\n\n### `KeystrokeFeatureExtractor`\nCreates feature vectors:\n- `identify_common_digraphs(all_features)`: Find most frequent digraphs\n- `create_feature_vectors(all_features)`: Build feature vectors\n\n### `KeystrokeMetrics`\nImplements distance metrics:\n- `manhattan_distance(v1, v2)`: Standard Manhattan distance\n- `modified_manhattan_distance(v1, v2)`: Weighted Manhattan distance\n\n### `KeystrokeAuthenticator`\nPerforms authentication and evaluation:\n- `leave_one_out_evaluation(feature_vectors)`: Cross-validation\n- `calculate_error_rates(evaluation_results, thresholds)`: Compute FAR/FRR/EER\n\n## 🧪 Experimental Results\n\nThe modified Manhattan distance metric with reduced DUtotal weight typically achieves:\n- Lower EER compared to standard Manhattan distance\n- Better discrimination between genuine and impostor attempts\n- Optimal performance with ~12 most common digraphs\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 📝 License\n\nThis project is open source and available under the MIT License.\n\n## 🙏 Acknowledgments\n\nThis implementation is based on research in keystroke dynamics authentication, particularly the use of digraph timing features and modified distance metrics for improved accuracy.\n\n## 📧 Contact\n\nFor questions or feedback, please open an issue on GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaaziq386%2Fkeystroke_ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhaaziq386%2Fkeystroke_ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhaaziq386%2Fkeystroke_ai/lists"}