@@ -240,20 +240,20 @@ void test1(double eta)
240
240
}
241
241
242
242
printf ("------- Test 1 -------\n" );
243
- printf ("Model before fit: %s" , adaline_get_weights_str (& ada ));
243
+ printf ("Model before fit: %s\n " , adaline_get_weights_str (& ada ));
244
244
245
245
adaline_fit (& ada , X , Y , N );
246
246
printf ("Model after fit: %s\n" , adaline_get_weights_str (& ada ));
247
247
248
248
double test_x [] = {5 , -3 };
249
249
int pred = adaline_predict (& ada , test_x , NULL );
250
- printf ("Predict for x=(5,-3): % d" , pred );
250
+ printf ("Predict for x=(5,-3): % d\n " , pred );
251
251
assert (pred == -1 );
252
252
printf (" ...passed\n" );
253
253
254
254
double test_x2 [] = {5 , 8 };
255
255
pred = adaline_predict (& ada , test_x2 , NULL );
256
- printf ("Predict for x=(5, 8): % d" , pred );
256
+ printf ("Predict for x=(5, 8): % d\n " , pred );
257
257
assert (pred == 1 );
258
258
printf (" ...passed\n" );
259
259
@@ -294,7 +294,7 @@ void test2(double eta)
294
294
}
295
295
296
296
printf ("------- Test 2 -------\n" );
297
- printf ("Model before fit: %s" , adaline_get_weights_str (& ada ));
297
+ printf ("Model before fit: %s\n " , adaline_get_weights_str (& ada ));
298
298
299
299
adaline_fit (& ada , X , Y , N );
300
300
printf ("Model after fit: %s\n" , adaline_get_weights_str (& ada ));
@@ -309,7 +309,7 @@ void test2(double eta)
309
309
test_x [0 ] = x0 ;
310
310
test_x [1 ] = x1 ;
311
311
int pred = adaline_predict (& ada , test_x , NULL );
312
- printf ("Predict for x=(% 3.2f,% 3.2f): % d" , x0 , x1 , pred );
312
+ printf ("Predict for x=(% 3.2f,% 3.2f): % d\n " , x0 , x1 , pred );
313
313
314
314
int expected_val = (x0 + 3. * x1 ) > -1 ? 1 : -1 ;
315
315
assert (pred == expected_val );
@@ -362,7 +362,7 @@ void test3(double eta)
362
362
}
363
363
364
364
printf ("------- Test 3 -------\n" );
365
- printf ("Model before fit: %s" , adaline_get_weights_str (& ada ));
365
+ printf ("Model before fit: %s\n " , adaline_get_weights_str (& ada ));
366
366
367
367
adaline_fit (& ada , X , Y , N );
368
368
printf ("Model after fit: %s\n" , adaline_get_weights_str (& ada ));
@@ -381,7 +381,7 @@ void test3(double eta)
381
381
test_x [4 ] = x1 * x1 ;
382
382
test_x [5 ] = x2 * x2 ;
383
383
int pred = adaline_predict (& ada , test_x , NULL );
384
- printf ("Predict for x=(% 3.2f,% 3.2f): % d" , x0 , x1 , pred );
384
+ printf ("Predict for x=(% 3.2f,% 3.2f): % d\n " , x0 , x1 , pred );
385
385
386
386
int expected_val = (x0 * x0 + x1 * x1 + x2 * x2 ) <= 1 ? 1 : -1 ;
387
387
assert (pred == expected_val );
0 commit comments