{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# Random Frog - Basic example\n\nA Random Frog example showing the feature importance for a synthetic regression task.\n\nThe example uses a synthetic dataset with 10 standard normally distributed features.\nThe target values only depend on two features: #0 and #5.\nIf the Random Frog method is tasked with selecting two features, it identifies the two important features as shown below.\n\nNote, that we use 1000 iterations to decrease the runtime in this case.\nA small number of iterations likely results in unstable selections if no fixed random seed is given.\nWe recommend to use the default 10000 iterations when using the Random Frog method.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "import matplotlib.pyplot as plt\nimport numpy as np\n\nfrom auswahl import RandomFrog\n\nnp.random.seed(1337)\nX = np.random.randn(100, 10)\ny = 5 * X[:, 0] - 2 * X[:, 5]\n\nn_iterations = 1000\nrf = RandomFrog(n_features_to_select=2, n_iterations=n_iterations, n_jobs=5, random_state=7331)\nrf.fit(X, y)\n\ncolors = np.full(X.shape[1], fill_value='C00')\ncolors[rf.get_support()] = 'C01'\n\nplt.bar(x=np.arange(X.shape[1]), height=rf.frequencies_ / n_iterations, color=colors)\n\nplt.xlabel('Feature')\nplt.ylabel('Relative Frequency')\n\nplt.show()"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8.13"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}