> ## 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.neptune_ai.analyzer

## `NeptuneOptunaAnalyzer`

```python theme={null}
NeptuneOptunaAnalyzer(
    project: str,
    api_token: str = None,
)
```

Neptune runs and fetching experiment data analyzer.

Method generated by attrs for class NeptuneOptunaAnalyzer.

### Ancestors

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

### Methods

#### `run_context`

```python theme={null}
run_context(
    self,
    **kwargs,
) ‑> neptune.metadata_containers.run.Run
```

Context manager to initialize and stop a Neptune run.

**Parameters**:

| Name     | Type        | Default | Description                                                                   |
| -------- | ----------- | ------- | ----------------------------------------------------------------------------- |
| `kwargs` | `tp.Kwargs` | `--`    | Additional arguments to pass to `neptune.init_run` (e.g., `with_id`, `mode`). |

**Yields**:

| Type          | Description                         |
| ------------- | ----------------------------------- |
| `neptune.Run` | The initialized Neptune run object. |

#### `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 metadata from Neptune runs and return as a DataFrame.

**Parameters**:

| Name           | Type            | Default     | Description                                                                                                      |
| -------------- | --------------- | ----------- | ---------------------------------------------------------------------------------------------------------------- |
| `metadata_tag` | `str`           | `--`        | The metadata field to fetch (e.g., 'best/values', 'trials/trials').                                              |
| `run_ids`      | `tp.Tuple[str]` | `--`        | The ID(s) of the Neptune run(s) to fetch.                                                                        |
| `is_trials`    | `bool`          | `--`        | Whether the metadata represents trials (True) or other data (False).                                             |
| `is_file`      | `bool`          | `True`      | Flag to fetch compressed file trials if True. Use namespace `fetch()` otherwise. Defaults to True.               |
| `mode`         | `str`           | `read-only` | Connection mode for Neptune. Options: 'async', 'sync', 'offline', 'read-only', 'debug'. Defaults to 'read-only'. |

**Returns**:

| Type           | Description                                |
| -------------- | ------------------------------------------ |
| `pd.DataFrame` | DataFrame containing the fetched metadata. |

#### `fetch_feature_config`

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

Fetch feature config from Neptune.

**Parameters**:

| Name     | Type          | Default | Description                         |
| -------- | ------------- | ------- | ----------------------------------- |
| `run`    | `neptune.Run` | `--`    | Neptune run.                        |
| `run_id` | `str`         | `--`    | The ID of the Neptune run to fetch. |

**Raises**:

| Type               | Description                    |
| ------------------ | ------------------------------ |
| `SystematicaError` | No metadata found for run\_id. |

**Returns**:

| Type        | Description      |
| ----------- | ---------------- |
| `tp.Kwargs` | metadata params. |

#### `get_all_trials`

```python theme={null}
get_all_trials(
    self,
    run_ids: str | List[str],
    is_file: bool = True,
) ‑> pandas.core.frame.DataFrame
```

Fetch all trials from Neptune runs.

**Parameters**:

| Name      | Type   | Default | Description                                                                                                                          |
| --------- | ------ | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `run_ids` | `str`  | `--`    | The ID(s) of the Neptune run(s) to fetch.                                                                                            |
| `is_file` | `bool` | `True`  | Flag to fetch compressed file trials through 'trials/compressed\_trials' if True. Fetch 'trials/trials' otherwise. Defaults to True. |

**Returns**:

| Type           | Description                                       |
| -------------- | ------------------------------------------------- |
| `pd.DataFrame` | All trial data, including 'run\_id' and 'number'. |

#### `fetch_optuna_study`

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

Loads Optuna study from an existing Neptune run.

Loading mechanics depend on the study storage type used during the run:

* If the study used `InMemoryStorage`, it will be loaded from the
  logged pickled study object.
* If the study used database storage, it will be loaded from the logged
  database URL.

To resume an existing run, you need the run ID. It is stored in the
run's `sys/id` field.

**Parameters**:

| Name     | Type  | Default | Description                         |
| -------- | ----- | ------- | ----------------------------------- |
| `run_id` | `str` | `--`    | The ID of the Neptune run to fetch. |

**Returns**:

| Type           | Description              |
| -------------- | ------------------------ |
| `optuna.Study` | The Optuna study object. |
