Skip to content

Instantly share code, notes, and snippets.

View Ladsgroup's full-sized avatar

Amir Sarabadani Ladsgroup

View GitHub Profile
@Ladsgroup
Ladsgroup / meta.py
Created December 29, 2015 21:08
OOP tests
class FeatureTestCase:
"""docstring for FeatureTestCase"""
def __init__(self, name):
super(FeatureTestCase, self).__init__()
self.name = name
def test_pickle(test_case):
return eq_(pickle.loads(pickle.dumps(test_case)), test_case)
@Ladsgroup
Ladsgroup / test.py
Created December 30, 2015 15:47
Qualifier test
import json
import pywikibase
with open('alan_touring.json', 'r') as f:
res = json.loads(f.read())
item = pywikibase.ItemPage()
item.get(res)
qua = 0
for p_number in item.claims:
claim = item.claims[p_number]
import urllib.request
import json
with open('/home/ladsgroup/res_aaron.txt', 'r') as f:
res = f.read().split('\n')[1:]
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i+n]
from revscoring.features.modifiers import not_, log
from revscoring.features.revision_oriented import revision
from revscoring.datasources.revision_oriented import revision as revision_datasource
from revscoring.features.wikibase.datasources.revision_oriented import Revision
from revscoring.features.wikibase.features.revision_oriented import Revision as it_is_driving_me_crazy
revision_wikibase_datasource = Revision('wikibase.revision', revision_datasource)
wikibase_revision = it_is_driving_me_crazy('wikibase.revision', revision_wikibase_datasource)
from ipaddress import ip_address
try:
ip_address(user.name)
except ValueError:
return False
else:
return True
{
"continue": {
"rvcontinue": "20151226095623|696846306",
"continue": "||"
},
"query": {
"pages": {
"15580374": {
"pageid": 15580374,
"ns": 0,
@Ladsgroup
Ladsgroup / enwiki, damaging
Last active May 3, 2016 20:01
Analysis of models
AUC of the classifier: 0.91944
f0.125-score (thrashhold, precision, recall, edits to review, total edits): 0.974, 0.875, 0.075269, 16, 4960 (0.32258%)
f0.25-score (thrashhold, precision, recall, edits to review, total edits): 0.931, 0.78049, 0.17204, 41, 4960 (0.82661%)
f0.5-score (thrashhold, precision, recall, edits to review, total edits): 0.892, 0.67606, 0.25806, 71, 4960 (1.4315%)
f1-score (thrashhold, precision, recall, edits to review, total edits): 0.847, 0.53571, 0.40323, 140, 4960 (2.8226%)
f2-score (thrashhold, precision, recall, edits to review, total edits): 0.749, 0.25, 0.73118, 544, 4960 (10.968%)
f3-score (thrashhold, precision, recall, edits to review, total edits): 0.749, 0.25, 0.73118, 544, 4960 (10.968%)
f4-score (thrashhold, precision, recall, edits to review, total edits): 0.578, 0.14734, 0.9086, 1147, 4960 (23.125%)
"""
``time_scorer -h``
::
Tests a scorer model. This utility expects to get a file of
tab-separated feature values and labels from which to test a model.
Usage:
time_scorer -h | --help
time_scorer <wiki> [--revs=<path>] [--model=<model>] [--batch]
from collections import OrderedDict
import json
import os
path = '.'
i18n_dir = os.path.join(path, 'i18n')
js_file = os.path.join(path, 'wsgi/static/js/wikiLabels/wikiLabels.js')
i18n = {}
for lang_file in os.listdir(i18n_dir):
@Ladsgroup
Ladsgroup / After PR 268.md
Created April 29, 2016 18:45
Feature extraction stats

Extracting 77 features

stat value
extractions 148
total_time 81.527
min_time 0.114
max_time 3.539
mean_time 0.551
median_time 0.337