Expectation Reflection for classification
Project description
Expectation Reflection
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 advantages in dealing with problems of small sample sizes (compared with number of features).
Citation
Please cite the following papers if you use this package in your publication:
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 interceptb
and interaction weightsw
from featuresX_train
to targety_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
andw
, we can predict outputsy_pred
and their probabilityp_pred
of new inputsX_test
:
y_pred,p_pred = ER.predict(X_test,b,w)
print('predicted output:',y_pred)
print('predicted probability:',p_pred)
Project details
Release history Release notifications | RSS feed
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
Hashes for expectation_reflection-0.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e764363245bb9d7a2ea4a5cb4c56a977b5d1f598d65935c1a71caf1e56ef885 |
|
MD5 | a563c4e3072dd54b35574791319d2390 |
|
BLAKE2b-256 | 4dba951eacf6d01ff62bf308e7508bff731a2de3be59c7b26e381ebef1d08e6d |
Hashes for expectation_reflection-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26ebfe6f128290b0bfc504123eb8806515fe69cd703820f593530eecd141e289 |
|
MD5 | f0c3a98b7b81626a32a79bb0eea6c06c |
|
BLAKE2b-256 | 7c5703f480926e4c0f13eee96c169272f8da20a6672b90e8fa69fdbed1f2f47d |