@@ -65,7 +65,6 @@ class BaseDM(object):
6565 def __init__ (self , source_type , dest_type , file_info , db_info ,
6666 categories , parentcat , ref_class , alphabet ,
6767 compute_wid = 'yes' , unknown_pred = 0 ):
68-
6968 """
7069 Stores files, folder and path names into the data struture of the
7170 DataManager object.
@@ -290,17 +289,17 @@ def df2data(self, df_labels, df_preds):
290289 return data
291290
292291 def importData (self ):
292+ """
293+ Read data from the input folder.
294+ Only labels with positive or negative label are loaded
293295
294- """ Read data from the input folder.
295- Only labels with positive or negative label are loaded
296-
297- :Args:
298- :-: None. File locations and the set of categories are taken
299- from the class attributes
296+ :Args:
297+ :-: None. File locations and the set of categories are taken
298+ from the class attributes
300299
301- :Returns:
302- :df_labels: Pandas dataframe of labels
303- :df_preds: Pandas dataframe of predictions
300+ :Returns:
301+ :df_labels: Pandas dataframe of labels
302+ :df_preds: Pandas dataframe of predictions
304303 """
305304
306305 # Warning.
@@ -373,8 +372,11 @@ def importData(self):
373372 'category {2} \r ' ).format (nk , ntot , cat ),
374373 end = "" )
375374
376- urls_dict [wid ] = preds [cat ][wid ]['url' ]
377- pred_dict [wid ] = preds [cat ][wid ]['pred' ]
375+ if preds [cat ][wid ] is not None :
376+ urls_dict [wid ] = preds [cat ][wid ]['url' ]
377+ pred_dict [wid ] = preds [cat ][wid ]['pred' ]
378+ else :
379+ print (f"{ wid } " )
378380
379381 df2_preds ['url' ].update (pd .Series (urls_dict ))
380382 df2_preds [cat ].update (pd .Series (pred_dict ))
@@ -434,7 +436,7 @@ def importData(self):
434436 # Make sure taht any changes here are also done there
435437 # (I know, this is not a good programming style..)
436438 info = ['marker' , 'relabel' , 'weight' , 'userId' , 'date' ]
437- arrays = [len (info )* ['info' ] + len (self .categories )* ['label' ],
439+ arrays = [len (info ) * ['info' ] + len (self .categories ) * ['label' ],
438440 info + self .categories ]
439441 tuples = list (zip (* arrays ))
440442 mindex = pd .MultiIndex .from_tuples (tuples )
@@ -508,21 +510,20 @@ def importLabels(self, category):
508510 return labels
509511
510512 def importPredicts (self , category = None ):
513+ """
514+ Get dictionary of predictions relative to a given category
511515
512- """ Get dictionary of predictions relative to a given category
513-
514- :Args:
515- :category: The category to load (from a pkl file)
516- If None, all categories are read from a unique
517- csv file
516+ :Args:
517+ :category: The category to load (from a pkl file)
518+ If None, all categories are read from a unique csv file
518519
519- :Returns:
520- :preds: Dictionary of predictions
521- - If category is not None, preds[wid] has the
522- prediction for url wid about the given category.
523- - If category is not None, preds is a dataframe
524- with the wid as uid column and one column with
525- predictions for each category.
520+ :Returns:
521+ :preds: Dictionary of predictions
522+ - If category is not None, preds[wid] has the prediction
523+ for url wid about the given category.
524+ - If category is not None, preds is a dataframe with the
525+ wid as uid column and one column with predictions for
526+ each category.
526527 """
527528
528529 # The default category is the reference class used by the
0 commit comments