KELMOR
A Python Implementation of Kernel Extreme Learning Machine for Ordinal Regression
Install / Use
/learn @jlsuarezdiaz/KELMORREADME
KELMOR
A Python implementation of Kernel Extreme Learning Machine for Ordinal Regression (KELMOR)
Usage
Download the file KELMOR.py and import it into your Python scripts:
from sys import path
from sklearn.datasets import load_iris
from sklearn.model_selection import StratifiedShuffleSplit
from sklearn.metrics import mean_absolute_error as mae
# Adding KELMOR.py to the path
path.append(".") # Replace . by the folder that contains KELMOR.py
# Import KELMOR module and class
kelmor_module = __import__("KELMOR")
KELMOR = kelmor_module.KELMOR
# Load the dataset
X, y = load_iris(return_X_y=True)
sss = StratifiedShuffleSplit(n_splits=1, test_size=0.2)
train_inds, test_inds = next(sss.split(X, y))
Xtra, ytra = X[train_inds, :], y[train_inds]
Xtst, ytst = X[test_inds, :], y[test_inds]
# Train kelmor on a dataset
kelmor = KELMOR(C=10, kernel="rbf")
kelmor.fit(Xtra, ytra)
# Predicting samples
ypred = kelmor.predict(Xtst)
# Mean absolute error of the predictions
print(mae(ytst, ypred))
# Output: 0.033333333
Parameters
- C: float, default=1. Adjusting parameter. Must be strictly positive.
- method: string, default="full". Method used for the factorization of the kernel matrix. Currently supported values are:
- "full": no factorization is applied (KELMOR).
- S: int, default=None. The numerical rank expected in the factorization of the kernel matrix. If None, S will be the number of samples in the dataset. Ignored if
method==full- - eps: float, default=1e-5. Error tolerance in the kernel matrix factorization. Ignored if
method==full. - kernel: string or callable, default="linear". The kernel to be used. Allowed values are: "linear" | "poly" | "rbf" | "sigmoid" | "cosine" | "precomputed".
- gamma: float, default=1/n_features. Kernel coefficient for rbd, poly and sigmoid kernels. Ignored by other kernels.
- degree: int, default=3. Degree for poly kernels. Ignored by other kernels.
- coef0: float, default=1. Independent term in poly and sigmoid kernels. Ignored by other kernels.
- kernel_params: mapping of string to any, default=None. Parameters (keyword arguments) and values for kernel passed as callable object. Ignored by other kernels.
Compatibility and dependencies
The script is compatible with Python 3 and has been fully-tested in Python 3.7. numpy and scikit-learn libraries are needed.
References
Shi, Y., Li, P., Yuan, H., Miao, J., & Niu, L. (2019). Fast kernel extreme learning machine for ordinal regression. Knowledge-Based Systems, 177, 44-54.
Related Skills
YC-Killer
2.7kA library of enterprise-grade AI agents designed to democratize artificial intelligence and provide free, open-source alternatives to overvalued Y Combinator startups. If you are excited about democratizing AI access & AI agents, please star ⭐️ this repository and use the link in the readme to join our open source AI research team.
flutter-tutor
Flutter Learning Tutor Guide You are a friendly computer science tutor specializing in Flutter development. Your role is to guide the student through learning Flutter step by step, not to provide d
groundhog
398Groundhog's primary purpose is to teach people how Cursor and all these other coding agents work under the hood. If you understand how these coding assistants work from first principles, then you can drive these tools harder (or perhaps make your own!).
last30days-skill
16.9kAI agent skill that researches any topic across Reddit, X, YouTube, HN, Polymarket, and the web - then synthesizes a grounded summary
