mcpField
L
llm-data-automation

llm-data-automation

github.com/datadrivenconstructionデータ・データベース375108 回インストール1 週間前に更新
リポジトリ

llm-data-automation について

自然言語のデータ処理依頼から Python と Pandas のコードを生成する、建設業向けスキルです。プロジェクトデータの読み込み、整理、分析、出力を扱い、機密データ向けのローカル LLM の選択肢も紹介します。

主な機能

  1. 01プロンプトから Python と Pandas コードを生成
  2. 02Excel、CSV、PDF データを処理
  3. 03BIM 要素、コスト、スケジュールを分析
  4. 04Ollama でローカル LLM を利用
  5. 05生成コードの検証方法を案内

活用シーン

  1. 01PDF の表を DataFrame に抽出
  2. 02BIM 要素のエクスポートデータを分析
  3. 03数量と単価から見積もりを算出
  4. 04スケジュールデータの遅延を特定

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/datadrivenconstruction/ddc_skills_for_ai_agents_in_construction --skill llm-data-automation

インストール後、Claude Code で/llm-data-automationを入力して読み込まれたか確認します。

同梱ファイルclaw.jsoninstructions.md

詳細

建設分野の LLM データ自動化

概要

DDC の方法論(第 2.3 章)に基づき、このスキルでは大規模言語モデル(LLM)を使った建設データ処理の自動化を実現します。データ変換を手作業でコーディングする代わりに、必要な処理を自然言語で説明すると、LLM が必要な Python/Pandas コードを生成します。

書籍の参考情報: 「Pandas DataFrame и LLM ChatGPT」/「Pandas DataFrame and LLM ChatGPT」

「ChatGPT や LLaMA などの LLM モデルを使えば、プログラミングの深い知識がない専門家も、企業のビジネスプロセスの自動化と改善に貢献できます。」 — DDC 書籍、第 2.3 章

クイックスタート

オプション 1:ChatGPT/Claude をオンラインで使用する

データ処理タスクを自然言語で説明するだけです。

Prompt: "Write Python code to read an Excel file with construction materials,
filter rows where quantity > 100, and save to CSV."
オプション 2:ローカル LLM を実行する(Ollama)
# Install Ollama from ollama.com
ollama pull mistral

# Run a query
ollama run mistral "Write Pandas code to calculate total cost from quantity * unit_price"
オプション 3:LM Studio を使用する(GUI)
  1. lmstudio.ai からダウンロードします
  2. インストールしてモデルを選択します(例:Mistral、LLaMA)
  3. ローカル AI とのチャットを開始します

基本概念

汎用フォーマットとしての DataFrame
import pandas as pd

# Construction project as DataFrame
# Rows = elements, Columns = attributes
df = pd.DataFrame({
    'element_id': ['W001', 'W002', 'C001'],
    'category': ['Wall', 'Wall', 'Column'],
    'material': ['Concrete', 'Brick', 'Steel'],
    'volume_m3': [45.5, 32.0, 8.2],
    'cost_per_m3': [150, 80, 450]
})

# Calculate total cost
df['total_cost'] = df['volume_m3'] * df['cost_per_m3']
print(df)
建設タスク向けの LLM プロンプト

データのインポート:

"Write code to import Excel file with construction schedule,
parse dates, and create a Pandas DataFrame"

データのフィルタリング:

"Filter construction elements where category is 'Structural'
and cost exceeds budget limit of 50000"

データの集計:

"Group construction data by floor level,
calculate total volume and cost for each floor"

レポートの生成:

"Create summary report with material quantities grouped by category,
export to Excel with formatting"

よくあるユースケース

1. PDF ドキュメントからデータを抽出する
# Prompt to ChatGPT:
# "Write code to extract tables from PDF and convert to DataFrame"

import pdfplumber
import pandas as pd

def pdf_to_dataframe(pdf_path):
    """Extract tables from PDF file"""
    all_tables = []
    with pdfplumber.open(pdf_path) as pdf:
        for page in pdf.pages:
            tables = page.extract_tables()
            for table in tables:
                if table:
                    df = pd.DataFrame(table[1:], columns=table[0])
                    all_tables.append(df)

    if all_tables:
        return pd.concat(all_tables, ignore_index=True)
    return pd.DataFrame()

# Usage
df = pdf_to_dataframe("construction_spec.pdf")
df.to_excel("extracted_data.xlsx", index=False)
2. BIM 要素データを処理する
# Prompt: "Analyze BIM elements, group by category, calculate volumes"

import pandas as pd

def analyze_bim_elements(csv_path):
    """Analyze BIM element data from CSV export"""
    df = pd.read_csv(csv_path)

    # Group by category
    summary = df.groupby('Category').agg({
        'Volume': 'sum',
        'Area': 'sum',
        'ElementId': 'count'
    }).rename(columns={'ElementId': 'Count'})

    return summary

# Usage
summary = analyze_bim_elements("revit_export.csv")
print(summary)
3. コスト見積もりのパイプライン
# Prompt: "Create cost estimation from quantities and unit prices"

