Cluster¶
The classes in Cluster
defines how each instrument should be grouped in a cluster.
- class fipie.NoCluster¶
Create no cluster and put all instruments into one group which is the classical way of constructing a portfolio
- __init__()¶
Instantiate the clustering algorithm. No extra parameter is needed.
- create_clusters(data: pandas.core.frame.DataFrame) numpy.array ¶
Return a list of cluster indices for each instrument
- Parameters
data – instrument returns which the clustering method is based on
- Returns
array of cluster indices
- Return type
np.array
- class fipie.CorrMatrixDistance(max_clusters: int)¶
Create clusters based on the distance in correlation matrix. The
max_node_size
parameter controls the maximum number of instruments in a cluster.- __init__(max_clusters: int)¶
Instantiate the clustering algorithm
- Parameters
max_clusters (int) – maximum number of clusters (or instruments) one cluster can have.
- create_clusters(data: pandas.core.frame.DataFrame) numpy.array ¶
Return a list of cluster indices for each instrument
- Parameters
data – instrument returns which the clustering method is based on
- Returns
array of cluster indices
- Return type
np.array
- pre_process(data: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame ¶
Pre-process the data time-series before feeding to the clustering algorithm. Remove instruments whose return standard deviation is zero in which case the correlation matrix can not be computed.
- Parameters
data (pd.DataFrame) – instrument returns which the clustering method is based on
- Returns
pre-processed data
- Return type
pd.DataFrame