def load_digits(n_class=10, return_X_y=False):
 module_path = dirname(__file__)
 data = np.loadtxt(join(module_path, 'data', 'digits.csv.gz'), delimiter=',')
 with open(join(module_path, 'descr', 'digits.rst')) as f:
  descr = f.read()
 target = data[:, (-1)].astype(np.int)
 flat_data = data[:, :(-1)]
 images = flat_data.view()
 images.shape = ((-1), 8, 8)
 if (n_class < 10):
  idx = (target < n_class)
  (flat_data, target) = (flat_data[idx], target[idx])
  images = images[idx]
 if return_X_y:
  return (flat_data, target)
 return Bunch(data=flat_data, target=target, target_names=np.arange(10), images=images, DESCR=descr)

def load_digits ( n_class = 10 , return_X_y = False ) : module_path = dirname ( __file__ ) data = np . loadtxt ( join ( module_path , 'data' , 'digits.csv.gz' ) , delimiter = ',' ) with open ( join ( module_path , 'descr' , 'digits.rst' ) ) as f : descr = f . read ( ) target = data [ : , ( - 1 ) ] . astype ( np . int ) flat_data = data [ : , : ( - 1 ) ] images = flat_data . view ( ) images . shape = ( ( - 1 ) , 8 , 8 ) if ( n_class < 10 ) : idx = ( target < n_class ) ( flat_data , target ) = ( flat_data [ idx ] , target [ idx ] ) images = images [ idx ] if return_X_y : return ( flat_data , target ) return Bunch ( data = flat_data , target = target , target_names = np . arange ( 10 ) , images = images , DESCR = descr )
load and return the digits dataset .