PROJECT 037 · PYTHON SOURCE
Curing age and measured strength
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': 37, 'dataset': 'concrete', 'title': 'Curing age and measured strength', 'question': 'How do strength distributions differ across curing-age bands?', 'method': 'Prespecified age bands with median, quartiles and sample counts.', 'action': 'Form a controlled curing-time experiment with comparable mix formulations.', 'limitations': 'Laboratory observations do not certify a construction mix. Composition and curing conditions are confounded. Models require independent engineering validation and cannot replace strength testing. '}
def analyze():
df = load('concrete').copy()
df['age_band']=pd.cut(df.age,[0,7,14,28,56,90,np.inf]).astype(str)
t=df.groupby('age_band').strength.agg(samples='size',median_strength='median',p25=lambda s:s.quantile(.25),p75=lambda s:s.quantile(.75)).reset_index()
out=result(t,'age_band','median_strength','MPa','Mix compositions differ across ages; this is not a longitudinal estimate of strength gain.')
return out
if __name__ == "__main__":
execute(Path(__file__).parent, META, analyze)