This package implements a learning method based on the Moore-Penrose inverse for hybrid Fuzzy Cognitive Maps. In this model, the user can specify how the variables interact or let the algorithm compute that matrix from the data using unsupervised learning. The supervised learning step focuses on computing the relationships between the last hidden state of the network and the outputs. Therefore, the model is devoted to solving multi-output regression problems where problem features are connected in non-trivial ways.
FCP_MP can be installed from PyPI
pip install fcm-mp
The Fuzzy Cognitive Map model implemented in this package is designed for multi-output regression problems.
The model is composed of two blocks. The inner block concerns the input concepts and the relationships between them, and it can be defined by domain experts. The outer block concerns the relationships between input and output concepts. These relationships are not defined by domain experts, but computed from the historical data using the Moore-Penrose inverse learning algorithm. Fig. 1 shows an example involving five variables where three are inputs while the others are outputs.
The weight matrix of the FCM_MP model is denoted as
The syntax for the usage of FCM_MP is compatible with scikit-learn library.
Let's assume that we want to solve a decision-making problem involving three input variables (
# This matrix contains the data concerning the input variables
X = np.array([[0.37, 0.95, 0.73],
[0.60, 0.16, 0.16],
[0.06, 0.87, 0.60],
[0.71, 0.02, 0.97],
[0.83, 0.21, 0.18]])
# This matrix contains the data concerning the output variables
Y = np.array([[0.35, 0.47],
[0.37, 0.43],
[0.42, 0.50],
[0.26, 0.48],
[0.33, 0.4]]) The next step consists of defining a weight matrix
# This matrix characterizes the relationships between input variables
Wi = np.array([[0.00, -1.00, -0.27],
[-0.50, 0.00, 0.15],
[-0.20, 0.23, 0.00]]) Now, we are ready to build the FCM model. Besides the weight matrix defining the interaction between the input variables, we can specify the number of iterations
from fcm.FCM_MP import FCM_MP
# We first define parameters and then build the model
model = FCM_MP(T=10, phi=0.5, slope=1.0, offset=0.0)
model.fit(X,Y)We can contrast the predictions made by the model with the ground truth. To obtain the predictions for the training data model.predict(X) function, which results in the following matrix:
As we can see, the predictions computed by the FCM_MP model are reasonably close to the ground truth
rmse = np.sqrt(np.mean((Y-Y_hat)**2))
print(np.round(rmse, 4))
# RMSE=0.0088If you use the FCM_MP model in your research please cite the following paper:
@article{NAPOLES2020258,
title = {Deterministic learning of hybrid Fuzzy Cognitive Maps and network reduction approaches},
journal = {Neural Networks},
volume = {124},
pages = {258-268},
year = {2020},
doi = {https://doi.org/10.1016/j.neunet.2020.01.019},
author = {Gonzalo Nápoles and Agnieszka Jastrzębska and Carlos Mosquera and Koen Vanhoof and Władysław Homenda}
}
