{
  "$schema": "https://schema.org",
  "@context": {
    "schema": "https://schema.org/",
    "biascraft": "https://biascraft.local/ontology#",
    "nodes": "biascraft:nodes",
    "edges": "biascraft:edges"
  },
  "@type": "Dataset",
  "name": "BiasCraft Model and Dataset Graph",
  "description": "Machine-readable knowledge graph for the BiasCraft AI-bias simulation app, including model inputs, candidate fields, API endpoint, metrics, and relationships.",
  "application": {
    "@type": "SoftwareApplication",
    "name": "BiasCraft",
    "applicationCategory": "EducationalApplication",
    "operatingSystem": "Web",
    "description": "Interactive simulation showing how feature weights affect hiring-model fairness and accuracy."
  },
  "api": {
    "baseUrlEnvironmentVariable": "VITE_API_BASE_URL",
    "endpoints": [
      {
        "id": "run-model",
        "method": "POST",
        "path": "/run-model",
        "requestBody": {
          "education": "number from 0 to 1",
          "experience": "number from 0 to 1",
          "location": "number from 0 to 1"
        },
        "responseBody": {
          "metrics": {
            "accuracy": "number from 0 to 1",
            "fairness": "number from 0 to 1",
            "final_score": "number from 0 to 1",
            "sf_rate": "number from 0 to 1",
            "non_sf_rate": "number from 0 to 1",
            "male_rate": "number from 0 to 1",
            "female_rate": "number from 0 to 1"
          },
          "alerts": "array of strings describing detected bias patterns",
          "sample_candidates": "array of selected candidate records sampled from the simulation"
        }
      }
    ]
  },
  "dataset": {
    "source": "backend/data/candidates.json",
    "generator": "backend/generate_data.py",
    "recordCount": 200,
    "fields": [
      { "name": "id", "type": "integer", "description": "Candidate identifier" },
      { "name": "name", "type": "string", "description": "Synthetic candidate name" },
      { "name": "gender", "type": "category", "values": ["Male", "Female", "Non-Binary"] },
      { "name": "location", "type": "category", "values": ["San Francisco", "Remote", "International"] },
      { "name": "education", "type": "number", "range": [0, 100] },
      { "name": "experience", "type": "number", "range": [0, 15] },
      { "name": "true_potential", "type": "number", "range": [0, 100] },
      { "name": "hired_ground_truth", "type": "binary", "values": [0, 1] }
    ],
    "knownBiasInjection": "San Francisco candidates receive a +10 education boost before ground-truth calculation."
  },
  "nodes": [
    { "id": "app", "label": "BiasCraft app", "type": "application" },
    { "id": "weights", "label": "Model weights", "type": "input" },
    { "id": "education_weight", "label": "Education weight", "type": "input_feature" },
    { "id": "experience_weight", "label": "Experience weight", "type": "input_feature" },
    { "id": "location_weight", "label": "Location bias weight", "type": "input_feature" },
    { "id": "candidate_dataset", "label": "Synthetic candidates", "type": "dataset" },
    { "id": "weighted_sum_model", "label": "Weighted-sum hiring model", "type": "model" },
    { "id": "selection_threshold", "label": "Top 30 percent selection threshold", "type": "decision_rule" },
    { "id": "metrics", "label": "Simulation metrics", "type": "output" },
    { "id": "accuracy", "label": "Accuracy", "type": "metric" },
    { "id": "fairness", "label": "Fairness", "type": "metric" },
    { "id": "final_score", "label": "Final score", "type": "metric" },
    { "id": "bias_alerts", "label": "Bias alerts", "type": "output" }
  ],
  "edges": [
    { "from": "app", "to": "weights", "relationship": "collects" },
    { "from": "weights", "to": "education_weight", "relationship": "contains" },
    { "from": "weights", "to": "experience_weight", "relationship": "contains" },
    { "from": "weights", "to": "location_weight", "relationship": "contains" },
    { "from": "candidate_dataset", "to": "weighted_sum_model", "relationship": "is_scored_by" },
    { "from": "weights", "to": "weighted_sum_model", "relationship": "parameterizes" },
    { "from": "weighted_sum_model", "to": "selection_threshold", "relationship": "feeds" },
    { "from": "selection_threshold", "to": "metrics", "relationship": "produces" },
    { "from": "metrics", "to": "accuracy", "relationship": "contains" },
    { "from": "metrics", "to": "fairness", "relationship": "contains" },
    { "from": "metrics", "to": "final_score", "relationship": "contains" },
    { "from": "metrics", "to": "bias_alerts", "relationship": "triggers" }
  ],
  "formulas": {
    "location_val": "1 if location is San Francisco, otherwise 0",
    "pred_score": "(education / 100) * education_weight + (experience / 15) * experience_weight + location_val * location_weight",
    "selected": "1 when pred_score is greater than or equal to the 70th percentile threshold",
    "accuracy": "mean(selected == hired_ground_truth)",
    "location_disparity": "absolute difference between San Francisco and non-San Francisco selection rates",
    "gender_disparity": "absolute difference between male and female selection rates",
    "fairness": "1 - average(location_disparity, gender_disparity)",
    "final_score": "fairness * 0.6 + accuracy * 0.4"
  }
}
