PyFCM
Fuzzy cognitive maps python library. Also, supports the topology generation from data to solve classification problems. The details associated to the generation process are described in this paper.
Installation
From source:
- Clone repository:
$ git clone https://github.com/J41R0/PyFCM.git $ cd PyFCM - Install setup tools and package:
$ pip install setuptools $ python setup.py install
From PyPi:
- Install package using pip:
$ pip install py-fcm
Example usage
Inference:
from py_fcm import from_json
fcm_json = """{
"max_iter": 500,
"decision_function": "LAST",
"activation_function": "sigmoid",
"memory_influence": False,
"stability_diff": 0.001,
"stop_at_stabilize": True,
"extra_steps": 5,
"weight": 1,
"concepts":
[
{
"id": "concept_1",
"is_active": True,
"type": "SIMPLE",
"activation": 0.5
},
{
"id": "concept_2", "is_active": True,
"type": "DECISION", "activation": 0.0,
"custom_function": "gceq",
"custom_function_args": {"weight": 0.3}
},
{
"id": "concept_3",
"is_active": True,
"type": "SIMPLE",
"activation": 0.0,
"use_memory": True
},
{
"id": "concept_4",
"is_active": True,
"type": "SIMPLE",
"activation": 0.3,
"custom_function": "saturation"
}
],
"relations":
[
{"origin": "concept_4", "destiny": "concept_2", "weight": -0.1},
{"origin": "concept_1", "destiny": "concept_3", "weight": 0.59},
{"origin": "concept_3", "destiny": "concept_2", "weight": 0.8911}
],
'activation_function_args': {'lambda_val': 1},
"""
my_fcm = from_json(fcm_json)
my_fcm.run_inference()
result = my_fcm.get_final_state(concept_type='any')
print(result)
Generation:
import pandas
from py_fcm import FcmEstimator
data_dict = {
'F1': ['x', 'x', 'y', 'y'],
'F2': [9.8, 7.3, 1.1, 3.6],
'class': ['a', 'a', 'r', 'r']
}
train = pandas.DataFrame(data_dict)
x_train = train.loc[:, train.columns != 'class']
y_train = train.loc[:, 'class']
estimator = FcmEstimator()
estimator.fit(x_train, y_train)
print(estimator.predict(x_train))
print("Accuracy: ",estimator.score(x_train, y_train))
print(estimator.get_fcm().to_json())
Metadata
Release files for py-fcm 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_fcm-1.0.0.tar.gz | 48.8 kB | Without provenance | Details for py_fcm-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_fcm-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for py_fcm-1.0.0-py3-none-any.whl |
Total release size: 103.6 kB
Release files / py_fcm-1.0.0.tar.gz
| Download URL | py_fcm-1.0.0.tar.gz |
|---|---|
| Size | 48.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
568cac736c482ab0808b3f61684ad78f233bf550e16a048fb8b007d668a34501
|
|
BLAKE2b-256 checksum How to use checksums |
dbc1d3c469f019c65cbccbebf37c5a955324a9e8a4d4f748a7e6e65980f2988a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Release files / py_fcm-1.0.0-py3-none-any.whl
| Download URL | py_fcm-1.0.0-py3-none-any.whl |
|---|---|
| Size | 54.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4d1db17c2e3b88034ca7d949dff6bcf75e8d1e0c17cb7beb4a87885394127c1
|
|
BLAKE2b-256 checksum How to use checksums |
0ee4f7d0f530eda7e7d0fdaec19f5f83a32922d3d689a4303868e69889a7be3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/51.0.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3
|
Security for py-fcm 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.