Get revscoring drafttopic prediction

POST /service/lw/inference/v1/models/{wiki}-drafttopic:predict

Get a score from the Revscoring Draft Topic model (previously hosted on ORES) for a given Wiki revision id.

Examples

curl

Anonymous access

# Get a score from the Revscoring Draft Topic model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-drafttopic:predict -X POST -d '{"rev_id": 12345}' -H "Content-type: application/json"

Logged in access

# Get a score from the Revscoring Draft Topic model for the revision 12345 of English Wikipedia.
$ curl https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-drafttopic:predict -X POST -d '{"rev_id": 12345}' -H "Authorization: Bearer YOUR_ACCESS_TOKEN" -H "Content-type: application/json"

Python

# Python 3
# Get a score from the Revscoring Draft Topic model for the revision 12345 of English Wikipedia.

import json
import requests

use_auth = False
inference_url = 'https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-drafttopic:predict'

if use_auth:
  headers = {
      'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
      'User-Agent': 'YOUR_APP_NAME (YOUR_EMAIL_OR_CONTACT_PAGE)',
      'Content-type': 'application/json'
  }
else:
  headers = {}
data = {"rev_id": 12345 }
response = requests.post(inference_url, headers=headers, data=json.dumps(data))
print(response.json())

JavaScript

/*
Get a score from the Revscoring Draft Topic model for the revision 12345 of English Wikipedia.
*/

const inferenceUrl = "https://api.wikimedia.org/service/lw/inference/v1/models/enwiki-drafttopic:predict";
const accessToken = "YOUR_ACCESS_TOKEN";
const appName = "YOUR_APP_NAME";
const email = "YOUR_EMAIL_OR_CONTACT_PAGE";
let headers = new Headers({
    "Content-Type": "application/json",
    "Authorization": "Bearer " + accessToken,
    "Api-User-Agent": appName + " ( " + email + " )"
});
let data = {"rev_id": 12345 };

fetch(inferenceUrl, {
    method: "POST",
    headers: headers,
    body: JSON.stringify(data)
})
.then(response => response.json())
.then(inferenceData => console.log(inferenceData));

URI Parameters

wiki

required

Wiki code:enwiki (English).

POST Parameters

rev_id

required

Wiki Revision id: integer related to a certain revision id for the Wiki set in the URI parameter.
extended_output Whether or not the response should include the extended output of the model (like the list of features used etc..). Either true or false. Default: false

Responses

200 Success: Revision id found. Returns a Revscoring score object.
Example
{
  "enwiki": {
    "models": {
      "drafttopic": {
        "version": "1.3.0"
      }
    },
    "scores": {
      "12345": {
        "drafttopic": {
          "score": {
            "prediction": [
              "STEM.STEM*"
            ],
            "probability": {
              "Culture.Biography.Biography*": 0.022902630539395685,
              "Culture.Biography.Women": 0.005067486633806841,
              "Culture.Food and drink": 0.011552909215159848,
              "Culture.Internet culture": 0.0018836356548609828,
              "Culture.Linguistics": 0.000987244438369833,
              "Culture.Literature": 0.0050423059095638205,
              "Culture.Media.Books": 0.0008228825281107042,
              "Culture.Media.Entertainment": 0.027835523391703726,
              "Culture.Media.Films": 0.0021233422398979594,
              "Culture.Media.Media*": 0.10369183346752998,
              "Culture.Media.Music": 0.005345021766065545,
              "Culture.Media.Radio": 4.71813720695922e-05,
              "Culture.Media.Software": 0.010991013112889197,
              "Culture.Media.Television": 0.003745806852443267,
              "Culture.Media.Video games": 0.0012726195754468794,
              "Culture.Performing arts": 0.0011692106165364648,
              "Culture.Philosophy and religion": 0.012211366011815949,
              "Culture.Sports": 0.008617259930690756,
              "Culture.Visual arts.Architecture": 0.015175202598187623,
              "Culture.Visual arts.Comics and Anime": 0.0004580529412803368,
              "Culture.Visual arts.Fashion": 0.0032463316804348247,
              "Culture.Visual arts.Visual arts*": 0.04966240731500535,
              "Geography.Geographical": 0.006501819685165024,
              "Geography.Regions.Africa.Africa*": 0.004278923507426861,
              "Geography.Regions.Africa.Central Africa": 0.0003367596839992931,
              "Geography.Regions.Africa.Eastern Africa": 3.092351159122444e-05,
              "Geography.Regions.Africa.Northern Africa": 0.0001802204967553657,
              "Geography.Regions.Africa.Southern Africa": 0.0018079996950138254,
              "Geography.Regions.Africa.Western Africa": 0.0007251088049127748,
              "Geography.Regions.Americas.Central America": 0.0004991928760763337,
              "Geography.Regions.Americas.North America": 0.006380070962953918,
              "Geography.Regions.Americas.South America": 0.0002306844502170147,
              "Geography.Regions.Asia.Asia*": 0.017313494735674808,
              "Geography.Regions.Asia.Central Asia": 0.0008072328532154094,
              "Geography.Regions.Asia.East Asia": 0.0023203835158971666,
              "Geography.Regions.Asia.North Asia": 0.00045870078954648444,
              "Geography.Regions.Asia.South Asia": 0.0009922199817278582,
              "Geography.Regions.Asia.Southeast Asia": 0.0002738236138644238,
              "Geography.Regions.Asia.West Asia": 0.004635726599288032,
              "Geography.Regions.Europe.Eastern Europe": 0.001716235984380361,
              "Geography.Regions.Europe.Europe*": 0.0077942173009087345,
              "Geography.Regions.Europe.Northern Europe": 0.0007906624707708472,
              "Geography.Regions.Europe.Southern Europe": 0.0013950233741366756,
              "Geography.Regions.Europe.Western Europe": 0.0020105862970372567,
              "Geography.Regions.Oceania": 0.005480678538779058,
              "History and Society.Business and economics": 0.010849117305548793,
              "History and Society.Education": 0.0006190153665937547,
              "History and Society.History": 0.0075245897065247735,
              "History and Society.Military and warfare": 0.0016535860240798408,
              "History and Society.Politics and government": 0.04792153752537525,
              "History and Society.Society": 0.0062335927532809815,
              "History and Society.Transportation": 0.0006034027160506236,
              "STEM.Biology": 0.008912249418159286,
              "STEM.Chemistry": 0.006101030851625054,
              "STEM.Computing": 0.09725027056674931,
              "STEM.Earth and environment": 0.013754905599942706,
              "STEM.Engineering": 0.0007519463706161267,
              "STEM.Libraries & Information": 0.0026560386120175325,
              "STEM.Mathematics": 0.037996709648705176,
              "STEM.Medicine & Health": 0.12580483337522344,
              "STEM.Physics": 0.004410180324962277,
              "STEM.STEM*": 0.9465090911647787,
              "STEM.Space": 0.003443873426925551,
              "STEM.Technology": 0.06698348905685471
            }
          }
        }
      }
    }
  }
}