Skip to main content


Project description


PyPi version Python version

Lapras is developed to facilitate the dichotomy model development work.


via pip

pip install lapras

via source code

python install


import pandas as pd
import lapras

# read data file as pandas dataframe
df = pd.read_csv('data/model_data.csv',encoding="utf-8")
to_drop = ['id']
target = 'bad'

# feature selection
lapras.quality(df.drop(to_drop,axis=1),target = target)
train_selected, dropped =,axis=1),target = target, empty = 0.9, \
                                                iv = 0.02, corr = 0.7, return_drop=True, exclude=[])

# bins   method = ['dt', 'kmeans', 'step', 'quantile']                                    
c = lapras.Combiner(), y = target, method = 'dt', min_samples = 0.05,n_bins=8)
# c.load({}) # export the default bins and change it as you wish, finally load it back and take effects.

# bins visualization
cols = train_selected.columns
for col in cols:
    if col != target:
        lapras.bin_plot(c.transform(train_selected[[col,target]], labels=True), col=col, target=target)

# transfer to WOE
transfer = lapras.WOETransformer()
train_woe = transfer.fit_transform(c.transform(train_selected), train_selected[target], exclude=[target])

# stepwise method to choose features
final_data = lapras.stepwise(train_woe,target = target, estimator='ols', direction = 'both', criterion = 'aic', exclude = [])

# ScoreCard fit, predict and export
card = lapras.ScoreCard(
    combiner = c,
    transfer = transfer,
col = list(final_data.drop([target],axis=1).columns)[col], final_data[target])
final_data['score'] = card.predict(final_data[col])
final_data['prob'] = card.predict_prob(final_data[col])

#  performance
lapras.score_plot(final_data,score='score', target=target)


A simple API.

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

lapras-0.0.14.tar.gz (27.3 kB view hashes)

Uploaded Source

Built Distribution

lapras-0.0.14-py2.py3-none-any.whl (34.1 kB view hashes)

Uploaded Python 2 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