PROJECT 019 · PYTHON SOURCE
Previous campaign outcomes
Study-specific code. Shared modules, dependency versions, and reproduction instructions are included in all project files.
Download Python file ↓from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
import numpy as np
import pandas as pd
from scipy.stats import spearmanr
from sklearn.decomposition import PCA
from sklearn.ensemble import IsolationForest
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import confusion_matrix, precision_score, recall_score
from portfolio.data import load
from portfolio.constants import *
from portfolio.methods import result, sql, rates, associations, distribution, regression, classification, cluster
from portfolio.engine import execute
META = {'id': 19, 'dataset': 'bank', 'title': 'Previous campaign outcomes', 'question': 'Do prior successful campaign records identify a different response population?', 'method': 'Response rates by recorded previous outcome.', 'action': 'Review how prior engagement should enter a future campaign experiment.', 'limitations': 'Observational marketing records do not identify campaign uplift. Month and row order are not precise timestamps; repeated-client identifiers are unavailable. Models are research diagnostics, not financial eligibility or automated contact decisions. '}
def analyze():
df = load('bank').copy()
t=rates(df,'poutcome','subscribed')
out=result(t,'poutcome','rate','Subscription share','Unknown prior outcomes remain separate from failure. Historical success is an association, not a guarantee.')
return out
if __name__ == "__main__":
execute(Path(__file__).parent, META, analyze)