#NEWLINE# def loadRawData( self , fname ) : #NEWLINE# #INDENT# " read svm sparse format from file 'fname' (with labels only)\n            output: [attributes[], labels[]] " #NEWLINE# targetfile = open ( fname . replace ( 'data' , 'targets' ) , 'r' ) #NEWLINE# x = [ ] #NEWLINE# y = [ ] #NEWLINE# for line in open ( fname , 'r' ) . readlines ( ) : #NEWLINE# #INDENT# if ( not line ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# targline = targetfile . readline ( ) #NEWLINE# targline = list ( map ( int , targline . split ( ) ) ) #NEWLINE# for ( i , v ) in enumerate ( targline ) : #NEWLINE# #INDENT# if v : #NEWLINE# #INDENT# label = i #NEWLINE# break #NEWLINE# #UNINDENT# #UNINDENT# feat = list ( map ( float , line . split ( ) ) ) #NEWLINE# x . append ( feat ) #NEWLINE# y . append ( [ float ( label ) ] ) #NEWLINE# self . nSamples += 1 #NEWLINE# #UNINDENT# self . nCls = len ( targline ) #NEWLINE# targetfile . close ( ) #NEWLINE# self . _setDataFields ( x , y )