Skip to content
Python code for the semi-supervised learning method particle competition and cooperation
Branch: master
Clone or download
Latest commit 52016a2 Sep 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information. Update Sep 16, 2019 import fixes Sep 11, 2019

Particle Competition and Cooperation

Python code for the semi-supervised learning method "particle competition and cooperation".

Getting Started


You need Python 3.7 or later to use pycc. You can find it at

The package is avaliable at PyPI. If you have pip, just run:

pip install pypcc

or clone this repo to your local machine using:

git clone


The usage of this class is pretty similar to semi-supervised algorithms at scikit-learn.


Considering the following iris.csv file located on /home/datasets:

sepal_l  sepal_w  petal_l  petal_w  label
5.1      3.5      1.4      0.2      Iris-setosa
4.9      3.0      1.4      0.2      Iris-setosa
7.0      3.2      4.7      1.4      Iris-versicolor
6.4      3.2      4.5      1.5      Iris-versicolor
6.3      3.3      6.0      2.5      Iris-virginica
5.8      2.7      5.1      1.9      Iris-virginica

One way to execute the particle competition and cooperation algorithm is to run:

from pypcc.model import ParticleCompetitionCooperation

df = pd.read_csv('/home/datasets/iris.csv')
data = df.loc[:,df.columns != 'label'].values
labels = df.loc[:,'label'].values

model = ParticleCompetitionAndCooperation(n_neighbors=32, pgrd=0.6, delta_v=0.35, max_iter=100), labels)
pred = model.predict(data)


As output, a report containing the accuracy for all present classes is shown:

45/45 - 1.00

41/45 - 0.91

39/45 - 0.87

125/135 - 0.93


As arguments, pycc receives the values explained below:

  • n_neighbors: value that represents the number of neighbours in the graph build.
  • pgrd: value from 0 to 1 that defines the probability of particles to take the greedy movement.
  • delta_v: value from 0 to 1 to control changing rate of the domination levels.
  • max_iter: number of epochs until the label propagation stops.


If you use this algorithm, please cite the original publication:

Breve, Fabricio Aparecido; Zhao, Liang; Quiles, Marcos Gonçalves; Pedrycz, Witold; Liu, Jiming, "Particle Competition and Cooperation in Networks for Semi-Supervised Learning," Knowledge and Data Engineering, IEEE Transactions on , vol.24, no.9, pp.1686,1698, Sept. 2012

Accepted Manuscript:

You can’t perform that action at this time.