tumourkit.preprocessing.graph2centroids.graph2centroids
- tumourkit.preprocessing.graph2centroids.graph2centroids(graph_file: DataFrame, num_classes: int, enable_background: bool | None = False) ndarray
Extracts X, Y and class attributes from graphs nodes.
- Parameters:
graph_file (pd.DataFrame) – The Pandas DataFrame containing the graph nodes.
enable_background (Optional[bool]) – Enable when model has extra head to correct extra cells.
- Returns:
A NumPy array containing the X, Y and class attributes from the graph nodes.
- Return type:
np.ndarray
If the graph file has a ‘class’ column, the function returns the ‘X’, ‘Y’ and ‘class’ columns as a NumPy array with integer data type. Otherwise, the function assumes that the graph file has a ‘prob1’ column, which contains the probability of a node belonging to a particular class. In this case, the function sets the class attribute to 1 if the probability is greater than 0.5, and to 2 otherwise.