闲社服务运行正常AI智能体自动化平台
h

历史成本分析

技能标识:historical-cost-analyzer"

Analyze historical construction costs for benchmarking, trend analysis, and estimating calibration. Compare projects, track escalation, identify patterns."

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 2.0.0
检测标记
后台标记通过
免费
免费获取
0
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

历史成本分析

技能名称:historical-cost-analyzer

施工历史成本分析器

概述

分析历史施工成本数据,用于基准测试、成本上涨追踪和估算校准。比较类似项目,识别成本驱动因素,并改进未来估算。

商业案例

历史成本分析能够实现:

  • - 基准测试:将当前估算与过往项目进行比较
  • 校准:利用实际数据提高估算准确性
  • 趋势分析:追踪成本上涨和市场变化
  • 风险评估:识别成本驱动因素和超支模式

技术实现

python
from dataclasses import dataclass, field
from typing import List, Dict, Any, Optional, Tuple
import pandas as pd
import numpy as np
from datetime import datetime
from scipy import stats

@dataclass
class CostBenchmark:
metric_name: str
value: float
unit: str
percentile_25: float
percentile_50: float
percentile_75: float
sample_size: int
project_types: List[str]

@dataclass
class EscalationAnalysis:
from_year: int
to_year: int
annual_rate: float
total_change: float
category: str
confidence: float

@dataclass
class CostDriver:
factor: str
impact_percentage: float
correlation: float
description: str

class HistoricalCostAnalyzer:
分析历史施工成本。

# RSMeans城市成本指数(示例——将从数据库加载)
LOCATION_FACTORS = {
New York: 1.32, San Francisco: 1.28, Los Angeles: 1.15,
Chicago: 1.12, Houston: 0.92, Dallas: 0.89,
Phoenix: 0.93, Atlanta: 0.91, Denver: 1.02,
Seattle: 1.08, National Average: 1.00
}

# 按年份划分的历史成本指数
COST_INDICES = {
2015: 100.0, 2016: 102.1, 2017: 105.3, 2018: 109.2,
2019: 112.5, 2020: 114.8, 2021: 121.4, 2022: 135.6,
2023: 142.3, 2024: 148.7, 2025: 154.2, 2026: 160.0
}

def init(self, historical_data: pd.DataFrame = None):
self.data = historical_data
self.benchmarks: Dict[str, CostBenchmark] = {}

def load_data(self, data: pd.DataFrame):
加载历史项目数据。
self.data = data.copy()

# 标准化数据
if completionyear not in self.data.columns and completiondate in self.data.columns:
self.data[completionyear] = pd.todatetime(self.data[completion_date]).dt.year

# 计算关键指标
if grossarea in self.data.columns and finalcost in self.data.columns:
self.data[costpersf] = self.data[finalcost] / self.data[grossarea]

if originalestimate in self.data.columns and finalcost in self.data.columns:
self.data[overrunpct] = ((self.data[finalcost] - self.data[original_estimate])
/ self.data[original_estimate] * 100)

def normalizetoyear(self, costs: pd.Series, from_years: pd.Series,
to_year: int = 2026) -> pd.Series:
使用成本指数将成本标准化到同一年份。
normalized = costs.copy()

for i, (cost, year) in enumerate(zip(costs, from_years)):
if pd.notna(cost) and pd.notna(year):
year = int(year)
if year in self.COSTINDICES and toyear in self.COST_INDICES:
factor = self.COSTINDICES[toyear] / self.COST_INDICES[year]
normalized.iloc[i] = cost * factor

return normalized

def normalizetolocation(self, costs: pd.Series, locations: pd.Series,
to_location: str = National Average) -> pd.Series:
将成本标准化到同一地点。
normalized = costs.copy()
tofactor = self.LOCATIONFACTORS.get(to_location, 1.0)

for i, (cost, loc) in enumerate(zip(costs, locations)):
if pd.notna(cost) and loc in self.LOCATION_FACTORS:
fromfactor = self.LOCATIONFACTORS[loc]
normalized.iloc[i] = cost * (tofactor / fromfactor)

