> ## Documentation Index
> Fetch the complete documentation index at: https://systematica.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyzer

> systematica.tuners.sqlite.analyzer

## `SQLiteOptunaAnalyzer`

```python theme={null}
SQLiteOptunaAnalyzer(
    project: str,
    api_token: str = None,
    init_kwargs: Dict[str, Any] = _Nothing.NOTHING,
)
```

SQLite-based optimization result analyzer.

Queries Optuna's native SQLite tables to fetch and analyze optimization results.
No custom tables - all data retrieved directly from Optuna's schema.

Method generated by attrs for class SQLiteOptunaAnalyzer.

### Ancestors

* `systematica.tuners.base.BaseOptunaAnalyzer`
* `systematica.tuners.base.BaseAnalyzer`
* `abc.ABC`

### Static methods

#### `from_storage_url`

```python theme={null}
from_storage_url(
    storage_url: str = 'sqlite:////Users/jmr/GitHub/systematica/sma_sqlite_optuna.db',
    **init_kwargs: Dict[str, Any],
) ‑> systematica.tuners.sqlite.analyzer.SQLiteOptunaAnalyzer
```

Create analyzer instance from storage URL.

**Parameters**:

| Name          | Type        | Default               | Description                       |
| ------------- | ----------- | --------------------- | --------------------------------- |
| `storage_url` | `str`       | `DEFAULT_STORAGE_URL` | SQLite storage URL.               |
| `init_kwargs` | `tp.Kwargs` | `--`                  | Additional initialization kwargs. |

**Returns**:

| Type                   | Description                    |
| ---------------------- | ------------------------------ |
| `SQLiteOptunaAnalyzer` | Initialized analyzer instance. |

### Instance variables

* `init_kwargs: Dict[str, Any]`: Initialization kwargs for storage configuration.

* `storage_url: str`: SQLite storage URL.

### Methods

#### `run_context`

```python theme={null}
run_context(
    self,
    **kwargs,
)
```

Context manager for consistency with base class API.

**Parameters**:

| Name     | Type        | Default | Description                    |
| -------- | ----------- | ------- | ------------------------------ |
| `kwargs` | `tp.Kwargs` | `--`    | Additional arguments (unused). |

**Yields**:

| Type   | Description                                                         |
| ------ | ------------------------------------------------------------------- |
| `None` | No session needed - Optuna handles database connections internally. |

#### `fetch_trials`

```python theme={null}
fetch_trials(
    self,
    metadata_tag: str,
    run_ids: Tuple[str],
    is_trials: bool,
    is_file: bool = False,
    mode: str = 'read-only',
) ‑> pandas.core.frame.DataFrame
```

Fetch optimization data from Optuna's native tables.

**Parameters**:

| Name           | Type    | Default       | Description                                                                                                                                                                             |
| -------------- | ------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `metadata_tag` | `str`   | `--`          | Data type to fetch: - 'best/params': Best trial parameters - 'best/values': Best trial metric values - 'study/distributions': Parameter distributions - 'trials/trials': All trial data |
| `run_ids`      | `tuple` | `--`          | of str Study names to fetch.                                                                                                                                                            |
| `is_trials`    | `bool`  | `--`          | Whether fetching trial-level data (True) or study-level data (False).                                                                                                                   |
| `is_file`      | `bool`  | `False`       | Unused, for API compatibility.                                                                                                                                                          |
| `mode`         | `str`   | `"read-only"` | Unused, for API compatibility with base class.                                                                                                                                          |

**Returns**:

| Type           | Description                  |
| -------------- | ---------------------------- |
| `pd.DataFrame` | DataFrame with fetched data. |

#### `fetch_feature_config`

```python theme={null}
fetch_feature_config(
    self,
    session,
    run_id: str,
) ‑> Dict[str, Any]
```

Fetch feature\_config from Optuna's study\_user\_attributes.

**Parameters**:

| Name      | Type  | Default | Description                                         |
| --------- | ----- | ------- | --------------------------------------------------- |
| `session` | `Any` | `--`    | Unused, kept for API compatibility with base class. |
| `run_id`  | `str` | `--`    | Study name.                                         |

**Returns**:

| Type   | Description                       |
| ------ | --------------------------------- |
| `dict` | Feature configuration dictionary. |

**Raises**:

| Type               | Description                                       |
| ------------------ | ------------------------------------------------- |
| `SystematicaError` | If feature\_config not found in study attributes. |

#### `fetch_optuna_study`

```python theme={null}
fetch_optuna_study(
    self,
    run_id: str,
) ‑> optuna.study.study.Study
```

Load Optuna study from SQLite storage.

**Parameters**:

| Name     | Type  | Default | Description |
| -------- | ----- | ------- | ----------- |
| `run_id` | `str` | `--`    | Study name. |

**Returns**:

| Type           | Description                                                 |
| -------------- | ----------------------------------------------------------- |
| `optuna.Study` | Loaded Optuna study object with all user attributes intact. |
