All Projects → madrury → basis-expansions

madrury / basis-expansions

Licence: BSD-3-Clause license
Basis expansion transformers in sklearn style.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to basis-expansions

Breast Cancer Prediction
Predicting the probability that a diagnosed breast cancer case is malignant or benign based on Wisconsin dataset
Stars: ✭ 19 (-74.32%)
Mutual labels:  sklearn, regression
Machine Learning Projects
This repository consists of all my Machine Learning Projects.
Stars: ✭ 135 (+82.43%)
Mutual labels:  sklearn, regression
Ailearning
AiLearning: 机器学习 - MachineLearning - ML、深度学习 - DeepLearning - DL、自然语言处理 NLP
Stars: ✭ 32,316 (+43570.27%)
Mutual labels:  sklearn, regression
Tensorflow Ml Nlp
텐서플로우와 머신러닝으로 시작하는 자연어처리(로지스틱회귀부터 트랜스포머 챗봇까지)
Stars: ✭ 176 (+137.84%)
Mutual labels:  sklearn, transformer
Machinelearningalgorithm
一些常用的机器学习算法实现
Stars: ✭ 84 (+13.51%)
Mutual labels:  sklearn, regression
ml course
"Learning Machine Learning" Course, Bogotá, Colombia 2019 #LML2019
Stars: ✭ 22 (-70.27%)
Mutual labels:  sklearn, regression
rps-cv
A Rock-Paper-Scissors game using computer vision and machine learning on Raspberry Pi
Stars: ✭ 102 (+37.84%)
Mutual labels:  sklearn
keyword-transformer
Official implementation of the Keyword Transformer: https://arxiv.org/abs/2104.00769
Stars: ✭ 76 (+2.7%)
Mutual labels:  transformer
TitleStylist
Source code for our "TitleStylist" paper at ACL 2020
Stars: ✭ 72 (-2.7%)
Mutual labels:  transformer
sciblox
sciblox - Easier Data Science and Machine Learning
Stars: ✭ 48 (-35.14%)
Mutual labels:  sklearn
proc-that
proc(ess)-that - easy extendable ETL tool for Node.js. Written in TypeScript.
Stars: ✭ 25 (-66.22%)
Mutual labels:  transformer
SGpp
SG⁺⁺ – the numerical library for Sparse Grids in all their variants.
Stars: ✭ 59 (-20.27%)
Mutual labels:  regression
jGeneticNeuralNet
A Java library that trains neural networks with a genetic algorithm.
Stars: ✭ 16 (-78.38%)
Mutual labels:  regression
ML-Track
This repository is a recommended track, designed to get started with Machine Learning.
Stars: ✭ 19 (-74.32%)
Mutual labels:  regression
Cuff less BP Prediction
Prediction of Blood Pressure from ECG and PPG signals using regression methods.
Stars: ✭ 101 (+36.49%)
Mutual labels:  regression
cheapml
Machine Learning algorithms coded from scratch
Stars: ✭ 17 (-77.03%)
Mutual labels:  regression
blorr
Tools for developing binary logistic regression models
Stars: ✭ 16 (-78.38%)
Mutual labels:  regression
En-transformer
Implementation of E(n)-Transformer, which extends the ideas of Welling's E(n)-Equivariant Graph Neural Network to attention
Stars: ✭ 131 (+77.03%)
Mutual labels:  transformer
psyplot
Python package for interactive data visualization
Stars: ✭ 64 (-13.51%)
Mutual labels:  regression
exemplary-ml-pipeline
Exemplary, annotated machine learning pipeline for any tabular data problem.
Stars: ✭ 23 (-68.92%)
Mutual labels:  sklearn

Basis Expansions

This module includes some scikit-learn style transformers that perform basis expansions on a feature x for use in regression. A basis expansions for the feature x is a collection of functions

f_0, f_1, f_2, ...

that are meant to be applied to the feature to construct derived features in a regression model. The functions in the expansions are often chosen to allow the model to adapt to non-linear shapes in the predictor/response relationship. When a basis expansion is applied to the feature x, the result is a new matrix or data frame of derived features

f_0(x), f_1(x), f_2(x), ...

Installation

You can install this library directly from github:

pip install git+https://github.com/madrury/basis-expansions.git

If you would prefer to install from source, first clone this repository:

git clone https://github.com/madrury/basis-expansions.git

And then navigate into the cloned directory, and run pip install

cd basis_expansions
pip install .

Supported Expansions

The following classes are included:

  • Binner: Creates indicator variables by segmenting the range of x into disjoint intervals.
  • GaussianKernel: Create Gaussian Kernel features, also known as "radial basis functions" by people cooler than me.
  • Polynomial: Creates polynomial features. Using these features in a regression fits a polynomial function of a given degree x to y.
  • LinearSpline: Creates a piecewise linear spline which joins continuously at the knots. Using this in a regression fits a piecewise linear function of x to y.
  • CubicSpline: Creates a piecewise cubic spline which joins continuously, differentiably, and second differentiably at a set of supplied knots.
  • NaturalCubicSpline: Creates a piecewise natural cubic spline (cubic curves in the interior segments, linear in the exterior segments) which joins continuously, differentiably, and second differentiably at a set of supplied knots.

Basis Expansions

Examples

The most basic use case is to transform a numpy.array:

x = np.random.uniform(0, 1, size=10)
pl = LinearSpline(knots=[0.25, 0.75])
pl.fit_transform(x)

which results in a two dimensional array:

array([[ 0.21776114,  0.        ,  0.        ],
       [ 0.63360478,  0.38360478,  0.        ],
       [ 0.29089787,  0.04089787,  0.        ],
       [ 0.83284663,  0.58284663,  0.08284663],
       [ 0.89158883,  0.64158883,  0.14158883],
       [ 0.97076139,  0.72076139,  0.22076139],
       [ 0.83373019,  0.58373019,  0.08373019],
       [ 0.39301854,  0.14301854,  0.        ],
       [ 0.27773455,  0.02773455,  0.        ],
       [ 0.68772864,  0.43772864,  0.        ]])

If we transform a pandas.Series:

s = pd.Series(x, name="moshi")
pl = LinearSpline(knots=[0.25, 0.75])
pl.fit_transform(s)

the result is a pandas.DataFrame:

   moshi_spline_linear  moshi_spline_0  moshi_spline_1
0             0.217761        0.000000        0.000000
1             0.633605        0.383605        0.000000
2             0.290898        0.040898        0.000000
3             0.832847        0.582847        0.082847
4             0.891589        0.641589        0.141589
5             0.970761        0.720761        0.220761
6             0.833730        0.583730        0.083730
7             0.393019        0.143019        0.000000
8             0.277735        0.027735        0.000000
9             0.687729        0.437729        0.000000

More advanced use can combine these transformers with sklearn.pipeline objects. For helper classes that allow for transformations on pandas.DataFrames, see examples/dftransformers.py.

Examples

See the basis-expansions-regressions.ipynb notebook for examples of use.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].