Skip to main content

TensorFlow-based framework implementing Extreme Learning Machines (ELM) and Random Vector Functional Link (RVFL) networks with all their variants.

Project description

TfELM-RVFL

A comprehensive TensorFlow-based framework implementing Extreme Learning Machines (ELM) and Random Vector Functional Link (RVFL) networks with all their variants.

Overview

TfELM-RVFL extends the original TfELM framework by adding RVFL counterparts for each ELM variant. RVFL networks include direct connections from input to output, often improving generalization performance.

Key Features

  • 27 model implementations (13 ELM + 14 RVFL variants)
  • 22 layer implementations with consistent API
  • 108 activation functions supported
  • Full scikit-learn compatibility (cross_val_score, GridSearchCV, etc.)
  • Multiple learning paradigms: supervised, semi-supervised, unsupervised, online

Installation

Install directly from GitHub:

pip install git+https://github.com/pabhenriquez/Tf-ELM-RVFL.git

Or clone the repository and install in editable mode:

git clone https://github.com/pabhenriquez/Tf-ELM-RVFL.git
cd Tf-ELM-RVFL
pip install -e .

Quick Start

Classification

from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from Layers.RVFLLayer import RVFLLayer
from Models.RVFLModel import RVFLModel

# Load and prepare data
X, y = load_iris(return_X_y=True)
X = StandardScaler().fit_transform(X)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)

# Create and train model
layer = RVFLLayer(number_neurons=100, activation='sigmoid', C=0.001)
model = RVFLModel(layer, task='classification')
model.fit(X_train, y_train)

# Predict
predictions = model.predict(X_test)
accuracy = model.score(X_test, y_test)
print(f"Accuracy: {accuracy:.4f}")

Regression

from sklearn.datasets import load_diabetes
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from Layers.ELMLayer import ELMLayer
from Models.ELMModel import ELMModel

# Load and prepare data
X, y = load_diabetes(return_X_y=True)
X = StandardScaler().fit_transform(X)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3)

# Create and train model
layer = ELMLayer(number_neurons=100, activation='sigmoid', C=0.001)
model = ELMModel(layer, task='regression')
model.fit(X_train, y_train)

# Predict
predictions = model.predict(X_test)
r2_score = model.score(X_test, y_test)
print(f"R² Score: {r2_score:.4f}")

Clustering (Unsupervised)

from sklearn.datasets import load_wine
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import adjusted_rand_score, silhouette_score
from Layers.USRVFLLayer import USRVFLLayer
from Models.USRVFLModel import USRVFLModel

# Load and prepare data
X, y_true = load_wine(return_X_y=True)
X = StandardScaler().fit_transform(X)

# Create unsupervised model for clustering
layer = USRVFLLayer(number_neurons=500, embedding_size=10, lam=0.1, activation='sigmoid')
model = USRVFLModel(layer, task='clustering', n_clusters=3)
model.fit(X)

# Get cluster assignments
labels = model.predict(X)

# Evaluate clustering
ari = adjusted_rand_score(y_true, labels)
sil = silhouette_score(X, labels)
print(f"ARI: {ari:.4f}, Silhouette: {sil:.4f}")

Embedding (Dimensionality Reduction)

from sklearn.datasets import load_iris
from sklearn.preprocessing import StandardScaler
from Layers.USELMLayer import USELMLayer
from Models.USELMModel import USELMModel

# Load and prepare data
X, y = load_iris(return_X_y=True)
X = StandardScaler().fit_transform(X)

# Create unsupervised model for embedding
layer = USELMLayer(number_neurons=500, embedding_size=2, lam=0.1, activation='sigmoid')
model = USELMModel(layer, task='embedding')
model.fit(X)

# Get 2D embeddings
embeddings = model.predict(X)
print(f"Embedding shape: {embeddings.shape}")  # (150, 2)

Cross-Validation with scikit-learn

from sklearn.model_selection import cross_val_score, RepeatedStratifiedKFold
from sklearn.datasets import load_breast_cancer
from sklearn.preprocessing import StandardScaler
from Layers.RVFLLayer import RVFLLayer
from Models.RVFLModel import RVFLModel

# Load data
X, y = load_breast_cancer(return_X_y=True)
X = StandardScaler().fit_transform(X)

# Create model
layer = RVFLLayer(number_neurons=100, activation='sigmoid', C=0.001)
model = RVFLModel(layer, task='classification')

# Cross-validation
cv = RepeatedStratifiedKFold(n_splits=5, n_repeats=3, random_state=42)
scores = cross_val_score(model, X, y, cv=cv, scoring='accuracy')
print(f"Accuracy: {scores.mean():.4f} ± {scores.std():.4f}")

ELM vs RVFL

Aspect ELM RVFL
Output y = H × β y = [H, X] × β
Direct links No Yes
Preserves linear info No Yes

Available Models

Supervised Learning

ELM RVFL Description
ELMModel RVFLModel Basic single hidden layer
KELMModel KRVFLModel Kernel-based
DeepELMModel DeepRVFLModel Deep stacked architecture
ML_ELMModel ML_RVFLModel Multi-layer with autoencoders
RCELMModel RCRVFLModel Residual compensation
OSELMModel OSRVFLModel Online sequential learning
SSELMModel SSRVFLModel Semi-supervised
SSKELMModel SSKRVFLModel Semi-supervised kernel
- EnsembleDeepRVFLModel Ensemble with voting

Unsupervised Learning

ELM RVFL Description
USELMModel USRVFLModel Embedding and clustering
USKELMModel USKRVFLModel Kernel-based unsupervised

Project Structure

TfELM-RVFL/
├── Data/           # 20+ UCI benchmark datasets
├── Examples/       # 5 annotated code examples
├── Layers/         # 22 layer implementations
├── Models/         # 27 model implementations
├── Optimizers/     # 6 optimizer implementations
├── Resources/      # 20 supporting functions
└── requirements.txt

Hyperparameters

Parameter Description Typical Values
number_neurons Hidden layer size 100-1000
activation Activation function 'sigmoid', 'relu', 'tanh'
C Regularization (supervised) 0.001-10
lam Regularization (unsupervised) 0.001-10

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tfelm_rvfl-1.1.0.tar.gz (84.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tfelm_rvfl-1.1.0-py3-none-any.whl (167.7 kB view details)

Uploaded Python 3

File details

Details for the file tfelm_rvfl-1.1.0.tar.gz.

File metadata

  • Download URL: tfelm_rvfl-1.1.0.tar.gz
  • Upload date:
  • Size: 84.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tfelm_rvfl-1.1.0.tar.gz
Algorithm Hash digest
SHA256 4895b12de3911049e82969d01daefd320318a7eba1c5273d4fe18275875bf879
MD5 43a7336a13a91d47c3342bbafd9b16fb
BLAKE2b-256 68124557075e93505b8aacaa2fc0d6af0d4ea368c7839ed950cf098f00f2ef74

See more details on using hashes here.

Provenance

The following attestation bundles were made for tfelm_rvfl-1.1.0.tar.gz:

Publisher: publish.yml on pabhenriquez/Tf-ELM-RVFL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tfelm_rvfl-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: tfelm_rvfl-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 167.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tfelm_rvfl-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54714ac824522306390a6f1f6e8c0c7fcab3f43d3d6452014c10934b9f28f3fb
MD5 a2e89181b781957b5099665e0433569f
BLAKE2b-256 50740bc37c8e53f8321f559039c85f9744f300ba4c6abf4aac9dff2b92d49bb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for tfelm_rvfl-1.1.0-py3-none-any.whl:

Publisher: publish.yml on pabhenriquez/Tf-ELM-RVFL

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page