return normalized

def calculatebenchmarks(self, projecttype: str = None,
year_range: Tuple[int, int] = None) -> Dict[str, CostBenchmark]:
根据历史数据计算成本基准。
df = self.data.copy()

# 按项目类型筛选
if projecttype and projecttype in df.columns:
df = df[df[projecttype] == projecttype]

# 按年份范围筛选
if yearrange and completionyear in df.columns:
df = df[(df[completionyear] >= yearrange[0]) &
(df[completionyear] <= yearrange[1])]

benchmarks = {}

# 每平方英尺成本
if costpersf in df.columns:
values = df[costpersf].dropna()
if len(values) > 0:
benchmarks[costpersf] = CostBenchmark(
metric_name=Cost per SF,
value=values.median(),
unit=$/SF,
percentile_25=values.quantile(0.25),
percentile_50=values.quantile(0.50),
percentile_75=values.quantile(0.75),
sample_size=len(values),
projecttypes=[projecttype] if projecttype else df[projecttype].unique().tolist()
)

# 超支百分比
if overrun_pct in df.columns:
values = df[overrun_pct].dropna()
if len(values) > 0:
benchmarks[overrun_pct] = CostBenchmark(
metric_name=Cost Overrun,
value=values.median(),
unit=%,
percentile_25=values.quantile(0.25),
percentile_50=values.quantile(0.50),
percentile_75=values.quantile(0.75),
sample_size=len(values),
projecttypes=[projecttype] if projecttype else df[projecttype].unique().tolist()
)

self.benchmarks.update(benchmarks)
return benchmarks

def calculate_escalation(self, category: str = overall,
from_year: int = 2020,
to_year: int = 2026) -> EscalationAnalysis:
计算年份之间的成本上涨。
if fromyear in self.COSTINDICES and toyear in self.COSTINDICES:
fromindex = self.COSTINDICES[from_year]
toindex = self.COSTINDICES[to_year]

totalchange = (toindex - fromindex) / fromindex
years = toyear - fromyear
annualrate = (toindex / from_index) (1 / years) - 1 if years > 0 else 0

return EscalationAnalysis(
fromyear=fromyear,
toyear=toyear,
annualrate=annualrate,
totalchange=totalchange,
category=category,
confidence=0.95
)

return None

def identifycostdrivers(self, targetcol: str = costper_sf) -> List[CostDriver]:
识别驱动成本的因素。
if self.data is None or target_col not in self.data.columns:
return []

drivers = []
target = self.data[target_col].dropna()

# 分析数值列
numericcols = self.data.selectdtypes(include=[np.number]).columns
exclude = [targetcol, finalcost, original_estimate]

for col in numeric_cols:
if col not in exclude:
validmask = self.data[col].notna() & self.data[targetcol].notna()
if valid_mask.sum() > 10:
corr, p_value = stats.pearsonr(
self.data.loc[valid_mask, col],
self.data.loc[validmask, targetcol]
)

if abs(corr) > 0.3 and p_value < 0.05:
impact = corr self.data[col].std() / target.std() 100

drivers.append(CostDriver(
factor=

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 historical-cost-analyzer-1776344471 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 historical-cost-analyzer-1776344471 技能

通过命令行安装

skillhub install historical-cost-analyzer-1776344471

下载

⬇ 下载 historical-cost-analyzer" v2.0.0(免费)

文件大小: 6.26 KB | 发布时间: 2026-4-17 15:56

v2.0.0 最新 2026-4-17 15:56
Version 2.0.0 introduces a full rewrite, adding robust construction cost analysis and reporting features.

- Major rewrite and restructuring for clarity and usability.
- Skill now analyzes historical construction costs for benchmarking, escalation tracking, and estimation calibration.
- Supports location and time normalization, cost escalation analysis, and identification of cost drivers.
- New data model classes (CostBenchmark, EscalationAnalysis, CostDriver) for clear and structured outputs.
- Usage examples and clear documentation added for practical implementation.
返回顶部