minires / mini-pricing.py
nicolamustone's picture
Add mini-pricing.py script and update README
ef3fe89
from pathlib import Path
import pandas as pd
from minires import minires
# ==== Edit these numbers for your context ====
RESIN_COST_PER_GRAM = 0.06 # in your currency, e.g. 0.06 = €0.06/gram
OVERHEAD_PER_MINI = 1.50 # fixed overhead per miniature (packaging, time, etc.)
INPUT_CSV = Path("stl_features.csv")
OUTPUT_CSV = Path("mini_pricing.csv")
# =============================================
def main() -> None:
if not INPUT_CSV.exists():
raise SystemExit(f"Input CSV not found: {INPUT_CSV}. "
"Run stl-scanner.py first.")
# Load STL features produced by stl-scanner.py
df = pd.read_csv(INPUT_CSV)
# Create MiniRes ensemble model
model = minires(verbose=0)
# Predict resin usage in grams
grams = model.predict(df)
df["predicted_grams"] = grams
df["resin_cost"] = df["predicted_grams"] * RESIN_COST_PER_GRAM
df["overhead"] = OVERHEAD_PER_MINI
df["total_cost"] = df["resin_cost"] + df["overhead"]
df.to_csv(OUTPUT_CSV, index=False)
print(f"Wrote pricing table to {OUTPUT_CSV.resolve()}")
if __name__ == "__main__":
main()