A Python implementation of the Fisher Scoring algorithm for logistic regression, multinomial regression, and focal loss regression.
Project description
Fisher Scoring Logistic Regression
Author: xRiskLab
Version: Beta v0.1
License: MIT License (2024)
Overview
This repository contains Python implementations of the Fisher Scoring algorithm for various logistic regression models:
- Fisher Scoring Logistic Regression: Standard logistic regression using Fisher scoring.
- Fisher Scoring Multinomial Regression: Multinomial logistic regression for multi-class classification.
- Fisher Scoring Focal Loss Regression: Logistic regression with focal loss for imbalanced classification problems.
The Fisher Scoring algorithm is an iterative optimization algorithm that updates model parameters using the observed or expected Fisher information matrix.
Models
Fisher Scoring Logistic Regression
The FisherScoringLogisticRegression
class is a custom implementation of logistic regression using the Fisher scoring algorithm. It provides methods for fitting the model, making predictions, and computing model statistics, including standard errors, Wald statistics, p-values, and confidence intervals.
Parameters:
epsilon
: Convergence threshold for the algorithm.max_iter
: Maximum number of iterations for the algorithm.information
: Type of information matrix to use ('expected' or 'observed').use_bias
: Include a bias term in the model.significance
: Significance level for computing confidence intervals.
Methods:
fit(X, y)
: Fit the model to the data.predict(X)
: Predict target labels for input data.predict_proba(X)
: Predict class probabilities for input data.get_params()
: Get model parameters.set_params(**params)
: Set model parameters.summary()
: Get a summary of model parameters, standard errors, p-values, and confidence intervals.display_summary()
: Display a summary of model parameters, standard errors, p-values, and confidence intervals.
Fisher Scoring Multinomial Regression
The FisherScoringMultinomialRegression
class implements the Fisher Scoring algorithm for multinomial logistic regression, suitable for multi-class classification tasks.
Parameters:
epsilon
: Convergence threshold for the algorithm.max_iter
: Maximum number of iterations for the algorithm.information
: Type of information matrix to use ('expected' or 'observed').use_bias
: Include a bias term in the model.significance
: Significance level for computing confidence intervals.verbose
: Enable verbose output.
Methods:
fit(X, y)
: Fit the model to the data.predict(X)
: Predict target labels for input data.predict_proba(X)
: Predict class probabilities for input data.summary(class_idx)
: Get a summary of model parameters, standard errors, p-values, and confidence intervals for a specific class.display_summary(class_idx)
: Display a summary of model parameters, standard errors, p-values, and confidence intervals for a specific class.
The algorithm is in a beta version and may require further testing and optimization to speed up matrix operations.
Fisher Scoring Focal Loss Regression
The FisherScoringFocalRegression
class implements the Fisher Scoring algorithm with focal loss, designed for imbalanced classification problems where the positive class is rare.
Parameters:
gamma
: Focusing parameter for focal loss.epsilon
: Convergence threshold for the algorithm.max_iter
: Maximum number of iterations for the algorithm.information
: Type of information matrix to use ('expected' or 'observed').use_bias
: Include a bias term in the model.verbose
: Enable verbose output.
The algorithm is experimental and may require further testing and optimization.
Installation
To use the models, clone the repository and install the required dependencies.
git clone https://github.com/xRiskLab/fisher-scoring.git
cd fisher-scoring
pip install -r requirements.txt
Change Log
-
v0.1.3
- Added coefficients, standard errors, p-values, and confidence intervals for Multinomial Regression.
-
v0.1.2
- Updated NumPy dependency.
-
v0.1.1
- Added support for Python 3.9+ 🐍.
-
v0.1.0
- Initial release of Fisher Scoring Logistic, Multinomial, and Focal Loss Regression.
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
Built Distribution
File details
Details for the file fisher_scoring-0.1.3.tar.gz
.
File metadata
- Download URL: fisher_scoring-0.1.3.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5b65a482573042c8ae4cd619d6ee91c49cb1b5e1775008e7ff207252fce0f20 |
|
MD5 | 9dee9f085c4cb8f97eb69f9ce336b43d |
|
BLAKE2b-256 | 53667f0ca7fdd91f03769674d594f0ad268e43b5d4081578553b41518460a405 |
Provenance
File details
Details for the file fisher_scoring-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: fisher_scoring-0.1.3-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.10.12 Darwin/23.4.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce921b059fcbfb365b4e6315e2ce4dc90a17184d613058fbcf1f217c4367419d |
|
MD5 | ed0e72ce4e966c23c9e05e0cb86a57ac |
|
BLAKE2b-256 | 092d698ed1c40231eb791bdc8eb1253c48e97bb0e4c086bdc21ed01024f63e4b |