-
Notifications
You must be signed in to change notification settings - Fork 28
Description
default class confidence is less than set by classier parameter confidence
what can be done to get default class predictions to be reliable ?
in example below default_class_confidence is 0.26 , but was used cba = CBA(confidence= 0.7)
import unittest
import pandas as pd
from pyarc import CBA
from pyarc.data_structures import (
TransactionDB
)
import os
header1 = ['F1' ,'F2','F3','F4' ,'F5','Target']
rows1 = [
[1, 1, 0, 0, 0, 1],
[1, 1, 0, 0, 0, 0],
[1, 1, 0, 0, 0, 0],
[0, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 0],
[0, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 0],
[1, 1, 0, 1, 0, 1],
[1, 0, 0, 1, 1, 0],
[1, 0, 1, 1, 1, 1],
[1, 1, 0, 1, 1, 0],
[0, 1, 1, 1, 1, 0],
[1, 0, 1, 1, 0, 0],
[1, 0, 0, 1, 0, 0],
[0, 0, 0, 1, 0, 0],
[1, 0, 0, 1, 0, 0],
[0, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0],
]
transactions = TransactionDB(rows1, header1)
cba = CBA(confidence= 0.7)
cba.fit(transactions)
print(cba.predict(transactions) )
[print(x) for x in cba.clf.rules]
cba.clf.rules
cba.clf.default_class
cba.clf.default_class_attribute
cba.clf.default_class_support
print('default_class_confidence' , cba.clf.default_class_confidence)
print('\n *** predict_matched_rules ***')
[print(x) for x in cba.predict_matched_rules(transactions) ]
print('\n predict_probability')
print([int(x * 100) for x in cba.predict_probability(transactions) ])
q=0
then output
['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '0', '0', '0', '0', '0', '0', '0', '0']
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 36
CAR {F5=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 39
CAR {F3=0,F1=0} => {Target=0} sup: 0.16 conf: 1.00 len: 3, id: 20
CAR {F5=1,F3=0} => {Target=0} sup: 0.11 conf: 1.00 len: 3, id: 5
CAR {F5=1,F2=1} => {Target=0} sup: 0.11 conf: 1.00 len: 3, id: 6
CAR {F1=0} => {Target=0} sup: 0.26 conf: 0.83 len: 2, id: 24
CAR {F3=0} => {Target=0} sup: 0.47 conf: 0.82 len: 2, id: 60
CAR {F1=1,F5=0,F3=1} => {Target=0} sup: 0.16 conf: 0.75 len: 4, id: 41
default_class_confidence 0.2631578947368421 !!!!!!!!!!!!!!!
*** predict_matched_rules ***
CAR {F3=0} => {Target=0} sup: 0.47 conf: 0.82 len: 2, id: 60
CAR {F3=0} => {Target=0} sup: 0.47 conf: 0.82 len: 2, id: 60
CAR {F3=0} => {Target=0} sup: 0.47 conf: 0.82 len: 2, id: 60
CAR {F1=0} => {Target=0} sup: 0.26 conf: 0.83 len: 2, id: 24
CAR {F1=1,F5=0,F3=1} => {Target=0} sup: 0.16 conf: 0.75 len: 4, id: 41
CAR {F1=1,F5=0,F3=1} => {Target=0} sup: 0.16 conf: 0.75 len: 4, id: 41
CAR {F1=0} => {Target=0} sup: 0.26 conf: 0.83 len: 2, id: 24
CAR {F1=1,F5=0,F3=1} => {Target=0} sup: 0.16 conf: 0.75 len: 4, id: 41
CAR {F3=0} => {Target=0} sup: 0.47 conf: 0.82 len: 2, id: 60
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 36
CAR {} => {Target=1} sup: 0.26 conf: 0.26 len: 1, id: 64
CAR {F5=1,F3=0} => {Target=0} sup: 0.11 conf: 1.00 len: 3, id: 5
CAR {F5=1,F2=1} => {Target=0} sup: 0.11 conf: 1.00 len: 3, id: 6
CAR {F5=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 39
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 36
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 36
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 36
CAR {F3=0,F1=0} => {Target=0} sup: 0.16 conf: 1.00 len: 3, id: 20
CAR {F3=0,F1=0} => {Target=0} sup: 0.16 conf: 1.00 len: 3, id: 20
predict_probability
[81, 81, 81, 83, 75, 75, 83, 75, 81, 100, 26, 100, 100, 100, 100, 100, 100, 100, 100]
^
???!!!!