def setUpClass(cls): DatabaseTest.create_db() cls.oConnection = DatabaseTest.connect_db() cls.db = Database() cls.db.add_table( 'table', create_from_csv("examples/join_table.csv", p_strDelimiter=',')) cls.db.add_table( 'addr', create_from_csv("examples/join_addr.csv", p_strDelimiter=','))
def test_get_index_create(self): quinlan = create_from_csv("examples/quinlan.csv", p_strDelimiter=',') h = quinlan.get_index("Outlook", p_bCreateIfDoesNotExist=True) self.assertEqual( h, { ("overcast", ): set([5, 6, 7, 8]), ("rain", ): set([9, 10, 11, 12, 13]), ("sunny", ): set([0, 1, 2, 3, 4]) })
def setUpClass(cls): cls.quinlan = create_from_csv("examples/quinlan.csv", p_strDelimiter=',')
def test_get_index_none(self): quinlan = create_from_csv("examples/quinlan.csv", p_strDelimiter=',') h = quinlan.get_index("Outlook") self.assertEqual(h, None)
def test_add_column_fail(self): quinlan = create_from_csv("examples/quinlan.csv", p_strDelimiter=',') quinlan.add_column("test", [True] * (quinlan.count() - 1)) self.assertEqual(quinlan.get_columns(), ['Outlook', 'Windy', 'Class'])
import random import c45 from database import Database from diff import compare from table import create_from_csv db = Database() db.add_table( "system", create_from_csv("/home/julesy/Workspace/qfin_system.csv", p_strDelimiter=";")) db.add_table( "systemb", create_from_csv("/home/julesy/Workspace/qfin_system.csv", p_strDelimiter=";")) db.add_table( "trade", create_from_csv("/home/julesy/Workspace/qfin_trade.csv", p_strDelimiter=";")) db.add_table( "instrument", create_from_csv("/home/julesy/Workspace/qfin_instrument.csv", p_strDelimiter=";")) db.add_table( "joined", db.join("system", "systemb", [('Trade Nr', 'Trade Nr')], p_strType="inner")) db.add_table( "joined_trade",
def test_entropy_target_once(self): quinlan = create_from_csv("examples/quinlan_mod.csv", p_strDelimiter=',') result = entropy(quinlan, "ClassPlay") self.assertEqual(round(result, 2), 0)
def setUpClass(cls): cls.tbl = create_from_csv("examples/diff.csv", p_strDelimiter=',')