Algorithm Search⌘K

Algorithmadvanced

TruthFinder

Also called TruthFinder algorithm.

Iterate between the trust of sources and the confidence of the facts they claim, with similar facts supporting each other and conflicting facts counting against each other.

Time
O(k n d) worst · averageO(n d) best
Space
O(n) extra
Where
d = the largest number of different facts on one object; k = the number of iterations; n = the number of claims
Properties
deterministicnot exactnot externalnot in placeofflineiterative
Origin
Xiaoxin Yin, Jiawei Han, Philip S. Yu, 2007

TruthFinder is an algorithm for truth discovery: many sources make claims about the same objects, the claims conflict, and the task is to pick the true value of each object without labels. TruthFinder gives each source a trust and each fact a confidence. The confidence of a fact grows with the trust of the sources that claim it, and the trust of a source is the mean confidence of its facts. It runs the two steps in turn until the trust values stop changing in direction. It also lets a fact gain support from similar facts on the same object and lose support to conflicting ones. The page truth discovery states the problem and compares the other methods; this page gives TruthFinder in full. Its equations are heuristics with a probabilistic reading. There is no proof that the iteration converges or that it finds the truth.

In plain words

Many web sites list the authors of the same books, and they do not agree. You do not know which sites to believe. TruthFinder starts by trusting every site the same. A fact that many trusted sites give gets a high score. A site whose facts have high scores becomes more trusted. Then the scores are computed again with the new trust, and so on, until the trust values settle. Facts that are close to each other, such as two spellings of one author list, help each other. Two different answers to the same question count against each other. At the end, for each book, you take the answer with the highest score.

The problem

