Tue 27 Aug 00:14:56 CEST 2024

This commit is contained in:
sbosse 2024-08-27 00:15:57 +02:00
parent 654d9d4581
commit 73fc606f1b

91
test/test-ml-entropy.js Normal file
View File

@ -0,0 +1,91 @@
var data1 = [
['a','A'],
['a','A'],
['a','A'],
['a','A'],
['a','A'],
['a','A'],
['a','A'],
['a','A'],
['a','A'],
['a','A'],
]
var data2 = [
['a','A'],
['b','A'],
['a','A'],
['b','A'],
['a','A'],
['b','A'],
['a','A'],
['b','A'],
['a','A'],
['b','A'],
]
var data3 = [
['a','A'],
['b','B'],
['c','C'],
['a','A'],
['b','B'],
['c','C'],
['a','A'],
['b','B'],
['c','C'],
['a','A'],
]
var data43 = [
['a','A'],
['b','B'],
['c','C'],
['a','C'],
['b','A'],
['c','B'],
['a','B'],
['b','C'],
['c','A'],
['a','A'],
]
var data42 = [
['a','A'],
['b','B'],
['c','B'],
['a','B'],
['b','A'],
['c','B'],
['a','B'],
['b','A'],
['c','A'],
['a','A'],
]
var data44 = [
['a','A'],
['b','D'],
['c','B'],
['a','B'],
['b','A'],
['c','C'],
['a','B'],
['b','A'],
['c','A'],
['a','C'],
]
print('entropy of data1',ml.stats.entropy(ml.stats.utils.column(data1,0)))
print('entropy of data2',ml.stats.entropy(ml.stats.utils.column(data2,0)))
print('entropy of data3',ml.stats.entropy(ml.stats.utils.column(data3,0)))
print('entropy of data42',ml.stats.entropy(ml.stats.utils.column(data42,0)))
print('entropy of data43',ml.stats.entropy(ml.stats.utils.column(data43,0)))
print('dep. entropy of data1',ml.stats.entropyT(data1,0,1,['A','B','C']))
print('dep. entropy of data2',ml.stats.entropyT(data2,0,1,['A','B','C']))
print('dep. entropy of data3',ml.stats.entropyT(data3,0,1,['A','B','C']))
print('dep. entropy of data42',ml.stats.entropyT(data42,0,1,['A','B']))
print('dep. entropy of data43',ml.stats.entropyT(data43,0,1,['A','B','C']))
print('dep. entropy of data44',ml.stats.entropyT(data44,0,1,['A','B','C','D']))