io.loader
class DatasetLoader
Section titled “class DatasetLoader”Bases: object
__init__()
Section titled “__init__()”custom_function(func, **kwargs)
Section titled “custom_function(func, **kwargs)”Apply a custom function to the data.
Parameters
Section titled “Parameters”func: callable : Custom function to apply.
**kwargs : Additional keyword arguments for the custom function.
Returns
Section titled “Returns”data: pandas.DataFrame : The modified data.
drop_columns(columns)
Section titled “drop_columns(columns)”Drop specified columns from the data.
Parameters
Section titled “Parameters”columns: list : List of columns index or names to drop.
Returns
Section titled “Returns”DatasetLoader : DatasetLoader object with the specified columns dropped.
get_data()
Section titled “get_data()”Get the loaded data.
Returns
Section titled “Returns”data: pandas.DataFrame : The loaded data.
get_descriptive_columns(columns)
Section titled “get_descriptive_columns(columns)”Get descriptive columns from the data.
Parameters
Section titled “Parameters”columns: list : List of descriptive columns.
Returns
Section titled “Returns”data: pandas.DataFrame : DataFrame containing the descriptive columns.
get_metadata()
Section titled “get_metadata()”Get metadata of the loaded data.
Returns
Section titled “Returns”metadata: dict : Dictionary containing the number of subjects and variables.
import_data(data, columns=None, index=None, **kwargs)
Section titled “import_data(data, columns=None, index=None, **kwargs)”Import data from a DataFrame or a array-like object.
Parameters
Section titled “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
Section titled “Returns”DatasetLoader : DatasetLoader object with the imported data.
join(df, left=True, **kwargs)
Section titled “join(df, left=True, **kwargs)”Join two DataFrames.
Parameters
Section titled “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
Section titled “Returns”data: pandas.DataFrame : Joined DataFrame.
load_data(file, **kwargs)
Section titled “load_data(file, **kwargs)”Load tabular data in any format (.txt, .csv, .xlsx).
Parameters
Section titled “Parameters”file: str : Input file to load.
**kwargs : Additional keyword arguments.
Returns
Section titled “Returns”df: pandas.DataFrame
reset_index(**kwargs)
Section titled “reset_index(**kwargs)”Reset the index of the DataFrame.
Parameters
Section titled “Parameters”**kwargs : Additional keyword arguments for the pd.DataFrame.reset_index function.
save_data(file, **kwargs)
Section titled “save_data(file, **kwargs)”Save the data to a file.
Parameters
Section titled “Parameters”file: str : Output file name.
**kwargs : Additional keyword arguments.
set_type(dtype, columns=None)
Section titled “set_type(dtype, columns=None)”Set the type of the specified columns.
Parameters
Section titled “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
Section titled “Returns”data: pandas.DataFrame : DataFrame with the specified type set.
transpose()
Section titled “transpose()”Transpose the data.
Returns
Section titled “Returns”DatasetLoader : DatasetLoader object with the transposed data.
class GraphLoader
Section titled “class GraphLoader”Bases: object
__init__()
Section titled “__init__()”add_edge_attribute(attributes)
Section titled “add_edge_attribute(attributes)”Add an edge attribute to the graph.
Parameters
Section titled “Parameters”attribute: dict : Dictionary containing the values of the attribute for each edge.
add_node_attribute(attributes)
Section titled “add_node_attribute(attributes)”Add a node attribute to the graph.
Parameters
Section titled “Parameters”attributes: dict : Dictionary containing the values of the attribute for each node.
build_graph(data, source=‘source’, target=‘target’, **kwargs)
Section titled “build_graph(data, source=‘source’, target=‘target’, **kwargs)”Build a graph from the provided data.
Parameters
Section titled “Parameters”data: pandas.DataFrame : DataFrame containing the data to build the graph.
**kwargs : Additional keyword arguments.
Returns
Section titled “Returns”graph: networkx.Graph
custom_function(func, **kwargs)
Section titled “custom_function(func, **kwargs)”Apply a custom function to the graph.
Parameters
Section titled “Parameters”func: callable : Custom function to apply.
**kwargs : Additional keyword arguments for the custom function.
Returns
Section titled “Returns”graph: networkx.Graph : The modified graph.
fetch_attributes_df(attributes=None)
Section titled “fetch_attributes_df(attributes=None)”Fetch nodes’ attributes from the graph as a DataFrame.
Parameters
Section titled “Parameters”attributes: List, optional : List of attributes to fetch.
Returns
Section titled “Returns”DatasetLoader : DatasetLoader object containing the nodes’ attributes.
fetch_edge_data(weight=‘membership’)
Section titled “fetch_edge_data(weight=‘membership’)”Fetch edge data from the graph.
Parameters
Section titled “Parameters”weight: str, optional : Edge attribute to use as weights for the edges.
Returns
Section titled “Returns”DatasetLoader : DatasetLoader object containing the edge data.
get_graph()
Section titled “get_graph()”Get the loaded graph.
Returns
Section titled “Returns”graph: networkx.Graph : The loaded graph.
get_metadata()
Section titled “get_metadata()”Get metadata of the loaded graph.
Returns
Section titled “Returns”metadata: dict : Dictionary containing the number of nodes and edges.
layout(layout=NetworkLayout.Spring, weight=‘membership’, **kwargs)
Section titled “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
Section titled “Returns”pos: dict : Dictionary containing the positions of the nodes.
load_graph(file, **kwargs)
Section titled “load_graph(file, **kwargs)”Load graph data.
Parameters
Section titled “Parameters”file: str : Input file to load.
**kwargs : Additional keyword arguments.
Returns
Section titled “Returns”graph: networkx.Graph
save_graph(file, **kwargs)
Section titled “save_graph(file, **kwargs)”Save the graph data.
Parameters
Section titled “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’)
Section titled “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
Section titled “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)
Section titled “filter_node_centroids(n)”Function to filter cluster nodes from subject’s nodes.
Parameters
Section titled “Parameters”n : Node label.
Returns
Section titled “Returns”bool : True or False
filter_node_subjects(n)
Section titled “filter_node_subjects(n)”Function to filter subject nodes from cluster’s nodes.
Parameters
Section titled “Parameters”n : Node label.
Returns
Section titled “Returns”bool : True or False