{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": { "collapsed": false }, "source": [ "# Basic Usage\n", "\n", "Here, we demonstrate how to filter conditions where we suspect the model to be undefined" ] }, { "cell_type": "code", "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-08-09T23:33:58.949255Z", "start_time": "2024-08-09T23:33:57.538974Z" } }, "source": [ "import math\n", "\n", "import numpy as np\n", "\n", "from autora.experimentalist.prediction_filter import prediction_filter\n", "import pandas as pd" ], "outputs": [], "execution_count": 1 }, { "cell_type": "markdown", "source": [ "Create a model:" ], "metadata": { "collapsed": false } }, { "cell_type": "code", "source": [ "class ModelWithNans:\n", " def predict(self, x):\n", " try:\n", " return math.sqrt((x**2 - 4))\n", " except:\n", " return None\n", "model = ModelWithNans()" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-08-09T23:34:00.789425Z", "start_time": "2024-08-09T23:34:00.787357Z" } }, "outputs": [], "execution_count": 2 }, { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "Let's create our pool:" ] }, { "cell_type": "code", "source": [ "pool = pd.DataFrame({'x': np.linspace(-5, 5, 11)})\n", "pool" ], "metadata": { "collapsed": false, "ExecuteTime": { "end_time": "2024-08-09T23:34:01.863883Z", "start_time": "2024-08-09T23:34:01.853300Z" } }, "outputs": [ { "data": { "text/plain": [ " x\n", "0 -5.0\n", "1 -4.0\n", "2 -3.0\n", "3 -2.0\n", "4 -1.0\n", "5 0.0\n", "6 1.0\n", "7 2.0\n", "8 3.0\n", "9 4.0\n", "10 5.0" ], "text/html": [ "
\n", " | x | \n", "
---|---|
0 | \n", "-5.0 | \n", "
1 | \n", "-4.0 | \n", "
2 | \n", "-3.0 | \n", "
3 | \n", "-2.0 | \n", "
4 | \n", "-1.0 | \n", "
5 | \n", "0.0 | \n", "
6 | \n", "1.0 | \n", "
7 | \n", "2.0 | \n", "
8 | \n", "3.0 | \n", "
9 | \n", "4.0 | \n", "
10 | \n", "5.0 | \n", "