{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Dataset Column Filters when Running Tests\n",
    "\n",
    "To run a test on a dataset but only include certain columns from that dataset, you can use the new `columns` option. This is done by passing a dictionary for the `dataset` input for the test instead of the dataset object or dataset input ID directly. This dictionary should have the following keys:\n",
    "\n",
    "- `input_id`: The dataset input ID for the dataset you want to use\n",
    "- `columns`: A list of the column names from the original dataset to include in the dataset that will be used for the test\n",
    "\n",
    "This mechanism is intended to be general enough to support many other types of options that users may want to set on datasets or models that apply to a specific test or set of tests. These can be implemented in the `with_options()` method of the `VMDataset` or `VMModel` classes which gets called when the user passes the above described dictionary for the `dataset` or `model` input. The `with_options()` method should return a new instance of the class with the specified options set."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from validmind import init\n",
    "\n",
    "init()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "\n",
    "from validmind import init_dataset\n",
    "\n",
    "my_df = pd.DataFrame(\n",
    "    {\n",
    "        \"col1\": [1, 1, 3],\n",
    "        \"col2\": [4, 5, 6],\n",
    "        \"target\": [0, 1, 0],\n",
    "    }\n",
    ")\n",
    "\n",
    "my_dataset = init_dataset(my_df, target_column=\"target\", input_id=\"my_dataset\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from validmind.tests import run_test\n",
    "\n",
    "result = run_test(\n",
    "    test_id=\"validmind.data_validation.DatasetDescription\",\n",
    "    inputs={\"dataset\": {\"input_id\": \"my_dataset\", \"columns\": [\"col1\"]}},\n",
    ")\n",
    "\n",
    "# notice that only the column \"col1\" is shown in the test result"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "validmind-mI3jzOkk-py3.11",
   "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.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
