-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest_likelihood.py
38 lines (35 loc) · 1.53 KB
/
test_likelihood.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#
# test_likelihood.py
#
# Copyright (c) 2016-2023 Junpei Kawamoto
#
# This file is part of rgmining-fraud-eagle.
#
# rgmining-fraud-eagle is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# rgmining-fraud-eagle is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with rgmining-fraud-eagle. If not, see <http://www.gnu.org/licenses/>.
"""Tests for likelihood module in fraud_eagle package.
"""
from fraud_eagle.constants import PLUS, MINUS, GOOD, BAD, HONEST, FRAUD
from fraud_eagle.likelihood import psi
def test_psi():
"""Test for all possible input combinations.
"""
for epsilon in (0.01, 0.1, 0.5):
assert psi(HONEST, GOOD, PLUS, epsilon) == 1 - epsilon
assert psi(HONEST, GOOD, MINUS, epsilon) == epsilon
assert psi(HONEST, BAD, PLUS, epsilon) == epsilon
assert psi(HONEST, BAD, MINUS, epsilon) == 1 - epsilon
assert psi(FRAUD, GOOD, PLUS, epsilon) == 2 * epsilon
assert psi(FRAUD, GOOD, MINUS, epsilon) == 1 - 2 * epsilon
assert psi(FRAUD, BAD, PLUS, epsilon) == 1 - 2 * epsilon
assert psi(FRAUD, BAD, MINUS, epsilon) == 2 * epsilon