Installation‐Deployment - LostRuneCloud/AutoML GitHub Wiki

インストール・デプロイメント

注意: このソフトウェアは著作権により保護されています。All Rights Reserved. 技術評価・学習目的での閲覧は許可されていますが、複製・実行・改変・商用利用は禁止されています。詳細はLICENSEを参照してください。

システム要件

最小動作環境

OS: 
  - Linux (Ubuntu 18.04+, CentOS 7+)
  - Windows 10/11
  - macOS 10.15+

Hardware:
  CPU: 2コア以上 (x86_64)
  Memory: 4GB RAM
  Storage: 10GB 空き容量
  Network: インターネット接続(初期セットアップ時)

Software:
  Python: 3.8.0以上
  pip: 20.0以上

推奨本番環境

Hardware:
  CPU: 8コア以上 (Intel Xeon/AMD EPYC推奨)
  Memory: 32GB RAM以上
  Storage: 
    - システム: 100GB SSD
    - データ: 1TB以上 (用途に応じて)
    - ログ: 50GB
  GPU: NVIDIA GPU (CUDA 11.0+対応) - オプション

Network:
  - 内部通信: 1Gbps以上
  - 外部アクセス: 用途に応じて

Software:
  Container: Docker 20.10+ / Podman 3.0+
  Orchestration: Kubernetes 1.20+ (大規模環境)

依存関係

必須ライブラリ(Standard版)

# 基本的なデータ処理
numpy>=2.0.0
pandas>=2.2.0
scipy>=1.15.0

# 機械学習フレームワーク
scikit-learn>=1.6.0
joblib>=1.4.0

# 可視化
matplotlib>=3.10.0

# ユーティリティ
pyyaml>=6.0.0
tqdm>=4.65.0

Enhanced版追加ライブラリ

# 高度な機械学習アルゴリズム
xgboost>=3.0.0
lightgbm>=4.5.0

# ハイパーパラメータ最適化
optuna>=4.0.0
bayesian-optimization>=2.0.0

# 説明可能性・解釈性
shap>=0.47.0
eli5>=0.16.0

# 高度可視化
plotly>=6.0.0
seaborn>=0.13.0

# データ前処理
category_encoders>=2.8.0
imbalanced-learn>=0.13.0

Web機能・追加ライブラリ

# Webダッシュボード
flask>=3.0.0
flask-socketio>=5.5.0

# データフォーマット対応
openpyxl>=3.1.0
pyarrow>=20.0.0

# データプロファイリング
ydata-profiling>=4.15.0

# システム監視
psutil>=7.0.0

# その他
pillow>=10.0.0
requests>=2.30.0
colorlog>=6.8.0

開発・テストツール

# テストフレームワーク
pytest>=7.0.0
pytest-cov>=4.0.0

# コード品質
black>=20.8b1
isort>=5.0.0
flake8>=3.8.0

# ドキュメント生成
sphinx>=3.0.0
sphinx-rtd-theme>=0.5.0

インストール手順

1. 基本セットアップ

# 1. リポジトリクローン
git clone https://github.com/LostRuneCloud/AutoML.git
cd AutoML

# 2. 仮想環境作成・有効化
python -m venv venv
source venv/bin/activate  # Linux/macOS
# venv\Scripts\activate   # Windows

# 3. 依存関係インストール
pip install -r requirements.txt

# 4. システムセットアップ
python setup.py install

2. バージョン別インストール

Standard版のみ(軽量インストール)

# 基本ライブラリのみインストール
pip install numpy>=2.0.0 pandas>=2.2.0 scikit-learn>=1.6.0 \
            matplotlib>=3.10.0 joblib>=1.4.0 scipy>=1.15.0 \
            pyyaml>=6.0.0 tqdm>=4.65.0

# システムセットアップ
python setup.py install

Enhanced版(全機能)

# 全依存関係インストール
pip install -r requirements.txt

