mcpField
5
5000-projects-analysis

5000-projects-analysis

github.com/datadrivenconstruction数据与数据库375103 次安装1 周前更新
代码仓库

关于 5000-projects-analysis

用于分析大量 IFC 和 Revit 项目的技能,可提取建筑基准、发现模式并为机器学习模型准备数据,适合处理项目级数据集的分析人员和研究者。

主要功能

  1. 01IFC 和 Revit 项目分析
  2. 02结构模式指标
  3. 03质量与完整性指标
  4. 04复杂度指标
  5. 05机器学习特征准备

适用场景

  1. 01将项目与大型数据集进行基准比较
  2. 02发现重复的设计或质量模式
  3. 03为成本预测准备特征
  4. 04从 BIM 项目构建研究数据集

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/datadrivenconstruction/ddc_skills_for_ai_agents_in_construction --skill 5000-projects-analysis

安装后在 Claude Code 中输入/5000-projects-analysis确认已加载。

附带文件claw.jsoninstructions.md

详细介绍

大规模 BIM 项目分析

业务案例

问题陈述

建筑公司缺乏行业基准,因为:

  • 单个项目的数据不足以进行统计分析
  • 无法获得可比较的项目数据
  • 手动分析无法扩展到数千个项目
解决方案

分析 5000+ 个 IFC 和 Revit 项目,提取规律、创建基准,并训练用于预测的 ML 模型。

商业价值
  • 行业基准 - 将您的项目与其他 5000+ 个项目进行比较
  • 规律检测 - 识别常见设计和问题
  • ML 训练数据 - 使用真实数据构建预测模型
  • 研究基础 - 学术和行业研究数据集

技术实现

数据集概览
指标值
项目总数5000+
文件格式IFC、RVT
构件数百万
类别200+
分析流程
import pandas as pd
import numpy as np
from pathlib import Path
from typing import Dict, List
import matplotlib.pyplot as plt
import seaborn as sns

class BIMProjectAnalyzer:
    def __init__(self, data_path: str):
        self.data_path = Path(data_path)
        self.projects = []
        self.elements = None

    def load_projects(self) -> int:
        """Load all project data."""
        project_files = list(self.data_path.glob("*.xlsx"))

        for f in project_files:
            try:
                df = pd.read_excel(f, sheet_name="Elements")
                df['ProjectId'] = f.stem
                self.projects.append(df)
            except Exception as e:
                print(f"Error loading {f}: {e}")

        self.elements = pd.concat(self.projects, ignore_index=True)
        return len(self.projects)

    def project_statistics(self) -> pd.DataFrame:
        """Calculate statistics per project."""
        stats = self.elements.groupby('ProjectId').agg({
            'ElementId': 'count',
            'Category': 'nunique',
            'Volume': ['sum', 'mean'],
            'Area': ['sum', 'mean']
        }).reset_index()

        stats.columns = [
            'ProjectId', 'ElementCount', 'CategoryCount',
            'TotalVolume', 'AvgVolume', 'TotalArea', 'AvgArea'
        ]
        return stats

    def category_distribution(self) -> pd.DataFrame:
        """Analyze element distribution across categories."""
        dist = self.elements.groupby('Category').agg({
            'ElementId': 'count',
            'ProjectId': 'nunique',
            'Volume': 'sum',
            'Area': 'sum'
        }).reset_index()

        dist.columns = ['Category', 'ElementCount', 'ProjectCount',
                        'TotalVolume', 'TotalArea']
        dist['AvgPerProject'] = dist['ElementCount'] / dist['ProjectCount']

        return dist.sort_values('ElementCount', ascending=False)

    def find_outliers(self, column: str, threshold: float = 3.0) -> pd.DataFrame:
        """Find projects with outlier values."""
        stats = self.project_statistics()
        mean = stats[column].mean()
        std = stats[column].std()

        z_scores = np.abs((stats[column] - mean) / std)
        outliers = stats[z_scores > threshold]

        return outliers

    def benchmark_project(self, project_id: str) -> Dict:
        """Compare project against dataset benchmarks."""
        stats = self.project_statistics()
        project = stats[stats['ProjectId'] == project_id].iloc[0]

        percentiles = {}
        for col in ['ElementCount', 'TotalVolume', 'TotalArea']:
            percentile = (stats[col] < project[col]).mean() * 100
            percentiles[col] = round(percentile, 1)

        return {
            'project_id': project_id,
            'percentiles': percentiles,
            'above_average': {
                col: project[col] > stats[col].mean()
                for col in ['ElementCount', 'TotalVolume', 'TotalArea']
            }
        }

    def generate_report(self, output_path: str) -> str:
        """Generate comprehensive analysis report."""
        stats = self.project_statistics()
        cat_dist = self.category_distribution()

        # Create visualizations
        fig, axes = plt.subplots(2, 2, figsize=(14, 10))

        # Element count distribution
        axes[0, 0].hist(stats['ElementCount'], bins=50, edgecolor='black')
        axes[0, 0].set_title('Element Count Distribution')
        axes[0, 0].set_xlabel('Elements per Project')

        # Top categories
        top_cats = cat_dist.head(15)
        axes[0, 1].barh(top_cats['Category'], top_cats['ElementCount'])
        axes[0, 1].set_title('Top 15 Categories')

        # Volume distribution
        axes[1, 0].hist(stats['TotalVolume'], bins=50, edgecolor='black')
        axes[1, 0].set_title('Total Volume Distribution')

        # Category count vs Element count
        axes[1, 1].scatter(stats['CategoryCount'], stats['ElementCount'], alpha=0.5)
        axes[1, 1].set_xlabel('Category Count')
        axes[1, 1].set_ylabel('Element Count')
        axes[1, 1].set_title('Complexity Analysis')

        plt.tight_layout()
        plt.savefig(output_path, dpi=150)

        return output_path
