Skip to main content

Expectation Reflection for classification

Project description

Expectation Reflection (ER) is a multiplicative optimization method that train the interaction weights from features to target according to the ratio of target observations to their corresponding model expectations. This approach completely separates model updates from minimization of a cost function measuring goodness of fit, so that this cost function can be used as the stopping criterion of the iteration. Therefore, this method has advantage in dealing with the problems of small sample sizes (but many features). Using only one hyperparameter is another benefit of this method.

Installation

From PyPi

pip install expectation-reflection

From Repository

git clone https://github.com/danhtaihoang/expectation-reflection.git

Usage

  • Import expectation_reflection package into python script:
from expectation_reflection import classication as ER
  • Train the model with (X_train, y_train) to get the value of intercept b and interaction weights w from features X_train to target y_train. In the current version, the target needs to be formatted in form of [0,1]:
b,w = ER.fit(X_train, y_train, iter_max, regu)
print('intercept:', b)
print('interaction weights:', w)
  • Using the trained b and w, we can predict outputs y_pred and their probability p_pred of new inputs X_test:
y_pred,p_pred = ER.predict(X_test,b,w)
print('predicted output:',y_pred)
print('predicted probability:',p_pred)

Citation

Please cite the following papers if you use this package in your work:

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

expectation_reflection-0.0.3.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

expectation_reflection-0.0.3-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

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