AI-Assisted Web-based Forensic Analysis Prototyping

Customer: AI | Published: 16.04.2026
Бюджет: 250 $

I need you to build this project as a full functional web-based diploma prototype, with the machine learning part designed to be more accurate, more reliable, and more realistic in practice. The project is: **Development of a web system with MySQL and integrated machine learning for the preliminary classification, prioritization, and statistical analysis of suspicious death cases in Albania, with mandatory expert verification and correction.** Use this stack only: * Backend: Python Flask * Database: MySQL * Frontend: HTML, CSS, Bootstrap 5 * Charts: Chart.js * ORM: SQLAlchemy * Auth: Flask-Login * Validation: Flask-WTF or equivalent * Password hashing: Werkzeug security * Machine Learning: scikit-learn * Model saving: joblib * Data processing: pandas, numpy Very important requirements: 1. **Everything must be built from scratch.** 2. **Do not use any premade dataset.** 3. **Do not use any downloaded/public dataset.** 4. **Do not use any pretrained or premade model.** 5. **Do not use any external AI/API for classification.** I need an **original improvised synthetic dataset** created by you from scratch specifically for this project. It must be realistic enough for prototype training/testing, but it will only be temporary, because later I will replace it with real data. So the whole system must be designed so that the synthetic dataset can be swapped out easily and the model can be retrained from scratch on real data later. The synthetic dataset must: * be generated by custom Python code * use logical forensic-like patterns, not random rows * include realistic class distributions * include some missing values * include some borderline/noisy cases * include some contradictory cases * have labels generated logically from feature combinations, not randomly Required outputs for the dataset part: * `dataset/cases_synthetic.csv` * `dataset/data_dictionary.md` * `app/ml/generate_synthetic_dataset.py` The ML system must be a **decision support system**, not a blind automatic classifier. The intended flow is: * user enters a case * system stores it in MySQL * ML model gives a preliminary prediction * system shows confidence/probabilities * expert reviews it * expert can confirm or change the final classification * system stores both model output and final expert decision * system stores audit history Classification categories: * Suspected homicide * Suspected suicide * Suspected accident * Suspicious natural death * Undetermined cause User roles: * Admin * Operator/Expert Admin should: * manage users * manage all cases * see dashboards/statistics * see audit logs * see model versions / ML metrics Operator/Expert should: * create/edit cases * view model prediction * view confidence and probabilities * assign final classification * add expert comment * update case status and priority Core features required: * login/logout/session management * role-based access control * full CRUD for cases * search/filter cases * dashboard with statistics and charts * ML prediction module * case details page * expert verification/correction workflow * audit log The case form must use mostly **structured fields**, not too much free text, because the model should rely mainly on structured data. Include fields such as: * case code * case date * age * gender * region * scene/location * injury type * violence indicators * toxicology * medical history * circumstances of finding * case status * priority Also add more structured ML-useful fields such as: * age group * urban/rural * found indoors/outdoors * external trauma yes/no * head trauma yes/no * neck trauma yes/no * thorax trauma yes/no * limb trauma yes/no * burns yes/no * sharp-force injury yes/no * firearm injury yes/no * strangulation signs yes/no * struggle signs yes/no * defensive wounds yes/no * estimated number of injuries * decomposition yes/no * alcohol positive yes/no * drugs positive yes/no * suspected poisoning yes/no * cardiac disease yes/no * chronic disease yes/no * psychiatric history yes/no * substance abuse history yes/no * previous suicide attempts yes/no * vehicle involved yes/no * weapon found yes/no * suicide note yes/no * witnesses yes/no * reported conflict yes/no * workplace incident yes/no * road incident yes/no * body found in water yes/no * estimated time since finding * preliminary autopsy assessment * data completeness level Use free-text only where really needed, such as short circumstances description and expert comment. Before prediction, validate the input and score data quality. I need: * input validation * impossible value checks * missing critical field count * inconsistency flags * contradiction flags * input quality score * data completeness percentage If the case data is weak, incomplete, or contradictory, the system must not behave as if the prediction is highly reliable. For machine learning, I need a full pipeline: * data loading * schema validation * cleaning * missing value handling * feature engineering * encoding * train/validation/test split * cross-validation * model training * hyperparameter tuning * probability calibration * threshold tuning * evaluation * model saving * model versioning * prediction integration into Flask Use proper scikit-learn pipeline components such as: * Pipeline * ColumnTransformer * SimpleImputer * OneHotEncoder * Stratified splits * StratifiedKFold * GridSearchCV or RandomizedSearchCV I want feature engineering implemented clearly and reproducibly, for example: * age_group * violent_pattern_score * medical_risk_score * toxicology_risk_score * scene_risk_score * data_completeness_ratio * contradiction_count * injury_severity_bucket * number_of_positive_flags Test at least these models: * Logistic Regression * Decision Tree * Random Forest * Extra Trees * Gradient Boosting or HistGradientBoosting The final model must **not** be selected based only on accuracy. Evaluate and compare using: * accuracy * balanced accuracy * precision * recall * F1-score * macro F1 * weighted F1 * confusion matrix * cross-validation stability * calibration quality * feature importance / coefficient summary Also do **probability calibration**, because I need the confidence score to be more trustworthy. Do not just display raw model probability as if it is fully reliable. Use calibrated probabilities and compare raw vs calibrated confidence if needed. Also implement **threshold tuning / abstention logic**: * if confidence is too low, flag the case as uncertain * if top two classes are too close, flag the case as ambiguous * if data completeness is too low, mark prediction reliability as low * if contradictions are too high, push it toward expert review or undetermined classification So the prediction result should store and show: * predicted_class * raw_confidence * calibrated_confidence * probabilities for all classes * top_2_classes * uncertainty_flag * input_quality_score * contradiction_count * model_version_id * prediction_date Very important: prevent **data leakage**. Do not train the model using fields that are only known after final expert review. Do not use fields like: * final_class * expert_comment * final decision timestamps * prior prediction outputs * audit log fields Database tables should include at least: * users * cases * predictions * final_classifications * audit_logs * model_versions The system should store: * model prediction * final expert classification * whether expert agreed with model * reason for correction * full audit history For expert correction, include structured correction reasons such as: * missing information * contextual evidence * contradiction in data * model low confidence * expert forensic judgment * other Dashboard/statistics should include: * total cases * cases by region * cases by gender * cases by category * cases over time * high-priority cases * low-confidence cases * unresolved/uncertain cases * model vs expert agreement rate * expert correction counts * active model version * average confidence by class Also include an **ML monitoring page** showing: * active model version * dataset version * key metrics * confusion matrix * calibration status * number of low-confidence predictions * number of expert corrections Project structure should be clean and modular, for example: * app/ * models/ * routes/ * forms/ * services/ * ml/ * templates/ * static/ * migrations/ * dataset/ * trained_models/ * reports/ * scripts/ * tests/ * run.py * requirements.txt * README.md I also need: * SQL schema * SQLAlchemy models * Flask routes * Bootstrap templates * training pipeline * evaluation scripts * prediction integration * synthetic dataset generator * seed logic if needed * testing * local run instructions Create the whole thing in a clean implementation order: 1. project structure 2. database schema 3. models 4. routes 5. services 6. templates 7. synthetic dataset generation 8. preprocessing 9. model training 10. tuning 11. calibration 12. threshold tuning 13. evaluation 14. model saving/loading 15. Flask integration 16. dashboard/statistics 17. testing 18. final run instructions Finally, I need a file named **`TEXT.md`** at the end. `TEXT.md` must contain very clear, practical, step-by-step instructions explaining: * how the whole project is structured * how the synthetic dataset was generated * how labels were created logically * how preprocessing works * how feature engineering works * how training works * how tuning/calibration work * how prediction is integrated into Flask * how to run the app locally * how to regenerate the dataset * how to retrain the model from scratch * how to replace the synthetic dataset with real data * how to update the database if needed * how to test the app * what each important file/folder does The instructions in `TEXT.md` must be detailed enough that I can follow them without guessing. Do not leave vague instructions. I need exact, practical guidance for each step.