Generate label maps from CSV files
Project description
LabelMap
Generate label maps for ML/DL Projects
Usage
-
With CSV file
from labelmap import LabelMap label_map = LabelMap(labels_csv="path-to-csv", labels_col_name="labels") label_map.info() # print label map
-
With CSV file and exclude some labels
from labelmap import LabelMap label_map = LabelMap(labels_csv="path-to-csv", labels_col_name="labels", exclude_labels=["cat", "dog"]) label_map.info() # print label map
-
Without CSV file
from labelmap import LabelMap label_map = LabelMap() label_map.add("cat") label_map.add("dog") label_map.info() # print label map
Parameters in LabelMap
class
labels_csv
:str
- The path to the csv file containing the labels and ids.
- Not Required, default =
None
labels_col_name
:str
- The name of the column containing the labels.
- Required if
labels_col_name
is set, default =None
ids_col_name
:str
- The name of the column containing the ids.
- Not Required, default =
None
id_type
:int/float
- The type of the ids.
- Not Required, default =
int
exclude_labels
:list
- The labels to exclude from the label map.
- Not Required, default =
None
Methods in LabelMap
class
-
add(label)
- Add a label to the label map.
- Args:
label -> str
- Return Type:
None
-
force_get(label)
- Get the id of a label or if id not found then add the label and get.
- Args:
label -> str
- Return Type:
None
-
to_text(id)
- Get the label of an id.
- Args:
id -> int/ float
- Return Type:
str
-
to_id(label)
- Get the id of a label.
- Args:
label -> str
- Return Type:
int/ float
-
map()
- Get the label map as dict.
- Args:
None
- Return Type:
dict
-
labels()
- Get the list of labels.
- Args:
None
- Return Type:
list
-
info()
- Print the label map as table.
- Args:
None
- Return Type:
None
-
count()
- Get the number of labels.
- Args:
None
' - Return Type:
int
-
as_dataframe()
- Label data dictionary to pandas dataframe.
- Args:
None
- Return Type:
pandas.DataFrame
-
save_csv(path)
- label data dictionary save to csv file.
- Args:
path -> str
- Return Type:
None
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
labelmap-0.0.1.tar.gz
(4.4 kB
view details)
File details
Details for the file labelmap-0.0.1.tar.gz
.
File metadata
- Download URL: labelmap-0.0.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
4f0a7025c28b4b7b5c6f4aa61d4630edb2975f59e24ca81743f8fed5aebc9bab
|
|
MD5 |
da0b543752024accbf280789fcecc997
|
|
BLAKE2b-256 |
9c18d67a340c5df2bc157862e90a7aeffd3918d9b9ba925c56ec1f7fa59f5f6f
|