import pandas as pd

def calculate_cost_estimate(quantities_df, prices_df):
    """
    Calculate project cost estimate

    Args:
        quantities_df: DataFrame with columns [item_code, quantity]
        prices_df: DataFrame with columns [item_code, unit_price, unit]

    Returns:
        DataFrame with cost calculations
    """
    # Merge quantities with prices
    result = quantities_df.merge(prices_df, on='item_code', how='left')

    # Calculate costs
    result['total_cost'] = result['quantity'] * result['unit_price']

    # Add summary
    result['cost_percentage'] = (result['total_cost'] /
                                  result['total_cost'].sum() * 100).round(2)

    return result

# Usage
quantities = pd.DataFrame({
    'item_code': ['C001', 'S001', 'W001'],
    'quantity': [150, 2000, 500]
})

prices = pd.DataFrame({
    'item_code': ['C001', 'S001', 'W001'],
    'unit_price': [120, 45, 85],
    'unit': ['m3', 'kg', 'm2']
})

estimate = calculate_cost_estimate(quantities, prices)
print(estimate)
4. スケジュールデータを処理する
# Prompt: "Parse construction schedule, calculate durations, identify delays"

import pandas as pd
from datetime import datetime

def analyze_schedule(schedule_path):
    """Analyze construction schedule for delays"""
    df = pd.read_excel(schedule_path)

    # Parse dates
    df['start_date'] = pd.to_datetime(df['start_date'])
    df['end_date'] = pd.to_datetime(df['end_date'])
    df['actual_end'] = pd.to_datetime(df['actual_end'])

    # Calculate durations
    df['planned_duration'] = (df['end_date'] - df['start_date']).dt.days
    df['actual_duration'] = (df['actual_end'] - df['start_date']).dt.days

    # Identify delays
    df['delay_days'] = df['actual_duration'] - df['planned_duration']
    df['is_delayed'] = df['delay_days'] > 0

    return df

# Usage
schedule = analyze_schedule("project_schedule.xlsx")
delayed_tasks = schedule[schedule['is_delayed']]
print(f"Delayed tasks: {len(delayed_tasks)}")

ローカル LLM のセットアップ(インターネット接続不要)

Ollama を使用する
# Install
curl -fsSL https://ollama.com/install.sh | sh

# Download models
ollama pull mistral      # General purpose, 7B params
ollama pull codellama    # Code-focused
ollama pull deepseek-coder  # Best for coding tasks

# Run
ollama run mistral "Write Pandas code to merge two DataFrames on project_id"
LlamaIndex を使用して社内ドキュメントを扱う
# Load company documents into local LLM
from llama_index import SimpleDirectoryReader, VectorStoreIndex

# Read all PDFs from folder
reader = SimpleDirectoryReader("company_documents/")
documents = reader.load_data()

# Create searchable index
index = VectorStoreIndex.from_documents(documents)

# Query your documents
query_engine = index.as_query_engine()
response = query_engine.query(
    "What are the standard concrete mix specifications?"
)
print(response)

IDE の推奨

IDE最適な用途機能
Jupyter Notebook学習、実験インタラクティブなセル、可視化
Google Colab無料の GPU、クイックスタートクラウドベース、ライブラリのプリインストール
VS Codeプロフェッショナルな開発拡張機能、GitHub Copilot
PyCharm大規模プロジェクト高度なデバッグ、リファクタリング
Jupyter のクイックセットアップ
pip install jupyter pandas openpyxl pdfplumber
jupyter notebook

ベストプラクティス

  1. シンプルに始める:明確で具体的なプロンプトから始めます
  2. 反復する:結果に基づいてプロンプトを改善します
  3. 検証する:実行前に必ず生成されたコードを確認します
  4. 文書化する:再利用できるよう、うまく機能したプロンプトを保存します
  5. セキュリティを確保する:機密性の高い社内データにはローカル LLM を使用します

よく使うプロンプト集

データのインポート
  • 「Excel ファイルを読み込み、最初の 10 行を表示する」
  • 「カスタム区切り文字とエンコーディングで CSV をインポートする」
  • 「複数の Excel シートを DataFrame の辞書に読み込む」
データのクリーニング
  • 「element_id に基づいて重複行を削除する」
  • 「欠損値を列の平均値で埋める」
  • 「エラーを処理しながら列を数値型に変換する」
データ分析
  • 「数値列の記述統計量を計算する」
  • 「コストと期間の相関を調べる」
  • 「IQR 法を使って外れ値を特定する」
データのエクスポート
  • 「複数のシートを含む Excel にエクスポートする」
  • 「指定したエンコーディングで CSV に保存する」
  • 「書式設定済みの PDF レポートを生成する」

リソース

次のステップ

  • 高度な Pandas 操作については pandas-construction-analysis を参照してください
  • ドキュメント処理については pdf-to-structured を参照してください
  • データパイプラインの自動化については etl-pipeline を参照してください
  • 建設ドキュメントを使った RAG の実装については rag-construction を参照してください

コメント