File size: 637 Bytes
b4fadea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#Load Production data from SQLite

import sqlite3
import json
import pandas as pd
from app.core.config import DB_PATH


def load_production_data(limit: int = 1000) -> pd.DataFrame:
    conn = sqlite3.connect(DB_PATH)
    cursor = conn.cursor()

    cursor.execute(
        """
        SELECT input_features
        FROM predictions
        ORDER BY id DESC
        LIMIT ?
        """,
        (limit,)
    )

    rows = cursor.fetchall()
    conn.close()

    if not rows:
        raise ValueError("No production data available for drift detection.")

    records = [json.loads(row[0]) for row in rows]
    return pd.DataFrame(records)