The input is a set of claims (w,o,v)(w, o, v): source ww says that object oo has value vv. A fact is a pair f=(o,v)f = (o, v). W(f)W(f) is the set of sources that claim ff, and F(w)F(w) is the set of facts of ww. An optional implication imp(f′→f)∈[−1,1]\mathrm{imp}(f' \to f) \in [-1, 1], for two facts on the same object, says how much f′f' supports ff: positive for similar values, negative for values that exclude each other. The paper uses imp(f′→f)=sim(f′,f)−base_sim\mathrm{imp}(f' \to f) = \mathrm{sim}(f', f) - \mathit{base\_sim}, with base_sim=0.5\mathit{base\_sim} = 0.5 on its book data. The output is a confidence s(f)s(f) for each fact, a trust t(w)t(w) for each source, and for each object the fact with the largest confidence.

The algorithm

  1. TruthFinder(claims, imp, t0, ρ, γ, δ, T)
  2. 1for each source w do t(w) ← t0 ▷ t0 = 0.9 in the paper
  3. 2repeat
  4. 3for each source w do τ(w) ← -ln(1 - t(w))
  5. 4for each fact f do σ(f) ← Σ over w in W(f) of τ(w)
  6. 5for each fact f do σ*(f) ← σ(f) + ρ · Σ over f' ≠ f on the same object of σ(f') · imp(f' → f)
  7. 6for each fact f do s(f) ← 1 / (1 + e^(-γ · σ*(f)))
  8. 7t_old ← t; for each source w do t(w) ← the mean of s(f) over f in F(w)
  9. 8until 1 - cos(t_old, t) < δ or T iterations are done
  10. 9return s, t, and for each object the fact with the largest s

Lines L3 and L4 are the basic model. If each source is right with probability t(w)t(w), independently, then 1−e−σ(f)=1−∏w∈W(f)(1−t(w))1 - e^{-\sigma(f)} = 1 - \prod_{w \in W(f)} (1 - t(w)) is the probability that at least one source of ff is right (Lemma 1 of the paper). Working with τ=−ln⁡(1−t)\tau = -\ln(1 - t) turns the product into a sum. Line L5 adds the support of the other facts on the same object, weighted by ρ\rho. Line L6 uses the logistic function instead of 1−e−σ∗1 - e^{-\sigma^*}, for two reasons: σ∗\sigma^* can be negative, and sources copy each other, so the dampening factor γ<1\gamma < 1 makes the evidence count less than independence would say. Line L8 compares the direction of the trust vectors with cosine similarity. The paper uses ρ=0.5\rho = 0.5, γ=0.3\gamma = 0.3 and δ=0.001%\delta = 0.001\%. The cap TT is not in the paper; the implementation adds it so that the loop always stops.

Example

Three sources and three books. The implication is −0.5-0.5 between two different values of the same book, and the parameters are those of the paper.

source b1 b2 b3
A x x x
B y y
C x x

For b1 the vote is a tie between x and y.

Iteration 1. All trusts are 0.9, so τ=−ln⁡0.1=2.303\tau = -\ln 0.1 = 2.303 for every source. For b1, σ(x)=σ(y)=2.303\sigma(x) = \sigma(y) = 2.303, and each loses 0.5⋅0.5⋅2.3030.5 \cdot 0.5 \cdot 2.303 to the other, so σ∗=1.727\sigma^* = 1.727 and s=0.627s = 0.627 for both. For b2, σ(x)=4.605\sigma(x) = 4.605 and σ(y)=2.303\sigma(y) = 2.303, so σ∗(x)=4.030\sigma^*(x) = 4.030 and σ∗(y)=1.151\sigma^*(y) = 1.151, which give s=0.770s = 0.770 and 0.5850.585. For b3, s(x)=0.799s(x) = 0.799. The new trusts are the means: A = 0.732, B = 0.606, C = 0.785.

Iteration 2. A is now trusted more than B, so for b1 the confidence of x is 0.581 and that of y is 0.545. The tie is broken in favour of A.

The loop stops after 5 iterations, with trusts A = 0.611, B = 0.529 and C = 0.638 and the answer x for all three books. The trusts fall below 0.9 in every iteration, because the logistic function with γ=0.3\gamma = 0.3 keeps the confidences between 0.5 and 0.8 here.

A larger run. On generated data with 200 objects, 4 sources that are right 90% of the time and claim half of the objects, and 20 sources that are right 30% of the time, claim 15% of the objects and usually agree on one wrong value (Python seed 42, 1025 claims), the vote is right on 63% of the objects. TruthFinder is right on 72% without implications and 73% with the implication above, after 3 and 5 iterations. These numbers are measurements on that data only.

Correctness

TruthFinder is a heuristic, so the claims that can be proved are about what it computes. All trust values stay strictly between 0 and 1, so every logarithm in line L3 is defined and every confidence is strictly between 0 and 1. When all trusts are equal and the implication is 0 or a fixed negative constant, the first iteration ranks the facts of each object by their number of sources, as a vote does; later iterations change the answers only through the trusts. The loop stops after at most TT iterations. There is no proof that the trusts converge, that the limit is unique, or that the facts with the highest confidence are true. The full statements are in the proof page.

Proof: TruthFinder computes well-defined trust and confidence values, stops, and starts as a votefull

We use the pseudocode of the page. WW is the set of sources, each fact ff is a pair (object, value), W(f)W(f) is the set of sources that claim ff, and F(w)F(w) is the set of facts that ww claims, which is not empty. The implication imp(f′→f)\mathrm{imp}(f' \to f) is a number in [−1,1][-1, 1], and 0<t0<10 < t_0 < 1, ρ≥0\rho \ge 0, γ>0\gamma > 0, δ≥0\delta \ge 0, and the cap T≥1T \ge 1.

TruthFinder is a heuristic: nothing here says that the facts with the highest confidence are true, and nothing says that the iteration converges. The claims below are about what the method computes.

Lemma 1 (the values are defined). At the start of each iteration, 0<t(w)<10 < t(w) < 1 for every source. In each iteration every τ(w)\tau(w), σ(f)\sigma(f), σ∗(f)\sigma^*(f) is a finite real number, and 0<s(f)<10 < s(f) < 1.

Proof. By induction on the iterations. Line L1 sets t(w)=t0∈(0,1)t(w) = t_0 \in (0, 1). If 0<t(w)<10 < t(w) < 1, then 1−t(w)∈(0,1)1 - t(w) \in (0, 1), so τ(w)=−ln⁡(1−t(w))\tau(w) = -\ln(1 - t(w)) in line L3 is a finite positive number. Line L4 sums finitely many of them, and line L5 adds a finite sum of finite terms. Line L6 applies the logistic function x↦1/(1+e−γx)x \mapsto 1/(1 + e^{-\gamma x}), whose values lie strictly between 0 and 1 for every real xx. Line L7 sets t(w)t(w) to a mean of values in (0,1)(0, 1) over the non-empty set F(w)F(w), which again lies in (0,1)(0, 1). □\square

In floating point, s(f)s(f) can round to 1 when γσ∗(f)\gamma \sigma^*(f) is very large; the implementation keeps 1−t(w)1 - t(w) away from 0 before it takes the logarithm.

Lemma 2 (the meaning of σ\sigma). For each fact, 1−e−σ(f)=1−∏w∈W(f)(1−t(w))1 - e^{-\sigma(f)} = 1 - \prod_{w \in W(f)} (1 - t(w)).

Proof. e−σ(f)=∏w∈W(f)e−τ(w)=∏w∈W(f)(1−t(w))e^{-\sigma(f)} = \prod_{w \in W(f)} e^{-\tau(w)} = \prod_{w \in W(f)} (1 - t(w)). □\square

So, if each source is right with probability t(w)t(w), independently of the others, 1−e−σ(f)1 - e^{-\sigma(f)} is the probability that at least one source of ff is right. This is the basic model of Yin, Han and Yu; lines L5 and L6 then change it, and the independence is an assumption, not a fact about the data. The logistic function with γ<1\gamma < 1 is their correction for sources that copy each other, and it is a heuristic.

Lemma 3 (the first iteration is a vote). Suppose imp=0\mathrm{imp} = 0, or imp(f′→f)=−c\mathrm{imp}(f' \to f) = -c with a constant c≥0c \ge 0 for any two different facts on one object. Then after the first iteration, for any two facts f,gf, g on the same object, s(f)>s(g)s(f) > s(g) if and only if ∣W(f)∣>∣W(g)∣|W(f)| > |W(g)|.

Proof. In the first iteration every source has t=t0t = t_0, so τ(w)=τ0=−ln⁡(1−t0)>0\tau(w) = \tau_0 = -\ln(1 - t_0) > 0 and σ(f)=τ0kf\sigma(f) = \tau_0 k_f with kf=∣W(f)∣k_f = |W(f)|. Let KK be the sum of kf′k_{f'} over the facts f′f' on the object of ff. Then

σ∗(f)=τ0kf−ρcτ0(K−kf)=τ0((1+ρc)kf−ρcK),\sigma^*(f) = \tau_0 k_f - \rho c \tau_0 (K - k_f) = \tau_0 \big( (1 + \rho c) k_f - \rho c K \big),

which grows strictly with kfk_f, since KK is the same for ff and gg. The logistic function is strictly increasing. □\square

So the answers after one iteration are those of a vote, up to ties, and the later iterations change the answers only through the trust values. The tests check this on generated data.

Termination. Each pass of lines L3 to L8 counts one iteration, and line L8 stops the loop when the iteration count reaches TT, whatever the values. So the loop stops after at most TT iterations. It can stop earlier, when 1−cos⁡(told,t)<δ1 - \cos(t_{\text{old}}, t) < \delta. With only one source, both vectors have one positive entry, so the cosine is 1 and the loop stops after the first iteration.

Cost of one iteration. Let CC be the number of claims and dod_o the number of different facts on object oo. Lines L3 and L7 take O(∣W∣+C)O(|W| + C), line L4 takes O(C)O(C), line L5 takes O(∑odo2)O(\sum_o d_o^2) calls of imp, and line L6 takes one step per fact. With imp in constant time an iteration takes O(∣W∣+C+∑odo2)O(|W| + C + \sum_o d_o^2), and the whole run at most TT times that. Line L9 takes one pass over the facts. ■\blacksquare

What is not proved. The map from the trust vector to the next trust vector is continuous and maps (0,1)∣W∣(0, 1)^{|W|} into itself, but the method has no proof that the iteration converges, that its limit is unique, or that it ranks true facts first. Yin, Han and Yu report that the trust values settle after a few iterations on their data; that is a measurement.

Complexity

  • One iteration. Lines L3, L4 and L7 take O(n)O(n) for nn claims. Line L5 takes O(∑odo2)=O(nd)O(\sum_o d_o^2) = O(n d) calls of imp, where dod_o is the number of different facts on object oo. Without implications, line L5 is free and an iteration takes O(n)O(n).
  • The run. kk iterations take O(knd)O(k n d). On the book data of the paper the trusts settled after a few iterations; this is a measurement, not a bound, so TT caps kk.
  • Space. O(n)O(n) for the claims, trusts and confidences.

Properties

  • Heuristic. The trust and confidence equations, ρ\rho, γ\gamma and t0t_0 are choices of the authors, set on their data.
  • Mutual reinforcement. Like HITS and PageRank, it computes two scores from each other, but its update is not linear and has no eigenvector form.
  • Fixed point method. The update maps trust vectors in (0,1)∣W∣(0, 1)^{|W|} to trust vectors, so a limit, if there is one, is a fixed point of that map, as in fixed-point iteration.
  • Deterministic. Ties are broken by a fixed order of the values.
  • Independence assumption. Line L4 treats sources as independent. γ\gamma only weakens all evidence by the same factor; it does not find which sources copy.

Variants and improvements

  • Without implications. Set imp=0\mathrm{imp} = 0. Then each fact depends only on its own sources, which is a vote weighted by τ\tau.
  • Similarity of values. For lists of authors the paper defines the similarity from the number of shared authors; numbers and strings need their own similarity.
  • Probabilistic models. Later methods put the sources and the truths in one probabilistic model and fit it with expectation maximization or sampling. They can model a false positive rate and a false negative rate for each source.
  • Copy detection. Dong, Berti-Equille and Srivastava model which sources copy from which, instead of one global γ\gamma.
  • Optimization methods. Methods such as CRH write truth discovery as the minimization of a weighted loss over sources and truths, with an alternating solver.

When to use it

Use it when many sources claim values for many objects, you have no labels, and you believe that sources that are often right on the objects where others agree with them are also right elsewhere. It helps most when a few sources cover many objects and many weak sources each cover a few. With few sources, or when every source covers only a few objects, the trusts carry little information and a vote does about as well.

Pitfalls

  • The cosine stop sees only the direction. If all trusts change by the same factor, the cosine is 1 and the loop stops; with one source it always stops after one iteration. A cap and a check of the absolute change are safer.
  • Narrow trust range. With γ=0.3\gamma = 0.3 the confidences of facts with positive σ∗\sigma^* stay above 0.5, so the trusts of good and bad sources can be close, and a large group of weak sources can still outvote one good source.
  • Copying. Sources that copy one source count as many. The global γ\gamma does not fix this for one group of copiers.
  • Single truth. It picks one value for each object. Objects with several true values, such as a list of authors read as separate facts, need a different model.
  • Implication on the wrong scale. ρ\rho multiplies sums of σ\sigma that grow with the number of sources, so a strong negative implication on a popular object can drive all its confidences below 0.5.

Implementations

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

truthfinder.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/truthfinder/. The authors are listed in prov/HNKC9H.jsonl.
"""TruthFinder (Yin, Han and Yu): iterate between source trust and fact confidence.

A claim is a triple (source, object, value). A fact is a pair (object, value).
imp(obj, v1, v2) is the implication from the fact (obj, v1) to the fact
(obj, v2), a number in [-1, 1]; the default is 0 for every pair, which gives
the plain version without similar facts. The defaults rho = 0.5, gamma = 0.3,
t0 = 0.9 and delta = 1e-5 (0.001%) are the values that the paper uses.
"""

import math


def facts_of(claims):
    """Return (sources, facts, providers of each fact, facts of each source)."""
    providers = {}
    by_source = {}
    for w, o, v in claims:
        f = (o, v)
        providers.setdefault(f, set()).add(w)
        by_source.setdefault(w, set()).add(f)
    sources = sorted(by_source, key=repr)
    facts = sorted(providers, key=repr)
    return sources, facts, providers, by_source


def cosine(a, b):
    na = math.sqrt(sum(x * x for x in a))
    nb = math.sqrt(sum(x * x for x in b))
    if na == 0 or nb == 0:
        return 1.0
    return sum(x * y for x, y in zip(a, b)) / (na * nb)


def no_implication(obj, v1, v2):
    return 0.0


def exclusive_implication(base_sim=0.5):
    """imp = sim - base_sim with sim = 0 for two different values: each value counts against the others."""

    def imp(obj, v1, v2):
        return (1.0 if v1 == v2 else 0.0) - base_sim

    return imp


def truthfinder(claims, imp=no_implication, t0=0.9, rho=0.5, gamma=0.3, delta=1e-5, max_iter=100):
    """Return (confidence of each fact, trust of each source, number of iterations)."""
    sources, facts, providers, by_source = facts_of(claims)
    same_object = {}
    for o, v in facts:
        same_object.setdefault(o, []).append(v)
    t = {w: t0 for w in sources}  # @line L1
    s = {}
    it = 0
    while True:  # @line L2
        it += 1
        tau = {w: -math.log(max(1e-300, 1.0 - t[w])) for w in sources}  # @line L3
        sigma = {f: sum(tau[w] for w in providers[f]) for f in facts}  # @line L4
        sigma_star = {}
        for o, v in facts:  # @line L5
            adj = sum(sigma[(o, u)] * imp(o, u, v) for u in same_object[o] if u != v)  # @line L5
            sigma_star[(o, v)] = sigma[(o, v)] + rho * adj  # @line L5
        s = {f: 1.0 / (1.0 + math.exp(-gamma * sigma_star[f])) for f in facts}  # @line L6
        old = [t[w] for w in sources]  # @line L7
        t = {w: sum(s[f] for f in by_source[w]) / len(by_source[w]) for w in sources}  # @line L7
        new = [t[w] for w in sources]
        if 1.0 - cosine(old, new) < delta or it >= max_iter:  # @line L8
            break
    return s, t, it


def answers(confidence):
    """For each object, the value with the largest confidence (ties go to the smallest repr)."""
    best = {}
    for (o, v), c in sorted(confidence.items(), key=lambda kv: repr(kv[0])):  # @line L9
        if o not in best or c > best[o][1]:  # @line L9
            best[o] = (v, c)  # @line L9
    return {o: v for o, (v, c) in best.items()}


def voting(claims):
    """The baseline: for each object, the value that most sources claim."""
    count = {}
    for w, o, v in set(claims):
        count[(o, v)] = count.get((o, v), 0) + 1
    return answers({f: float(c) for f, c in count.items()})
test_truthfinder.py 156 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/truthfinder/. The authors are listed in prov/HNKC9H.jsonl.
import math
import random
import unittest

from truthfinder import answers, exclusive_implication, truthfinder, voting


def synthetic(seed, objects=200, good=4, bad=20, good_acc=0.9, bad_acc=0.3):
    """Few accurate sources with large coverage, many poor sources that share a popular wrong value."""
    rng = random.Random(seed)
    truth, popular = {}, {}
    for o in range(objects):
        a, b = rng.sample(range(6), 2)
        truth[o] = "v%d_%d" % (o, a)
        popular[o] = "v%d_%d" % (o, b)
    specs = [("good%d" % i, good_acc, 0.5) for i in range(good)]
    specs += [("bad%d" % i, bad_acc, 0.15) for i in range(bad)]
    claims = []
    for name, acc, cover in specs:
        for o in range(objects):
            if rng.random() < cover:
                if rng.random() < acc:
                    v = truth[o]
                elif rng.random() < 0.7:
                    v = popular[o]
                else:
                    v = truth[o]
                    while v in (truth[o], popular[o]):
                        v = "v%d_%d" % (o, rng.randint(0, 5))
                claims.append((name, o, v))
    return truth, claims


def accuracy(ans, truth):
    return sum(ans[o] == truth[o] for o in ans) / len(ans)


class TestTruthFinder(unittest.TestCase):
    def test_one_iteration_by_hand(self):
        claims = [("w1", "o", "a"), ("w2", "o", "a"), ("w2", "o", "b")]
        s, t, it = truthfinder(claims, imp=exclusive_implication(), max_iter=1)
        self.assertEqual(it, 1)
        tau = -math.log(1 - 0.9)
        sa, sb = 2 * tau, tau
        star_a = sa + 0.5 * sb * (-0.5)
        star_b = sb + 0.5 * sa * (-0.5)
        conf_a = 1 / (1 + math.exp(-0.3 * star_a))
        conf_b = 1 / (1 + math.exp(-0.3 * star_b))
        self.assertAlmostEqual(s[("o", "a")], conf_a, places=12)
        self.assertAlmostEqual(s[("o", "b")], conf_b, places=12)
        self.assertAlmostEqual(t["w1"], conf_a, places=12)
        self.assertAlmostEqual(t["w2"], (conf_a + conf_b) / 2, places=12)
        self.assertEqual(answers(s), {"o": "a"})

    def test_cosine_stop_with_one_source(self):
        # One trust value: the cosine of two one-element vectors is 1, so the loop stops at once.
        s, t, it = truthfinder([("w", "o", "a")])
        self.assertEqual(it, 1)
        self.assertAlmostEqual(s[("o", "a")], 1 / (1 + 0.1 ** 0.3), places=12)

    def test_iteration_cap(self):
        truth, claims = synthetic(3)
        for cap in (1, 2, 5):
            _, _, it = truthfinder(claims, max_iter=cap, delta=0.0)
            self.assertEqual(it, cap)

    def test_ranges_and_renaming(self):
        rng = random.Random(8)
        truth, claims = synthetic(8, objects=60)
        s, t, it = truthfinder(claims, imp=exclusive_implication())
        self.assertTrue(all(0 < c < 1 for c in s.values()))
        self.assertTrue(all(0 < x < 1 for x in t.values()))
        names = sorted({w for w, _, _ in claims})
        shuffled = names[:]
        rng.shuffle(shuffled)
        rename = dict(zip(names, ["src%03d" % i for i in range(len(names))]))
        renamed = [(rename[w], o, v) for w, o, v in reversed(claims)]
        s2, t2, it2 = truthfinder(renamed, imp=exclusive_implication())
        self.assertEqual(it, it2)
        for f in s:
            self.assertAlmostEqual(s[f], s2[f], places=9)
        for w in t:
            self.assertAlmostEqual(t[w], t2[rename[w]], places=9)

    def test_similar_facts_support_each_other(self):
        claims = [("w1", "x", 100), ("w2", "x", 101), ("w3", "x", 50)]

        def imp(o, v1, v2):
            return math.exp(-abs(v1 - v2)) - 0.5

        s0, _, _ = truthfinder(claims)
        self.assertAlmostEqual(s0[("x", 100)], s0[("x", 50)], places=12)
        s, _, _ = truthfinder(claims, imp=imp)
        self.assertGreater(s[("x", 100)], s[("x", 50)])
        self.assertGreater(s[("x", 101)], s[("x", 50)])
        self.assertIn(answers(s)["x"], (100, 101))

    def test_against_voting_synthetic(self):
        truth, claims = synthetic(42)
        vote = accuracy(voting(claims), truth)
        s, t, it = truthfinder(claims)
        plain = accuracy(answers(s), truth)
        s2, t2, it2 = truthfinder(claims, imp=exclusive_implication())
        excl = accuracy(answers(s2), truth)
        # The numbers on the page (seed 42): 1025 claims on 200 objects.
        self.assertEqual(len(claims), 1025)
        self.assertEqual((round(vote, 3), round(plain, 3), round(excl, 3)), (0.63, 0.72, 0.73))
        self.assertEqual((it, it2), (3, 5))
        good = sum(t2["good%d" % i] for i in range(4)) / 4
        bad = sum(t2["bad%d" % i] for i in range(20)) / 20
        self.assertGreater(good, bad)

    def test_first_iteration_is_a_vote(self):
        truth, claims = synthetic(42)
        count = {}
        for w, o, v in claims:
            count[(o, v)] = count.get((o, v), 0) + 1
        for imp in (None, exclusive_implication()):
            if imp is None:
                s, _, _ = truthfinder(claims, max_iter=1)
            else:
                s, _, _ = truthfinder(claims, imp=imp, max_iter=1)
            for f in s:
                for g in s:
                    if f[0] == g[0] and count[f] > count[g]:
                        self.assertGreater(s[f], s[g])

    def test_page_example(self):
        claims = [
            ("A", "b1", "x"), ("A", "b2", "x"), ("A", "b3", "x"),
            ("B", "b1", "y"), ("B", "b2", "y"),
            ("C", "b2", "x"), ("C", "b3", "x"),
        ]
        imp = exclusive_implication()
        s, t, it = truthfinder(claims, imp=imp, max_iter=1)
        r = {f: round(c, 3) for f, c in s.items()}
        self.assertEqual(r, {("b1", "x"): 0.627, ("b1", "y"): 0.627, ("b2", "x"): 0.77, ("b2", "y"): 0.585, ("b3", "x"): 0.799})
        self.assertEqual({w: round(x, 3) for w, x in t.items()}, {"A": 0.732, "B": 0.606, "C": 0.785})
        s, t, it = truthfinder(claims, imp=imp, max_iter=2, delta=0.0)
        self.assertEqual((round(s[("b1", "x")], 3), round(s[("b1", "y")], 3)), (0.581, 0.545))
        s, t, it = truthfinder(claims, imp=imp)
        self.assertEqual(it, 5)
        self.assertEqual(answers(s), {"b1": "x", "b2": "x", "b3": "x"})
        self.assertEqual({w: round(x, 3) for w, x in t.items()}, {"A": 0.611, "B": 0.529, "C": 0.638})

    def test_several_seeds_beat_voting(self):
        for seed in (1, 2, 3, 4, 5):
            truth, claims = synthetic(seed)
            s, _, _ = truthfinder(claims, imp=exclusive_implication())
            self.assertGreater(accuracy(answers(s), truth), accuracy(voting(claims), truth))


if __name__ == "__main__":
    unittest.main()

History

Yin, Han and Yu introduced TruthFinder at KDD 2007 and gave the full version in IEEE TKDE in 2008. They studied the authors of computer science books listed by online bookstores: 1265 books, 894 bookstores and 34031 listings. With ρ=0.5\rho = 0.5 and γ=0.3\gamma = 0.3 they measured an accuracy of about 95% on that data after three iterations. Later work on truth discovery added copy detection, probabilistic models and optimization models.

References

  1. Xiaoxin Yin, Jiawei Han and Philip S. Yu, Truth discovery with multiple conflicting information providers on the web, Proceedings of the 13th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2007, pages 1048 to 1052, Section 3.1.1 (Equations 1 to 4 and Lemma 1), Section 3.1.2 (the implication between facts, Equation 6), Section 3.1.3 (the dampening factor and the logistic function, Equation 8), Section 3.2 (the iteration and the cosine stop), Section 4 (the parameters and the book data)
  2. Xiaoxin Yin, Jiawei Han and Philip S. Yu, Truth discovery with multiple conflicting information providers on the web, IEEE Transactions on Knowledge and Data Engineering 20(6), 2008, pages 796 to 808, the journal version

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH2 full proof
  • correctness: no review record reviews/HNKC9H/proof-correctness.yaml
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • at least three sources
  • a scene preset for the example