Skip to content
This repository was archived by the owner on Sep 3, 2022. It is now read-only.

Commit a9e88fe

Browse files
authored
ConfusionMatrix supports file patterns. (#290)
1 parent cd2f434 commit a9e88fe

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

google/datalab/ml/_confusion_matrix.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@ def from_csv(input_csv, headers=None, schema_file=None):
5959
names = [x['name'] for x in schema]
6060
else:
6161
raise ValueError('Either headers or schema_file is needed')
62-
with _util.open_local_or_gcs(input_csv, mode='r') as f:
63-
df = pd.read_csv(f, names=names)
62+
63+
all_files = _util.glob_files(input_csv)
64+
all_df = []
65+
for file_name in all_files:
66+
with _util.open_local_or_gcs(file_name, mode='r') as f:
67+
all_df.append(pd.read_csv(f, names=names))
68+
df = pd.concat(all_df, ignore_index=True)
69+
6470
if 'target' not in df or 'predicted' not in df:
6571
raise ValueError('Cannot find "target" or "predicted" column')
6672

0 commit comments

Comments
 (0)