分析示例
# Initialize analyzer
analyzer = BIMProjectAnalyzer("C:/Data/5000_Projects")

# Load all projects
num_projects = analyzer.load_projects()
print(f"Loaded {num_projects} projects")

# Get statistics
stats = analyzer.project_statistics()
print("\nDataset Summary:")
print(f"  Total elements: {analyzer.elements.shape[0]:,}")
print(f"  Avg elements/project: {stats['ElementCount'].mean():,.0f}")
print(f"  Avg volume/project: {stats['TotalVolume'].mean():,.2f} m³")

# Category analysis
categories = analyzer.category_distribution()
print("\nTop 10 Categories:")
print(categories.head(10)[['Category', 'ElementCount', 'AvgPerProject']])

# Benchmark a specific project
benchmark = analyzer.benchmark_project("MyProject_001")
print(f"\nProject Benchmark:")
print(f"  Element count: {benchmark['percentiles']['ElementCount']}th percentile")
print(f"  Total volume: {benchmark['percentiles']['TotalVolume']}th percentile")

# Generate report
report_path = analyzer.generate_report("analysis_report.png")

可提取的洞察

结构规律
  • 墙体与楼板的平均比例
  • 每单位面积的典型门窗数量
  • MEP 构件密度基准
质量指标
  • 类别完整性
  • 参数填充率
  • 几何一致性
复杂度指标
  • 每平方米楼面面积的构件数
  • 类别多样性指数
  • 楼层数与建筑高度的关系

与 ML 集成

from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import train_test_split

# Prepare features for cost prediction
features = stats[[
    'ElementCount', 'CategoryCount',
    'TotalVolume', 'TotalArea'
]].values

# Assuming you have cost data
# costs = [project_cost_data]

# Train model
X_train, X_test, y_train, y_test = train_test_split(
    features, costs, test_size=0.2
)

model = RandomForestRegressor(n_estimators=100)
model.fit(X_train, y_train)

# Predict for new project
new_project = [[5000, 50, 15000, 8000]]  # elements, categories, volume, area
predicted_cost = model.predict(new_project)

资源

评论

支持 Markdown