# または段階的インストール
pip install -e .                    # 基本ライブラリ
pip install -e .[viz]               # 可視化機能追加
pip install -e .[dev]               # 開発ツール追加

3. 設定ファイル初期化

# デフォルト設定ファイル生成(オプション)
python -c "
from automl_pipeline import AutoML
automl = AutoML()
print('AutoML初期化完了')
"

# 設定ファイル場所(自動生成される)
# Linux/macOS: ~/.automl/
# Windows: %USERPROFILE%\.automl\

4. 初期検証

# システム動作確認
python -c "
from automl_pipeline import AutoML
print('✓ AutoMLインポート成功')

try:
    from models.enhanced.auto_model_builder_enhanced import AutoModelBuilderEnhanced
    print('✓ Enhanced版利用可能')
except ImportError:
    print('⚠ Enhanced版不可 - Standard版で動作')

import pandas as pd
import numpy as np
data = pd.DataFrame({'x': [1,2,3,4,5], 'y': [2,4,6,8,10]})
automl = AutoML()
print('✓ 基本機能テスト完了')
"

Docker デプロイメント

Dockerfile

FROM python:3.9-slim

WORKDIR /app

# システム依存関係のインストール
RUN apt-get update && apt-get install -y \
    gcc g++ \
    build-essential \
    && rm -rf /var/lib/apt/lists/*

# Python依存関係のインストール
COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt

# アプリケーションコピー
COPY . .

# パッケージインストール
RUN python setup.py install

# ヘルスチェック
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s \
    CMD python -c "from automl_pipeline import AutoML; AutoML()" || exit 1

# 実行設定
EXPOSE 8080
ENV AUTOML_VERSION=enhanced
ENV AUTOML_LOG_LEVEL=INFO

# エントリーポイント
CMD ["python", "-c", "from automl_pipeline import AutoML; print('AutoML container ready')"]

Docker Compose(本番用)

version: '3.8'

services:
  automl:
    build: 
      context: .
      dockerfile: Dockerfile
    container_name: automl-service
    ports:
      - "8080:8080"
    volumes:
      - ./data:/app/data:ro
      - ./config:/app/config:ro
      - ./logs:/app/logs
      - ./models:/app/models
    environment:
      - AUTOML_CONFIG_PATH=/app/config
      - AUTOML_LOG_LEVEL=INFO
      - AUTOML_VERSION=enhanced
      - PYTHONPATH=/app
    restart: unless-stopped
    healthcheck:
      test: ["CMD", "python", "-c", "from automl_pipeline import AutoML; AutoML()"]
      interval: 30s
      timeout: 10s
      retries: 3
    deploy:
      resources:
        limits:
          memory: 16G
          cpus: '8'
        reservations:
          memory: 4G
          cpus: '2'

  redis:
    image: redis:7-alpine
    container_name: automl-redis
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    command: redis-server --appendonly yes
    restart: unless-stopped

  monitoring:
    image: prom/prometheus:latest
    container_name: automl-monitoring
    ports:
      - "9090:9090"
    volumes:
      - ./monitoring/prometheus.yml:/etc/prometheus/prometheus.yml:ro
    restart: unless-stopped

volumes:
  redis_data:

Kubernetes デプロイメント

デプロイメント設定

apiVersion: apps/v1
kind: Deployment
metadata:
  name: automl-service
  labels:
    app: automl
    version: v1.0.0
spec:
  replicas: 3
  selector:
    matchLabels:
      app: automl
  template:
    metadata:
      labels:
        app: automl
    spec:
      containers:
      - name: automl
        image: automl:latest
        ports:
        - containerPort: 8080
        resources:
          requests:
            memory: "4Gi"
            cpu: "2"
          limits:
            memory: "16Gi"
            cpu: "8"
        env:
        - name: AUTOML_VERSION
          value: "enhanced"
        - name: AUTOML_LOG_LEVEL
          value: "INFO"
        - name: PYTHONPATH
          value: "/app"
        volumeMounts:
        - name: config-volume
          mountPath: /app/config
          readOnly: true
        - name: data-volume
          mountPath: /app/data
          readOnly: true
        - name: models-volume
          mountPath: /app/models
        livenessProbe:
          exec:
            command:
            - python
            - -c
            - "from automl_pipeline import AutoML; AutoML()"
          initialDelaySeconds: 60
          periodSeconds: 30
        readinessProbe:
          exec:
            command:
            - python
            - -c
            - "from automl_pipeline import AutoML; print('Ready')"
          initialDelaySeconds: 30
          periodSeconds: 10
      volumes:
      - name: config-volume
        configMap:
          name: automl-config
      - name: data-volume
        persistentVolumeClaim:
          claimName: automl-data-pvc
      - name: models-volume
        persistentVolumeClaim:
          claimName: automl-models-pvc

サービス設定

apiVersion: v1
kind: Service
metadata:
  name: automl-service
  labels:
    app: automl
spec:
  selector:
    app: automl
  ports:
    - name: http
      protocol: TCP
      port: 80
      targetPort: 8080
  type: LoadBalancer

---
apiVersion: v1
kind: ConfigMap
metadata:
  name: automl-config
data:
  config.yaml: |
    automl:
      version: enhanced
      time_budget: 3600
      complexity_level: balanced
      resource_constraint: unlimited
      logging:
        level: INFO
        format: json

運用監視

システムメトリクス

# 監視対象メトリクス
system_metrics = {
    'cpu_usage': '< 80%',           # CPU使用率
    'memory_usage': '< 85%',        # メモリ使用率
    'disk_usage': '< 90%',          # ディスク使用率
    'response_time': '< 30s',       # 応答時間
    'throughput': '> 10 jobs/hour', # 処理スループット
    'error_rate': '< 1%',           # エラー発生率
    'model_accuracy': '> 0.8'       # モデル精度
}

ログ設定

# logging_config.yaml
version: 1
disable_existing_loggers: false

formatters:
  detailed:
    format: '[%(asctime)s] %(name)s.%(levelname)s: %(message)s'
    datefmt: '%Y-%m-%d %H:%M:%S'
  json:
    format: '{"timestamp": "%(asctime)s", "logger": "%(name)s", "level": "%(levelname)s", "message": "%(message)s"}'

handlers:
  console:
    class: logging.StreamHandler
    level: INFO
    formatter: detailed
    stream: ext://sys.stdout
    
  file:
    class: logging.handlers.RotatingFileHandler
    filename: logs/automl.log
    maxBytes: 10485760  # 10MB
    backupCount: 5
    level: DEBUG
    formatter: detailed
    encoding: utf-8
    
  error_file:
    class: logging.handlers.RotatingFileHandler
    filename: logs/automl_error.log
    maxBytes: 10485760
    backupCount: 5
    level: ERROR
    formatter: json
    encoding: utf-8

loggers:
  automl:
    level: DEBUG
    handlers: [console, file, error_file]
    propagate: false
    
  models:
    level: INFO
    handlers: [file]
    propagate: false
    
  preprocessing:
    level: INFO
    handlers: [file]
    propagate: false

root:
  level: WARNING
  handlers: [console]

バックアップ・リカバリ

バックアップ戦略

backup_strategy:
  models:
    frequency: "after_training"
    retention: "180 days"
    location: "/backup/models"
    versioning: true
    compression: true
    
  configuration:
    frequency: "daily"
    retention: "30 days"
    location: "/backup/config"
    
  logs:
    frequency: "weekly"
    retention: "365 days"
    location: "/backup/logs"
    compression: true
    
  knowledge_base:
    frequency: "daily"
    retention: "90 days"
    location: "/backup/knowledge"
    incremental: true

リカバリ手順

# 完全システムリカバリスクリプト
#!/bin/bash

# 1. サービス停止
docker-compose down

# 2. バックアップからの復元
cp -r /backup/models/latest/* ./models/
cp -r /backup/config/latest/* ./config/

# 3. 権限設定
chown -R automl:automl ./models ./config

# 4. システム検証
python -c "
from automl_pipeline import AutoML
automl = AutoML()
print('✓ システム復旧確認完了')
"

# 5. サービス再開
docker-compose up -d

# 6. ヘルスチェック
sleep 30
curl -f http://localhost:8080/health || echo "⚠ ヘルスチェック失敗"

トラブルシューティング

よくある問題と解決方法

1. メモリ不足エラー

# 症状: Out of Memory エラー
# 原因: 大規模データセット処理時のメモリ不足

# 解決方法1: Standard版に切り替え
export AUTOML_VERSION=standard

# 解決方法2: メモリ制限設定
export AUTOML_MEMORY_LIMIT=4GB

# 解決方法3: 軽量設定使用
python -c "
from automl_pipeline import AutoML
automl = AutoML(config={'complexity_level': 'simple', 'resource_constraint': 'fast'})
"

2. 依存関係エラー

# 症状: ModuleNotFoundError: No module named 'optuna'
# 原因: Enhanced版の依存関係不足

# 解決方法1: 必要ライブラリのインストール
pip install optuna>=4.0.0 shap>=0.47.0 plotly>=6.0.0

# 解決方法2: Standard版で動作確認
python -c "
from automl_pipeline import AutoML
automl = AutoML(config={'complexity_level': 'simple'})
"

3. パフォーマンス低下

# 症状: 処理時間が著しく増加
# 原因: リソース競合、設定不適切

# 解決方法1: 並列度調整
export AUTOML_PARALLEL_WORKERS=4

# 解決方法2: 時間予算調整
python -c "
from automl_pipeline import AutoML
automl = AutoML(config={'time_budget': 300})  # 5分制限
"

4. データ読み込みエラー

# 症状: UnicodeDecodeError, FileNotFoundError
# 原因: ファイル形式、エンコーディング問題

# 解決方法: エンコーディング指定での再読み込み
python -c "
import pandas as pd
# 複数エンコーディングを自動試行(システムが自動実行)
data = pd.read_csv('data.csv')  # UTF-8, Shift_JIS, CP932を順次試行
"

セキュリティ設定

アクセス制御

access_control:
  authentication:
    methods: ["api_key", "oauth2"]
    session_timeout: "8 hours"
    max_failed_attempts: 3
    lockout_duration: "15 minutes"
    
  authorization:
    roles:
      admin:
        permissions: ["read", "write", "execute", "deploy", "manage"]
      data_scientist:
        permissions: ["read", "execute", "create_models"]
      viewer:
        permissions: ["read", "view_reports"]
        
  api_security:
    rate_limiting:
      requests_per_minute: 60
      burst_limit: 10
    request_validation: true
    response_sanitization: true

データ保護

data_protection:
  encryption:
    at_rest: 
      algorithm: "AES-256-GCM"
      key_rotation: "monthly"
    in_transit: 
      protocol: "TLS 1.3"
      certificate_validation: true
      
  privacy:
    data_anonymization: true
    pii_detection: true
    retention_policy: "2 years"
    
  audit_logging:
    enabled: true
    retention: "5 years"
    tamper_protection: true
    real_time_monitoring: true

スケーリング設定

水平スケーリング

# Kubernetes自動スケーリング
kubectl autoscale deployment automl-service \
  --cpu-percent=70 \
  --memory-percent=80 \
  --min=2 \
  --max=10

# Docker Swarmスケーリング
docker service scale automl-service=5

パフォーマンス最適化

設定項目 小規模環境 大規模環境
CPU制限 2コア 8+コア
メモリ制限 4GB 32GB+
並列ワーカー 2 8
時間予算 300秒 3600秒
複雑度レベル simple advanced

開発: Claude Desktop + Claude Code による AI駆動開発(2025年3月〜継続中)
ライセンス: All Rights Reserved - 技術評価・学習目的での閲覧のみ許可