
Evaluation and comparison of classification accuracy 295
Listing 7.1: Cross-validation on the cloud.
1 IMPO RT numpy as np
2 IMPO RT cloud , gdal , ogr , osr , os , time
3
4 DEF c rossva lidate (( Gstrn , lstrn , Gstst , lstst ,L )):
5 affn = Ffncg ( Gstrn , lstrn ,L )
6 IF affn . trai n ( epo chs =1 000):
7 RETUR N affn . test ( Gstst , lstst )
8 ELSE :
9 RETUR N None
10
11 DEF traintst (Gs ,ls , L):
12 m = np . sha pe ( Gs )[0]
13 trai ntest = []
14 FOR i IN RAN GE (10 ):
15 sl = SL ICE ( i* m //10 ,( i +1)* m //1 0)
16 traintest . ap pend ( ( np . delete ( Gs ,sl ,0) , \
17 np . del ete (ls ,sl ,0) , Gs [ sl ,:] , ls [sl ,:] , L) )
18 jids = c loud . MAP (