danubePrediction - Examples

In the following, an example request and the according response using the danubePrediction endpoint are shown.

Note: This example assumes the rules have already been set as shown in the setRules example.

const testData = [
  {
    id: 0,
    title: "job-1",
    field: "Test/QA",
    salaryFrom: 36000,
    salaryTo: 50000,
    daysAgo: 240,
    companyType: "Startup",
    jobLevel: "Experienced",
    technologies: ["Python", "Java", "C++", "C"],
    benefits: ["Flexible working hours", "Team events"]
  },
  {
    id: 1,
    title: "job-2",
    field: "Software",
    salaryFrom: 42000,
    salaryTo: 60000,
    daysAgo: 100,
    companyType: "Established company",
    // jobLevel missing --> data may be incomplete
    technologies: ["Git", "Docker", "JavaScript"]
    // benefits missing --> data may be incomplete
  },
];

const stringifiedTestData = JSON.stringify(testData);

const testSearchData = {
  companyType: ["Startup"],
  jobLevel: ["Junior", "Experienced"],
  technologies: ["SQL", "Java", "Linux"],
  benefits: ["Flexible working hours", "Home office"]
};

const stringifiedTestSearchData = JSON.stringify(testSearchData);

POST https://api.danube.ai/graphql

body: {
  "query": "mutation ($data: PredictionInputData!) { danubePrediction(data: $data) { newColumnScores { property, score }, rowScores, rowMatches } }",
  "variables": {
    "data": {
      "rulesId": "my-rules-set-1",
      "data": {{stringifiedTestData}},
      "searchData": {{stringifiedTestSearchData}},
      "initialColumnScores": [
        {"property": "salaryFrom", "score": 1},
        {"property": "salaryTo", "score": 1},
        {"property": "daysAgo", "score": 0.5}, // might be initialized less important
        {"property": "companyType", "score": 1},
        {"property": "jobLevel", "score": 1},
        {"property": "technologies", "score": 2}, // might be initialized more important
        {"property": "benefits", "score": 1}
      ],
      "strategy": "mixed",
      "mixFactor": 0.75,
      "impact": 1
    }
  }
}

Returns

{
  "data": {
    "danubePrediction": {
      "newColumnScores": [
        {"property": "salaryFrom", "score": 0.97},
        {"property": "salaryTo", "score": 0.97},
        {"property": "daysAgo", "score": 1.15},
        {"property": "companyType", "score": 0.70},
        {"property": "jobLevel", "score": 1.56},
        {"property": "technologies", "score": 1.20},
        {"property": "benefits", "score": 0.95}
      ],
      "rowScores": [3.99, 2.61, ...],
      "rowMatches": [
        [0.83, 0.83, 0.00, 1.00, 0.00, 1.00, 0.50],
        [1.00, 1.00, 0.58, 0.00, 0.00, 0.00, 0.00],
        ...
      ]
    }
  }
}