{
  "cells": [
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "collapsed": false
      },
      "outputs": [],
      "source": [
        "%matplotlib inline"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\n# CARS - Basic example\n\nA Competetive Adaptive Reweighted Sampling example showing the feature importance defined as selection probability of\nmultiple CARS runs 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.\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 CARS\n\nnp.random.seed(1337)\nX = np.random.randn(10, 10)\ny = 5 * X[:, 0] - 2 * X[:, 5]\n\ncars = CARS(n_features_to_select=2)\ncars.fit(X, y)\n\ncolors = np.full(X.shape[1], fill_value='C00')\ncolors[cars.get_support()] = 'C01'\n\nplt.bar(x=np.arange(X.shape[1]), height=cars.feature_importance_, color=colors)\n\nplt.xlabel('Feature')\nplt.ylabel('CARS')\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
}