-
Notifications
You must be signed in to change notification settings - Fork 28
Description
if something can be done for unbalanced data?
like this
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],
[1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 1],
[1, 1, 1, 0, 0, 0],
[1, 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],
[1, 1, 1, 1, 1, 0],
[1, 0, 1, 1, 0, 0],
[1, 0, 0, 1, 0, 0],
[1, 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()
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) ]
q=0
so output is: all detected as 0s
['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0']
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 40
default_class_confidence 0.7368421052631579
*** predict_matched_rules ***
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 105
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 106
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 107
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 108
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 109
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 110
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 111
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 112
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 113
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 40
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 114
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 115
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 116
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 117
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 40
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 40
CAR {F3=0,F2=0} => {Target=0} sup: 0.21 conf: 1.00 len: 3, id: 40
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 118
CAR {} => {Target=0} sup: 0.74 conf: 0.74 len: 1, id: 119