io.loader
class DatasetLoader
Bases: object
__init__()
custom_function(func, **kwargs)
Apply a custom function to the data.
Parameters
func: callable : Custom function to apply.
**
kwargs : Additional keyword arguments for the custom function.
Returns
data: pandas.DataFrame : The modified data.
drop_columns(columns)
Drop specified columns from the data.
Parameters
columns: list : List of columns index or names to drop.
Returns
DatasetLoader : DatasetLoader object with the specified columns dropped.
get_data()
Get the loaded data.
Returns
data: pandas.DataFrame : The loaded data.
get_descriptive_columns(columns)
Get descriptive columns from the data.
Parameters
columns: list : List of descriptive columns.
Returns
data: pandas.DataFrame : DataFrame containing the descriptive columns.
get_metadata()
Get metadata of the loaded data.
Returns
metadata: dict : Dictionary containing the number of subjects and variables.
import_data(data, columns=None, index=None, **kwargs)
Import data from a DataFrame or a array-like object.
Parameters
data: pandas.DataFrame or array-like : Data to import.
columns: list, optional : List of columns to use. If None, all columns will be used.
Returns
DatasetLoader : DatasetLoader object with the imported data.
join(df, left=True, **kwargs)
Join two DataFrames.
Parameters
df: pandas.DataFrame : DataFrame to join with.
left: bool, optional : If true, provided DataFrame is the left DataFrame. If false, provided DataFrame is the right DataFrame. Default is True.
**
kwargs : Additional keyword arguments for the pd.concat function.
Returns
data: pandas.DataFrame : Joined DataFrame.
load_data(file, **kwargs)
Load tabular data in any format (.txt, .csv, .xlsx).
Parameters
file: str : Input file to load.
**
kwargs : Additional keyword arguments.
Returns
df: pandas.DataFrame
reset_index(**kwargs)
Reset the index of the DataFrame.
Parameters
**
kwargs : Additional keyword arguments for the pd.DataFrame.reset_index function.
save_data(file, **kwargs)
Save the data to a file.
Parameters
file: str : Output file name.
**
kwargs : Additional keyword arguments.
set_type(dtype, columns=None)
Set the type of the specified columns.
Parameters
dtype: str : Type to set.
columns: list, optional : List of columns to set the type for. If None, all columns will be converted.
Returns
data: pandas.DataFrame : DataFrame with the specified type set.
transpose()
Transpose the data.
Returns
DatasetLoader : DatasetLoader object with the transposed data.
class GraphLoader
Bases: object
__init__()
add_edge_attribute(attributes)
Add an edge attribute to the graph.
Parameters
attribute: dict : Dictionary containing the values of the attribute for each edge.
add_node_attribute(attributes)
Add a node attribute to the graph.
Parameters
attributes: dict : Dictionary containing the values of the attribute for each node.
build_graph(data, source=‘source’, target=‘target’, **kwargs)
Build a graph from the provided data.
Parameters
data: pandas.DataFrame : DataFrame containing the data to build the graph.
**
kwargs : Additional keyword arguments.
Returns
graph: networkx.Graph
custom_function(func, **kwargs)
Apply a custom function to the graph.
Parameters
func: callable : Custom function to apply.
**
kwargs : Additional keyword arguments for the custom function.
Returns
graph: networkx.Graph : The modified graph.
fetch_attributes_df(attributes=None)
Fetch nodes’ attributes from the graph as a DataFrame.
Parameters
attributes: List, optional : List of attributes to fetch.
Returns
DatasetLoader : DatasetLoader object containing the nodes’ attributes.
fetch_edge_data(weight=‘membership’)
Fetch edge data from the graph.
Parameters
weight: str, optional : Edge attribute to use as weights for the edges.
Returns
DatasetLoader : DatasetLoader object containing the edge data.
get_graph()
Get the loaded graph.
Returns
graph: networkx.Graph : The loaded graph.
get_metadata()
Get metadata of the loaded graph.
Returns
metadata: dict : Dictionary containing the number of nodes and edges.
layout(layout=NetworkLayout.Spring, weight=‘membership’, **kwargs)
Compute the layout of the graph. Parameters ———- layout: NetworkLayout
Layout algorithm to use.
weight: str, optional : Edge attribute to use as weights for the layout.
**
kwargs : Additional keyword arguments for the layout algorithm.
Returns
pos: dict : Dictionary containing the positions of the nodes.
load_graph(file, **kwargs)
Load graph data.
Parameters
file: str : Input file to load.
**
kwargs : Additional keyword arguments.
Returns
graph: networkx.Graph
save_graph(file, **kwargs)
Save the graph data.
Parameters
file: str : Output file to save.
**
kwargs : Additional keyword arguments.
visualize(output, weight=‘weight’, centroids_labelling=True, subjects_labelling=False, centroid_node_shape=500, centroid_alpha=1, centroid_node_color=‘white’, centroid_edge_color=‘black’, subject_node_shape=5, subject_alpha=0.3, subject_node_color=‘black’, subject_edge_color=None, edge_width_multiplier=10, colormap=‘plasma’, title=‘Graph Network’, legend_title=‘Membership values’)
Visualize the graph network.
Parameters
output: str : Output file name.
weight: str, optional : Edge attribute to use as weights for the edges.
centroids_labelling: bool, optional : If true, label the centroid nodes.
subjects_labelling: bool, optional : If true, label the subject nodes.
centroid_node_shape: int, optional : Shape of the centroid nodes.
centroid_alpha: float, optional : Alpha value of the centroid nodes.
centroid_node_color: str, optional : Color of the centroid nodes.
centroid_edge_color: str, optional : Color of the centroid edges.
subject_node_shape: int, optional : Shape of the subject nodes.
subject_alpha: float, optional : Alpha value of the subject nodes.
subject_node_color: str, optional : Color of the subject nodes.
subject_edge_color: str, optional : Color of the subject edges.
colormap: str, optional : Colormap to use for the edges.
title: str, optional : Title of the plot.
legend_title: str, optional : Title of the legend.
filter_node_centroids(n)
Function to filter cluster nodes from subject’s nodes.
Parameters
n : Node label.
Returns
bool : True or False
filter_node_subjects(n)
Function to filter subject nodes from cluster’s nodes.
Parameters
n : Node label.
Returns
bool : True or False