{ "cells": [ { "cell_type": "markdown", "id": "a7e1ece6", "metadata": {}, "source": [ "# Analysing Samples" ] }, { "cell_type": "markdown", "id": "4d09269b", "metadata": {}, "source": [ "{nb-download}`Download this as a Jupyter notebook `" ] }, { "cell_type": "markdown", "id": "b253a871", "metadata": {}, "source": [ "This guide covers how to use `pyXla` to conduct landscape analysis." ] }, { "cell_type": "markdown", "id": "79bc3162", "metadata": {}, "source": [ "The first step is to load a sample:" ] }, { "cell_type": "code", "execution_count": null, "id": "b51d9fa4", "metadata": {}, "outputs": [], "source": [ "from pyxla.sampling import HilbertCurveSampler\n", "from pyxla import load_data" ] }, { "cell_type": "code", "execution_count": null, "id": "995acb9d", "metadata": {}, "outputs": [], "source": [ "sampler = HilbertCurveSampler(\n", " sample_size=100, dim=2, return_neighbourhood=True\n", ")\n", "\n", "sample = {\n", " \"X\": sampler,\n", " \"F\": lambda x: (x**2).sum(),\n", " \"V\": lambda x: ((x**2).sum() - 3),\n", " \"D\": lambda x1, x2: ((x1 - x2)**2).sum(), #must take a pair of arguments and real number\n", " # N file is provided by the sampler since return_neighbourhood=True\n", "}\n", "\n", "load_data(sample)" ] }, { "cell_type": "markdown", "id": "dddb7a49", "metadata": {}, "source": [ "The next step, is to import the explainable landscape analysis (xLA) feature of choice. For instance we import the `distr_f` (distribution of objective values) below:" ] }, { "cell_type": "code", "execution_count": null, "id": "d73cceaf", "metadata": {}, "outputs": [], "source": [ "from pyxla import distr_f" ] }, { "cell_type": "markdown", "id": "94e637b4", "metadata": {}, "source": [ "Lastly, invoke the imported feature." ] }, { "cell_type": "code", "execution_count": null, "id": "8804c8b1", "metadata": {}, "outputs": [], "source": [ "feat, plot = distr_f(sample)" ] }, { "cell_type": "markdown", "id": "dc5be4ba", "metadata": {}, "source": [ "Each xLA feature in `pyXla` produces as output both visual and numerical outputs. For most features these outputs are returned as a pair." ] }, { "cell_type": "markdown", "id": "434a8458", "metadata": {}, "source": [ "The numerical output is the first item in the pair:" ] }, { "cell_type": "code", "execution_count": null, "id": "1164940f", "metadata": {}, "outputs": [], "source": [ "feat" ] }, { "cell_type": "markdown", "id": "68659247", "metadata": {}, "source": [ "The visual output is the second item in the pair:" ] }, { "cell_type": "code", "execution_count": null, "id": "ce2099f6", "metadata": {}, "outputs": [], "source": [ "plot" ] }, { "cell_type": "markdown", "id": "ee6e5dfb", "metadata": {}, "source": [ "For a complete reference of all the xLA features implemented in `pyXla` see the {doc}`API reference <../api-reference/pyxla>`." ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }