#NEWLINE# def test_cmac( self ) : #NEWLINE# #INDENT# input_train = np . reshape ( np . linspace ( 0 , ( 2 * np . pi ) , 100 ) , ( 100 , 1 ) ) #NEWLINE# input_train_before = input_train . copy ( ) #NEWLINE# input_test = np . reshape ( np . linspace ( np . pi , ( 2 * np . pi ) , 50 ) , ( 50 , 1 ) ) #NEWLINE# input_test_before = input_test . copy ( ) #NEWLINE# target_train = np . sin ( input_train ) #NEWLINE# target_train_before = target_train . copy ( ) #NEWLINE# target_test = np . sin ( input_test ) #NEWLINE# cmac = algorithms . CMAC ( quantization = 100 , associative_unit_size = 32 , step = 0.2 , verbose = False ) #NEWLINE# cmac . train ( input_train , target_train , epochs = 100 ) #NEWLINE# predicted_test = cmac . predict ( input_test ) #NEWLINE# predicted_test = predicted_test . reshape ( ( len ( predicted_test ) , 1 ) ) #NEWLINE# error = metrics . mean_absolute_error ( target_test , predicted_test ) #NEWLINE# self . assertAlmostEqual ( error , 0.0024 , places = 4 ) #NEWLINE# np . testing . assert_array_equal ( input_train , input_train_before ) #NEWLINE# np . testing . assert_array_equal ( input_train , input_train_before ) #NEWLINE# np . testing . assert_array_equal ( target_train , target_train_before )