diff --git a/topic/multi-model/README.md b/topic/multi-model/README.md new file mode 100644 index 00000000..4ec3a818 --- /dev/null +++ b/topic/multi-model/README.md @@ -0,0 +1,9 @@ +# CrateDB UK Offshore Wind Farms Data Workshop + +This workshop explores multi-model data modeling and queries with [CrateDB](https://cratedb.com), using data from [The Crown Estate](https://www.thecrownestate.co.uk/our-business/marine/offshore-wind) which manages the UK's offshore wind farms. It is derived from a conference presentation that you can [watch on YouTube](https://www.youtube.com/watch?v=xqiLGjaTlBk). + +Use the Jupyter notebook to run the queries from the talk yourself, in your own CrateDB cluster in the cloud... click the button below to try it out in Google Colab! + + + Open In Colab + \ No newline at end of file diff --git a/topic/multi-model/multi-model-offshore-wind-farms-query.png b/topic/multi-model/multi-model-offshore-wind-farms-query.png new file mode 100644 index 00000000..711e5d17 Binary files /dev/null and b/topic/multi-model/multi-model-offshore-wind-farms-query.png differ diff --git a/topic/multi-model/multi-model-offshore-wind-farms.ipynb b/topic/multi-model/multi-model-offshore-wind-farms.ipynb new file mode 100644 index 00000000..13ebd877 --- /dev/null +++ b/topic/multi-model/multi-model-offshore-wind-farms.ipynb @@ -0,0 +1,1110 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# CrateDB UK Offshore Wind Farms Data Workshop\n", + "\n", + "![Turbines forming part of a wind farm near the UK coastline.](multi-model-offshore-wind-farms.jpg \"A wind farm near the UK coastline.\")\n", + "\n", + "This workshop explores multi-model data modeling and queries with [CrateDB](https://cratedb.com), using data from [The Crown Estate](https://www.thecrownestate.co.uk/our-business/marine/offshore-wind) which manages the UK's offshore wind farms. It is derived from a conference presentation that you can [watch on YouTube](https://www.youtube.com/watch?v=xqiLGjaTlBk).\n", + "\n", + "You'll work with tables containing data for:\n", + "\n", + "* **Wind Farms**. Details of the UK's 45 offshore wind farms are loaded into a CrateDB table from the supplied JSONL file. Each record includes an ID for the wind farm as well as a name, description and geospatial data in [WKT format](https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry) that describes the shape of the wind farm as one or more polygons. The co-ordinates of each turbine are also included, where known.\n", + "\n", + "* **Hourly Wind Farm Performance Data**. This table contains time-series data pertaining to the power output of each wind farm on an hourly basis for the period 19th August 2024 to 28th October 2024. The data is supplied as a compressed JSONL file.\n", + "\n", + "## Install Dependencies\n", + "\n", + "First, install the required dependencies by executing the `pip install` command below." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "! pip install -U ipyleaflet sqlalchemy-cratedb pandas" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Connect to CrateDB\n", + "\n", + "Before going any further, you'll need to update the code below to include a connection string for your CrateDB cluster. If you prefer, you can set the environment variable `CRATEDB_CONNECTION_STRING` instead.\n", + "\n", + "The code below assumes that you're using a managed CrateDB Cloud database cluster. [Sign up here](https://console.cratedb.cloud/) to create a free cluster.\n", + "\n", + "Alternatively, if you are running CrateDB locally (for example with [Docker](https://hub.docker.com/_/crate)), use the `localhost` code block to establish a database connection instead." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import sqlalchemy as sa\n", + "\n", + "# Define database address when using CrateDB Cloud.\n", + "# Please find these settings on your cluster overview page.\n", + "CONNECTION_STRING = os.environ.get(\n", + " \"CRATEDB_CONNECTION_STRING\",\n", + " \"crate://:@/?ssl=true\"\n", + ")\n", + "\n", + "# # Define database address when using CrateDB on localhost.\n", + "# CONNECTION_STRING = os.environ.get(\n", + "# \"CRATEDB_CONNECTION_STRING\",\n", + "# \"crate://crate@localhost/\"\n", + "# )\n", + "\n", + "# Connect to CrateDB using SQLAlchemy.\n", + "engine = sa.create_engine(\n", + " CONNECTION_STRING, \n", + " echo=sa.util.asbool(os.environ.get(\"DEBUG\", \"false\")))\n", + "connection = engine.connect()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Create Tables\n", + "\n", + "Next, we'll create two tables as follows:\n", + "\n", + "* `windfarms`: Contains data about each wind farm, including geospatial data, the nunber, type and location of each turbine, and a free-text description providing an overview of the wind farm and its history. There's also a vector embedding representation of this textual data which was created using the OpenAI `text-embedding-3-large` model.\n", + "\n", + "* `windfarm_output`: Hourly records for each wind farm containing details of the actual output for that hour and the percentage of the maximum output that the wind farm was operating at.\n", + "\n", + "Run the code below to create them, taking a moment to understand the table schemas." + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [], + "source": [ + "# Drop any previous version of the tables.\n", + "_ = connection.execute(sa.text(\"DROP TABLE IF EXISTS windfarms\"))\n", + "_ = connection.execute(sa.text(\"DROP TABLE IF EXISTS windfarm_output\"))\n", + "\n", + "# Create the tables.\n", + "\n", + "_= connection.execute(sa.text(\n", + "\"\"\"\n", + " CREATE TABLE windfarms (\n", + " id TEXT PRIMARY KEY,\n", + " name TEXT,\n", + " description TEXT INDEX USING fulltext WITH (analyzer='english'),\n", + " description_vec FLOAT_VECTOR(2048),\n", + " location GEO_POINT,\n", + " territory TEXT,\n", + " boundaries GEO_SHAPE INDEX USING geohash WITH (PRECISION='1m', DISTANCE_ERROR_PCT=0.025),\n", + " turbines OBJECT(STRICT) AS (\n", + " brand TEXT,\n", + " model TEXT,\n", + " locations ARRAY(GEO_POINT),\n", + " howmany SMALLINT\n", + " ),\n", + " capacity DOUBLE PRECISION,\n", + " url TEXT\n", + " );\n", + "\"\"\" \n", + "))\n", + "\n", + "_= connection.execute(sa.text(\n", + "\"\"\"\n", + " CREATE TABLE windfarm_output (\n", + " windfarmid TEXT,\n", + " ts TIMESTAMP WITHOUT TIME ZONE,\n", + " month GENERATED ALWAYS AS date_trunc('month', ts),\n", + " day TIMESTAMP WITH TIME ZONE GENERATED ALWAYS AS date_trunc('day', ts),\n", + " output DOUBLE PRECISION,\n", + " outputpercentage DOUBLE PRECISION\n", + " ) PARTITIONED BY (day);\n", + "\"\"\" \n", + "))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's take a quick look at the schema of these tables, beginning with `windfarms`.\n", + "\n", + "Here, we're using a `TEXT` column named `description` for the wind farm description data, and indexing that for full text search. The vector representation of this data is stored in its own column named `description_vec` which uses CrateDB's [`FLOAT_VECTOR`](https://cratedb.com/docs/crate/reference/en/latest/general/ddl/data-types.html#float-vector) type. \n", + "\n", + "There are two columns used to store geospatial data. `location` is a `GEO_POINT`, storing a single latitude/longitude position representing the location of the wind farm. `boundaries` is a `GEO_SHAPE` column that stores the GeoJSON representation of the overall shape of the wind farm's boundaries.\n", + "\n", + "CrateDB supports nested object columns in tables and these can have dynamic schemas. In this case, we already know what the schema for our `turbines` object looks like, so we specify it when creating the table. Note that object columns can contain other \"container\" data types - in this case we have an array for the geospatial data about the location of each turbine in the wind farm.\n", + "\n", + "Moving on to the `windfarm_output` table... this data is more of a time series, and the table schema for it reflects this. Data is received hourly from each wind farm, and is stored against the ID of the wind farm and a timestamp. To help with aggregations and managing rolling data windows, we have CrateDB generate a couple of extra columns for values that aren't in the source data: `month` and `day`. We also partition the table by day to assist with managing the data and speed up aggregations. Read more about CrateDB's table partitioning strategies [here](https://cratedb.com/docs/crate/reference/en/latest/general/ddl/partitioned-tables.html)." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Loading the Data\n", + "\n", + "We'll load the data from files contained in the [`cratedb-datasets` public GitHub repository](https://github.com/crate/cratedb-datasets/). There's one JSONL file for each table. The file containing the hourly output data has been compressed.\n", + "\n", + "The code that follows populates each table in turn, using `COPY FROM` statements." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def display_results(table_name, info):\n", + " print(f\"{table_name}: loaded {info['success_count']}, errors: {info['error_count']}\")\n", + "\n", + " if info[\"error_count\"] > 0:\n", + " print(f\"Errors: {info['errors']}\")\n", + "\n", + "\n", + "# Load the wind farm data.\n", + "result = connection.execute(sa.text(\"\"\"\n", + " COPY windfarms \n", + " \n", + " FROM 'https://github.com/crate/cratedb-datasets/raw/main/devrel/uk-offshore-wind-farm-data/wind_farms.json'\n", + " RETURN SUMMARY;\n", + "\"\"\"))\n", + "\n", + "display_results(\"windfarms\", result.mappings().first())" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Load the wind farm output data.\n", + "result = connection.execute(sa.text(\"\"\"\n", + " COPY windfarm_output\n", + " FROM 'https://github.com/crate/cratedb-datasets/raw/main/devrel/uk-offshore-wind-farm-data/wind_farm_output.json.gz' \n", + " WITH (compression='gzip')\n", + " RETURN SUMMARY;\n", + "\"\"\"))\n", + "\n", + "display_results(\"windfarm_data\", result.mappings().first())" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Once the data's located, verify that the output shows 0 errors for each table. Next, we'll run `REFRESH` and `ANALYZE` commands to make sure that the data's ready for immediate querying. This isn't normally necessary as CrateDB will perform these tasks automatically in the background. We're invoking them manually here to ensure that everyone in the workshop is on the same page at the same time." + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [], + "source": [ + "_ = connection.execute(sa.text(\"REFRESH TABLE windfarms, windfarm_output\"))\n", + "_ = connection.execute(sa.text(\"ANALYZE\"))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Querying the Data \n", + "\n", + "The queries that follow replicate those shown in the [conference talk](https://www.youtube.com/watch?v=xqiLGjaTlBk), in the order that they're demonstrated there.\n", + "\n", + "### Simple SQL Query\n", + "\n", + "Let's begin with a simple query that retrieves the timestamp, actual output and percentage of maximum output values for the North Hoyle (`NHOYW-1`) wind farm, for times where the output was at least 50% of its maximum capacity. We'll order these so that the most recent observations come first." + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
tsoutputoutputpercentage
0173009160000032.053.33
1173008800000039.565.83
2173008440000046.076.67
3173008080000046.978.17
4173007720000047.879.67
\n", + "
" + ], + "text/plain": [ + " ts output outputpercentage\n", + "0 1730091600000 32.0 53.33\n", + "1 1730088000000 39.5 65.83\n", + "2 1730084400000 46.0 76.67\n", + "3 1730080800000 46.9 78.17\n", + "4 1730077200000 47.8 79.67" + ] + }, + "execution_count": 33, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import pandas as pd\n", + "\n", + "query = \"\"\"\n", + "SELECT \n", + " ts, output, outputpercentage\n", + "FROM \n", + " windfarm_output\n", + "WHERE\n", + " windfarmid = 'NHOYW-1' AND outputpercentage >= 50\n", + "ORDER BY \n", + " ts DESC\n", + "LIMIT \n", + " 5\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Basic Aggregation\n", + "\n", + "This query returns the average output percentage of each wind farm for the month of August 2024 (represented by the timesamp `1722470400000`). Rather than displaying the ID values for each wind farm, we'll display the full name - obtained from the `windfarms` table." + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
nameavg_output_percent
0Seagreen Phase 169.41
1Walney 267.69
2West of Duddon Sands66.41
3Walney Extension 465.71
4Rhyl Flats61.25
\n", + "
" + ], + "text/plain": [ + " name avg_output_percent\n", + "0 Seagreen Phase 1 69.41\n", + "1 Walney 2 67.69\n", + "2 West of Duddon Sands 66.41\n", + "3 Walney Extension 4 65.71\n", + "4 Rhyl Flats 61.25" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Slide 18\n", + "\n", + "query = \"\"\"\n", + "SELECT\n", + " name, trunc(avg(outputpercentage), 2) AS avg_output_percent\n", + "FROM\n", + " windfarm_output o, windfarms w\n", + "WHERE\n", + " month = 1722470400000 AND o.windfarmid = w.id\n", + "GROUP BY\n", + " name\n", + "ORDER BY\n", + " avg_output_percent DESC\n", + "LIMIT\n", + " 5\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Downsampling\n", + "\n", + "Sometimes we want to aggregate time series data in a way that we can calculate a single value for a longer time period than that which the data was originally gathered in. The following query uses CrateDB's [`date_bin`](https://cratedb.com/docs/crate/reference/en/master/general/builtins/scalar-functions.html#date-bin-interval-timestamp-origin) function to downsample the data into weekly buckets with the average hourly output percentage." + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
weekhourly_avg_output_pct
0172972800000026.29
1172912320000031.16
2172851840000026.64
\n", + "
" + ], + "text/plain": [ + " week hourly_avg_output_pct\n", + "0 1729728000000 26.29\n", + "1 1729123200000 31.16\n", + "2 1728518400000 26.64" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"\n", + "SELECT\n", + " date_bin('1 week'::INTERVAL, ts, 0) AS week,\n", + " trunc(avg(outputpercentage), 2) AS hourly_avg_output_pct\n", + "FROM\n", + " windfarm_output\n", + "WHERE\n", + " windfarmid = 'NHOYW-1'\n", + "GROUP BY \n", + " week\n", + "ORDER BY\n", + " week DESC\n", + "LIMIT \n", + " 3\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Window Functions\n", + "\n", + "Let's use a [Window Function](https://cratedb.com/docs/crate/reference/en/latest/general/builtins/window-functions.html) to write a query that returns the hourly output of the Seagreen 1 wind farm along with a running total for the output for the day so far..." + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
hour_of_dayhour_outputoutput_day_so_far
017241120000001014.51014.5
117241156000001014.02028.5
217241192000001014.03042.5
317241228000001014.05070.5
417241228000001014.05070.5
517241300000001005.36075.8
61724133600000981.07056.8
71724137200000956.48013.2
81724140800000958.98972.1
91724144400000912.19884.2
101724148000000927.110811.3
111724151600000904.411715.7
\n", + "
" + ], + "text/plain": [ + " hour_of_day hour_output output_day_so_far\n", + "0 1724112000000 1014.5 1014.5\n", + "1 1724115600000 1014.0 2028.5\n", + "2 1724119200000 1014.0 3042.5\n", + "3 1724122800000 1014.0 5070.5\n", + "4 1724122800000 1014.0 5070.5\n", + "5 1724130000000 1005.3 6075.8\n", + "6 1724133600000 981.0 7056.8\n", + "7 1724137200000 956.4 8013.2\n", + "8 1724140800000 958.9 8972.1\n", + "9 1724144400000 912.1 9884.2\n", + "10 1724148000000 927.1 10811.3\n", + "11 1724151600000 904.4 11715.7" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"\n", + "SELECT \n", + " ts AS hour_of_day, \n", + " output AS hour_output, \n", + " sum(output) OVER (ORDER BY ts ASC) AS output_day_so_far\n", + "FROM\n", + " windfarm_output \n", + "WHERE \n", + " windfarmid='SEGRN-1' AND ts >= 1724112000000 AND ts < 1724198400000 \n", + "ORDER BY\n", + " hour_of_day ASC\n", + "LIMIT 12\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Geospatial Queries\n", + "\n", + "Imagine we wanted to know what was happening with wind farms in a given grographical area? Here's a GeoJSON representation of a polygon just off of the South East coast of England:\n", + "\n", + "```json\n", + "{\n", + " \"type\": \"Feature\",\n", + " \"properties\": {},\n", + " \"geometry\": {\n", + " \"coordinates\": [\n", + " [\n", + " [ 0.056102312465469595, 53.561105338449806 ],\n", + " [ 0.6294239522362943, 52.99772662833962 ],\n", + " [ 0.7490867055060448, 53.00672492889956 ],\n", + " [ 1.2526092934924407, 52.99172438336538 ],\n", + " [ 1.7362237521376755, 52.75097942970572 ],\n", + " [ 1.7711106241761172, 52.53317123980176 ],\n", + " [ 2.9676480713816034, 52.952692458677035 ],\n", + " [ 1.412164720757545, 54.09662224695873 ],\n", + " [ 0.056102312465469595, 53.561105338449806 ] \n", + " ]\n", + " ], \n", + " \"type\": \"Polygon\"\n", + " }\n", + "}\n", + "```\n", + "\n", + "This is what the polygon looks like when visualized on a map:\n", + "\n", + "![Map of the coastline showing a GeoJSON polygon.](multi-model-offshore-wind-farms-query.png \"Map of the coastline showing a GeoJSON polygon\")\n", + "\n", + "We can use this in a query to retrieve the names and latest output data for each wind farm whose location (a `GEO_POINT` in the `windfarms` table) falls [within](https://cratedb.com/docs/crate/reference/en/latest/general/builtins/scalar-functions.html#within-shape1-shape2) our Polygon like so:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namelatest_output_pct
0Race Bank71.48
1Dudgeon63.56
2Inner Dowsing59.48
3Triton Knoll51.89
4Lincs41.67
5Sheringham Shoal39.59
6Scroby Sands23.17
7Humber Gateway17.12
\n", + "
" + ], + "text/plain": [ + " name latest_output_pct\n", + "0 Race Bank 71.48\n", + "1 Dudgeon 63.56\n", + "2 Inner Dowsing 59.48\n", + "3 Triton Knoll 51.89\n", + "4 Lincs 41.67\n", + "5 Sheringham Shoal 39.59\n", + "6 Scroby Sands 23.17\n", + "7 Humber Gateway 17.12" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "query = \"\"\"\n", + "SELECT\n", + " name,\n", + " max_by(outputpercentage, ts) AS latest_output_pct\n", + "FROM\n", + " windfarms w, windfarm_output o\n", + "WHERE\n", + " w.id = o.windfarmid AND within(\n", + " location,\n", + " {\n", + " coordinates = [\n", + " [\n", + " [ 0.056102312465469595, 53.561105338449806 ],\n", + " [ 0.6294239522362943, 52.99772662833962 ],\n", + " [ 0.7490867055060448, 53.00672492889956 ],\n", + " [ 1.2526092934924407, 52.99172438336538 ],\n", + " [ 1.7362237521376755, 52.75097942970572 ],\n", + " [ 1.7711106241761172, 52.53317123980176 ],\n", + " [ 2.9676480713816034, 52.952692458677035 ],\n", + " [ 1.412164720757545, 54.09662224695873 ],\n", + " [ 0.056102312465469595, 53.561105338449806 ] \n", + " ]\n", + " ], \n", + " type = 'Polygon'\n", + " }\n", + " )\n", + "GROUP BY\n", + " name\n", + "ORDER BY\n", + " latest_output_pct DESC\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Full-text Search\n", + "\n", + "Recall that when we defined the schema for the `windfarms` table, we told CrateDB to index the `description` field using a full-text index. CrateDB's full-text search is powered by Lucene, and invoked with the [`match` predicate](https://cratedb.com/docs/crate/reference/en/latest/general/dql/fulltext.html).\n", + "\n", + "We can also, of course, combine full-text search clauses with other clauses in the same SQL statement. Here, we're selecting the name, number of turbines and text descriptions of each wind farm that has more than 80 turbines and whose description field contains keyword matches for either \"oil\" or \"gas\"." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
namenum_turbinesdescription
0East Anglia One102East Anglia ONE is located in the southern area of the East Anglia Zone, and is approximately 43 km (27 miles) from the shore. The initial proposal was for an installed capacity of 1200 MW. Cabling for East Anglia ONE lands near the River Deben at Bawdsey, runs north of Ipswich and is connected to the National Grid at Bramford. A plan was formally submitted to the government in December 2012, and planning consent was granted in June 2014. In October 2014 ScottishPower announced that it intended to scale down East Anglia ONE because of insufficient subsidies. In February 2015 it was announced that ScottishPower would proceed with a scaled-down 714 MW project. A contract for £119/MWh was published on 27 April 2016, using 102 Siemens Wind Power direct-drive 7 MW turbines. Nacelles were built in Cuxhaven, while blades were made in Hull. Due to water depths between 30-40m, the turbines use jacketed foundations. Cabling is at 66 kV as opposed to the traditional 33 kV. Two export cables at 220 kV AC send the power to shore. A support vessel is powered by used vegetable oil.
1Moray (East)100Moray East Wind Farm is an offshore wind farm located in the Moray Firth off the coast of Scotland. The wind farm received consent in 2014, and received support under the Contracts for Difference (CfD) scheme at £57.50/MWh (2012 prices) in 2017. The wind farm began exporting power in June 2021. The final turbine was installed in September 2021. Full power output was achieved in April 2022 and was commissioned. However, as market prices had increased above the CfD price due to the 2021 United Kingdom natural gas supplier crisis, the operator deferred the CfD start.
2Sheringham Shoal89Sheringham Shoal Offshore Wind Farm is a Round 2 wind farm in North Sea off the coast of Norfolk. A lease for use of the sea bed was obtained in 2004 by Scira Offshore Energy (later acquired by Statoil (now Equinor) and Statkraft), the development gained offshore planning consent in 2008, and was constructed 2009–2011, being officially opened in 2012. The wind farm has 88 Siemens Wind Power 3.6MW turbines (total power 316.8 MW) spread over a 35 km2 (14 sq mi) area over 17 km (11 mi) from shore. In 2004 the Crown Estate awarded Econventures (Utrecht, NL) the lease of the Round 2 wind farm site at Sheringham shoal. Econventures together with SLP Energy (Lowestoft, UK) formed a joint venture Scira Offshore Energy to develop a c. 315MW wind farm. Development work for Econventures was to be carried out by Evelop BV, both subsidiaries of Econcern BV. In 2005 Hydro took a 50% stake in Scira, acquiring 25% shareholdings from both SLP Energy and Ecocentures. In 2006 Scira submitted a planning application to the Department of Trade and Industry for a 108 turbine, 315 MW wind farm. The planned wind farm was approximately 18 kilometres (11 mi) off the coast of Norfolk at Sheringham, just within the 12 nm UK territorial water boundary, and 5 kilometres (3.1 mi) north of the sand bank known as Sheringham shoal. The wind farm would be located at water depths of 16 to 22 metres (52 to 72 ft) and consist of somewhere between 45 and 108 turbines. Benefits of the site included low shipping and trawling intensities; lack of any dredging, dumping, oil/gas, or MoD practice areas, and of cables or pipelines; as well as low visual impact from the coast, and outside any nature conservation areas. The seabed at the wind farm and offshore cable route consisted of mainly gravely sand, overlying chalk. The electrical power export cable was to be connected to a switching station near Muckleburgh Collection, via landfall near Weybourne Hope. Two routes were considered for the export cable, one avoiding the sandbank at Sheringham shoal. The connection to the National Grid was planned to be made at an electrical substation near Salle, Norfolk via a 132kV 21.3 kilometres (13.2 mi) underground cable. Planning consent for the wind farm was given on 8 August 2008.
3Beatrice84The Beatrice Offshore Wind Farm now known as Beatrice Offshore Windfarm Ltd (BOWL) project, is an offshore wind farm close to the Beatrice oil field in the Moray Firth, part of the North Sea 13 km off the north east coast of Scotland.
\n", + "
" + ], + "text/plain": [ + " name num_turbines \\\n", + "0 East Anglia One 102 \n", + "1 Moray (East) 100 \n", + "2 Sheringham Shoal 89 \n", + "3 Beatrice 84 \n", + "\n", + " description \n", + "0 East Anglia ONE is located in the southern area of the East Anglia Zone, and is approximately 43 km (27 miles) from the shore. The initial proposal was for an installed capacity of 1200 MW. Cabling for East Anglia ONE lands near the River Deben at Bawdsey, runs north of Ipswich and is connected to the National Grid at Bramford. A plan was formally submitted to the government in December 2012, and planning consent was granted in June 2014. In October 2014 ScottishPower announced that it intended to scale down East Anglia ONE because of insufficient subsidies. In February 2015 it was announced that ScottishPower would proceed with a scaled-down 714 MW project. A contract for £119/MWh was published on 27 April 2016, using 102 Siemens Wind Power direct-drive 7 MW turbines. Nacelles were built in Cuxhaven, while blades were made in Hull. Due to water depths between 30-40m, the turbines use jacketed foundations. Cabling is at 66 kV as opposed to the traditional 33 kV. Two export cables at 220 kV AC send the power to shore. A support vessel is powered by used vegetable oil. \n", + "1 Moray East Wind Farm is an offshore wind farm located in the Moray Firth off the coast of Scotland. The wind farm received consent in 2014, and received support under the Contracts for Difference (CfD) scheme at £57.50/MWh (2012 prices) in 2017. The wind farm began exporting power in June 2021. The final turbine was installed in September 2021. Full power output was achieved in April 2022 and was commissioned. However, as market prices had increased above the CfD price due to the 2021 United Kingdom natural gas supplier crisis, the operator deferred the CfD start. \n", + "2 Sheringham Shoal Offshore Wind Farm is a Round 2 wind farm in North Sea off the coast of Norfolk. A lease for use of the sea bed was obtained in 2004 by Scira Offshore Energy (later acquired by Statoil (now Equinor) and Statkraft), the development gained offshore planning consent in 2008, and was constructed 2009–2011, being officially opened in 2012. The wind farm has 88 Siemens Wind Power 3.6MW turbines (total power 316.8 MW) spread over a 35 km2 (14 sq mi) area over 17 km (11 mi) from shore. In 2004 the Crown Estate awarded Econventures (Utrecht, NL) the lease of the Round 2 wind farm site at Sheringham shoal. Econventures together with SLP Energy (Lowestoft, UK) formed a joint venture Scira Offshore Energy to develop a c. 315MW wind farm. Development work for Econventures was to be carried out by Evelop BV, both subsidiaries of Econcern BV. In 2005 Hydro took a 50% stake in Scira, acquiring 25% shareholdings from both SLP Energy and Ecocentures. In 2006 Scira submitted a planning application to the Department of Trade and Industry for a 108 turbine, 315 MW wind farm. The planned wind farm was approximately 18 kilometres (11 mi) off the coast of Norfolk at Sheringham, just within the 12 nm UK territorial water boundary, and 5 kilometres (3.1 mi) north of the sand bank known as Sheringham shoal. The wind farm would be located at water depths of 16 to 22 metres (52 to 72 ft) and consist of somewhere between 45 and 108 turbines. Benefits of the site included low shipping and trawling intensities; lack of any dredging, dumping, oil/gas, or MoD practice areas, and of cables or pipelines; as well as low visual impact from the coast, and outside any nature conservation areas. The seabed at the wind farm and offshore cable route consisted of mainly gravely sand, overlying chalk. The electrical power export cable was to be connected to a switching station near Muckleburgh Collection, via landfall near Weybourne Hope. Two routes were considered for the export cable, one avoiding the sandbank at Sheringham shoal. The connection to the National Grid was planned to be made at an electrical substation near Salle, Norfolk via a 132kV 21.3 kilometres (13.2 mi) underground cable. Planning consent for the wind farm was given on 8 August 2008. \n", + "3 The Beatrice Offshore Wind Farm now known as Beatrice Offshore Windfarm Ltd (BOWL) project, is an offshore wind farm close to the Beatrice oil field in the Moray Firth, part of the North Sea 13 km off the north east coast of Scotland. " + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "\n", + "query = \"\"\"\n", + "SELECT\n", + " name,\n", + " turbines['howmany'] AS num_turbines,\n", + " description\n", + "FROM \n", + " windfarms\n", + "WHERE\n", + " match(description, 'oil gas') AND turbines['howmany'] > 80\n", + "ORDER BY\n", + " num_turbines DESC\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Vector Similarity Search\n", + "\n", + "When we created the `windfarms` table earlier, we added a column named `description_vec` - this contains a vector representation of the text in the `description` field for each wind farm. The data set contains representations generated by OpenAI's `text-embedding-3-large` model - this step was performed whilst creating the JSONL file that you loaded into your cluster.\n", + "\n", + "CrateDB supports vector similarity search with the [`knn_match`](https://cratedb.com/docs/crate/reference/en/latest/general/builtins/scalar-functions.html#scalar-knn-match) function. This uses a k nearest neighbor search to find vectors that are similar to a given query vector.\n", + "\n", + "To perform searches, we'll need a query vector. The following represents the string \"Wind farms located off of the East of England\" after it has been encoded using the `text-embedding-3-large` model. Execute the following cell to prepare this for our query." + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [], + "source": [ + "query_vec = [-0.02290182188153267, 0.02615201473236084, 0.005037046503275633, 0.0037561545614153147, -0.022119367495179176, -0.011894803494215012, -0.01153367105871439, 0.008629563264548779, 0.011052160523831844, 0.003507876070216298, 0.035421084612607956, 0.006692237686365843, -0.041078828275203705, -0.000278608116786927, 0.02067483775317669, 0.03232136368751526, -0.003594397334381938, 0.005687837488949299, 0.030636077746748924, 0.009126120246946812, 0.008238336071372032, -0.007640210445970297, -0.015242802910506725, -0.011849661357700825, -0.014437777921557426, 0.03301353380084038, -0.00802015233784914, 0.01236126571893692, -0.036053065210580826, -0.0067599499598145485, -0.008170624263584614, -0.008238336071372032, -0.01616068184375763, 0.0057292175479233265, 0.0022006514482200146, 0.025249183177947998, -0.0013617706717923284, -0.02192375436425209, -0.012519261799752712, 0.00035995698999613523, 0.023428473621606827, 0.0016100492794066668, -0.046044398099184036, 0.03785872831940651, 0.011571289040148258, 0.006549288984388113, -0.02124663069844246, 0.0047097704373300076, 0.005345514044165611, 0.012263459153473377, 0.029311925172805786, 0.02592630684375763, -0.014400159940123558, 0.014272259548306465, -0.07162462174892426, -0.015603935346007347, -0.023278001695871353, 0.11568279564380646, 0.024225974455475807, 0.03764806687831879, 0.01810176856815815, 0.030214756727218628, -0.01740959845483303, -0.003699727589264512, -0.03205051273107529, -0.0009931145468726754, 0.005289087072014809, 0.0052702780812978745, -0.06470291316509247, -0.0010307325283065438, 0.0049016219563782215, 0.0011435863561928272, -0.007809491362422705, 0.0016345009207725525, -0.017198937013745308, 0.006978134158998728, -0.020133139565587044, -0.0049956669099628925, 0.03066617250442505, 0.00720760365948081, 0.041770998388528824, -0.032802872359752655, -0.04186128079891205, -0.013504852540791035, -0.014227117411792278, -0.0016674166545271873, -0.011571289040148258, -0.020930640399456024, 0.02535451389849186, -0.029733246192336082, 0.010405131615698338, 0.030079331248998642, -0.01307600736618042, 0.015099854208528996, -3.0123768738121726e-05, 0.009381922893226147, 0.02324790693819523, -0.006989419460296631, -0.008772511035203934, 0.05516299605369568, -0.08691256493330002, -0.006835185922682285, -0.041530244052410126, -0.009058408439159393, -0.015348133631050587, 0.0001791555987438187, -0.005996305029839277, 0.02288677543401718, 0.05702884867787361, -0.023940078914165497, 0.02290182188153267, -0.036685049533843994, 0.02570059895515442, -0.0073166959919035435, -0.04887327179312706, 0.016341248527169228, 0.033314477652311325, 0.035150233656167984, 0.03433768451213837, 0.004566822201013565, -0.014076645486056805, 0.008877841755747795, 0.08606992661952972, -0.011751854792237282, 0.02655828930437565, -0.0040476941503584385, 0.0062182508409023285, 0.01969677023589611, 0.03283296898007393, 0.03713646158576012, -0.018252240493893623, -0.02323286049067974, -0.00405145576223731, -0.010976924560964108, 0.058443281799554825, 0.030395323410630226, 0.002238269429653883, 0.01929049752652645, 0.047819968312978745, -0.012872870080173016, 0.010638362728059292, 0.02460215426981449, -0.029372112825512886, 0.04824128746986389, -0.007060893811285496, 0.004378732293844223, -0.01361770648509264, 0.013279144652187824, 0.0013486043317243457, -0.03689570724964142, 0.00030400024843402207, 0.01576945371925831, -0.032170891761779785, 0.027431026101112366, 0.005356799345463514, -0.024120643734931946, -0.017906155437231064, -0.004566822201013565, -0.013542470522224903, -0.009539918042719364, -0.038340236991643906, 0.0028100626077502966, -0.011383199132978916, -0.035661838948726654, 0.004487824160605669, -0.00867470446974039, -0.019456015899777412, 0.003635777160525322, -0.011277868412435055, 0.0023567660246044397, 0.027280554175376892, -0.02699465863406658, 0.010186946950852871, -0.02992885932326317, -0.013941220939159393, 0.06193423271179199, -0.015408322215080261, 0.013775701634585857, 0.011292915791273117, 0.03364551439881325, -0.04664628580212593, -0.009208880364894867, 0.05260497331619263, 0.048903364688158035, -0.010322371497750282, 0.031478721648454666, -0.014768816530704498, -0.043245621025562286, 0.013557517901062965, -0.024180833250284195, 0.008012628182768822, -0.025790883228182793, 0.06217498704791069, -0.03481919690966606, -0.005827024113386869, -0.009743055328726768, -0.026076778769493103, 0.0730089619755745, 0.030967116355895996, -0.024135692045092583, 0.047940343618392944, 0.031147681176662445, -0.011518623679876328, -0.026242299005389214, -0.017108654603362083, 0.03150881454348564, 0.04110892117023468, 0.06033923104405403, 0.009901050478219986, 0.0038896985352039337, 0.009246498346328735, -0.011119873262941837, 0.017951296642422676, 0.04032646864652634, 0.0006663083331659436, 0.06771235167980194, 0.009592583402991295, 0.018177004531025887, 0.007230174727737904, -0.0015470391372218728, 0.07096254825592041, -0.011398245580494404, -0.03701608628034592, 0.03469881787896156, -0.027431026101112366, 0.017394550144672394, -0.03472891449928284, -0.0052702780812978745, 0.031599096953868866, -0.01356504112482071, -0.06674933433532715, -0.009577536024153233, 0.0014830885920673609, -0.01255687978118658, -0.02997400052845478, -0.05639686435461044, 0.012428978458046913, 0.0329834409058094, -0.0076966374181210995, -0.02151748165488243, 0.018748797476291656, 0.034969668835401535, -0.06012856960296631, -0.024933192878961563, 0.0235187578946352, -0.03364551439881325, -0.02323286049067974, 0.0725274533033371, -0.0005054915091022849, -0.0291163120418787, 0.00645148241892457, 0.023097435012459755, -0.030636077746748924, 0.016642192378640175, -0.01255687978118658, -0.04836166650056839, 0.00876498781144619, 0.05492224171757698, -0.017891108989715576, 0.001492493087425828, -0.009314210154116154, 0.014528061263263226, -0.026528194546699524, 0.05064883828163147, -0.038460616022348404, 0.018192052841186523, -0.038280051201581955, 0.0167324747890234, -0.004055217374116182, -0.021788330748677254, -0.0029586537275463343, -0.027099987491965294, 0.007083464413881302, -0.050046950578689575, 0.03205051273107529, 0.011924897320568562, -0.025851070880889893, 0.014874146319925785, 0.02067483775317669, 0.004284687340259552, -0.05091968923807144, -0.002014442579820752, -0.030741408467292786, 0.01661209762096405, -0.0552532784640789, 0.02940220758318901, -0.005909783765673637, 0.03602297231554985, 0.013008295558393002, -0.04249326139688492, -0.012887917459011078, 0.03635400906205177, 0.010924259200692177, 0.031478721648454666, -0.023714371025562286, 0.008900412358343601, 0.016010209918022156, -0.04270392283797264, -0.004111644346266985, 0.06488347798585892, 0.01124777365475893, -0.002529808785766363, -0.03915278613567352, 0.007406978867948055, 0.009396969340741634, 0.01153367105871439, -0.01683780550956726, -0.006086587905883789, 0.023022199049592018, -0.023202765733003616, -0.006421388126909733, 0.04270392283797264, 0.03180975839495659, 0.0011746211675927043, -0.02734074369072914, -0.004961810540407896, -0.008087864145636559, -0.033495042473077774, -0.0038633658550679684, 0.006519194692373276, -0.011902326717972755, 0.020118093118071556, -0.05019742250442505, -0.03704617917537689, 0.01282020565122366, -0.007677828427404165, 0.05206327512860298, -0.011548717506229877, 0.0035906354896724224, 0.006748664658516645, 0.018643466755747795, -0.02318771928548813, 0.020810263231396675, -0.042162224650382996, 0.03319409862160683, -0.002136700786650181, 0.007632686756551266, -0.0076138777658343315, -0.025836024433374405, 0.03292325139045715, 0.015400798059999943, -0.003174956887960434, -6.612534343730658e-05, -0.04420864209532738, -0.03683552145957947, -0.014407684095203876, -0.0033874984364956617, 0.03797910735011101, -0.005443320609629154, -0.04535222798585892, 0.0006070600356906652, -0.0010448392713442445, 0.01213555783033371, 0.01236126571893692, 0.05031780153512955, -0.058262716978788376, -0.07138386368751526, -0.018116816878318787, 0.02038894221186638, 0.013121149502694607, 0.0015526819042861462, -0.02746112085878849, 0.024812815710902214, 0.023503709584474564, -0.04423873499035835, 0.05808215215802193, -0.016296105459332466, 0.0011849661823362112, 0.04098854213953018, -9.692506137071177e-05, -0.005988781340420246, 0.012128034606575966, -0.05371846631169319, 0.03177966549992561, -0.015573840588331223, -0.018628420308232307, -0.000840761698782444, 0.009690389968454838, 0.033314477652311325, -0.05122063308954239, -0.004769959021359682, -0.003923554439097643, 0.01957639306783676, -0.009803243912756443, -0.010254659689962864, 0.01843280717730522, 0.009855909273028374, -0.021878613159060478, -0.000546401075553149, 0.051130350679159164, 0.01724407821893692, 0.007580021861940622, -0.0012075369013473392, -0.01255687978118658, 0.013038389384746552, -0.04345628246665001, -0.0359627828001976, 0.015340609475970268, 0.013580088503658772, -0.0069480398669838905, -0.05462129786610603, 0.014279782772064209, 0.03466872498393059, 0.05477176979184151, -0.009901050478219986, 0.009773149155080318, -0.021201489493250847, -0.024526918306946754, -0.020283611491322517, 0.01062331534922123, 0.011142443865537643, -0.03590259328484535, 0.03975467383861542, -0.04017599672079086, 0.032110702246427536, 0.02956772781908512, -0.026588384062051773, -0.0002155980037059635, -0.017093606293201447, -0.046856947243213654, -0.0005388774443417788, -0.02654324285686016, -0.021938802674412727, 0.026648571714758873, -0.0362035371363163, 0.025053570047020912, 0.00176710425876081, 0.021547574549913406, 0.008862794376909733, 0.017259126529097557, -0.0014887313591316342, -0.025249183177947998, 0.019034694880247116, -0.02735579013824463, -0.002638900885358453, 0.03150881454348564, 0.04029637202620506, 0.027431026101112366, 0.005097235552966595, 0.0276868287473917, -0.016867898404598236, -0.00041779462480917573, -0.020343799144029617, 0.010442749597132206, -0.006729855667799711, 0.010653410106897354, 0.016973229125142097, -0.008855271153151989, 0.037888821214437485, -0.004781244322657585, -0.013459711335599422, 0.0025392132811248302, -0.00413797702640295, 0.035601649433374405, -0.02895079180598259, -0.010916735976934433, 0.04134967550635338, 0.02123158425092697, 0.011887279339134693, 0.013798272237181664, 0.01810176856815815, 0.03981486335396767, 0.049535349011421204, -0.026362676173448563, 0.008787558414041996, -0.03328438475728035, -0.038972221314907074, 0.0047135320492088795, -0.011405769735574722, -0.001502837985754013, -0.004092835355550051, 0.011541194282472134, -0.021998990327119827, 0.03196023032069206, -0.0660872533917427, 0.01170671358704567, 0.025820976123213768, -0.024075502529740334, 0.018989553675055504, -0.03677533194422722, -0.0011219560401514173, -0.04023618623614311, 0.015092330984771252, -0.004081550054252148, -0.017951296642422676, 0.004284687340259552, 0.020133139565587044, 0.006090349983423948, 0.007749302312731743, 0.022977057844400406, -0.005443320609629154, -0.0014304234646260738, -0.03247183561325073, 0.016627144068479538, -0.025595268234610558, -0.01765035279095173, -0.040747787803411484, -0.003784368047490716, -0.004642057698220015, 0.016235917806625366, -0.014339971356093884, 0.009682866744697094, 0.06789291650056839, -0.025143854320049286, -0.012910488061606884, 0.04484062269330025, 0.003363046795129776, -0.006470291409641504, -0.018914317712187767, 0.013692942447960377, 0.06837442517280579, -0.00996123906224966, 0.003741107415407896, 0.0045103952288627625, 0.00761011615395546, 0.020118093118071556, -0.02255573682487011, 0.015438416041433811, -0.015385751612484455, 0.0056351725943386555, -0.016566956415772438, 0.012963153421878815, 0.01361770648509264, 0.03208060935139656, 0.025550127029418945, 0.0329834409058094, -0.033254288136959076, -0.01924535445868969, -0.01258697360754013, 0.029537633061408997, -0.007572498172521591, 0.0028213479090481997, -0.012489167042076588, 0.013602659106254578, -2.498068533896003e-05, 0.020584555342793465, -0.008975648321211338, -0.013015818782150745, 0.031839851289987564, 0.014181976206600666, -0.03138843551278114, -0.001997514395043254, -0.01877889223396778, -0.038851842284202576, -0.008802605792880058, -0.030214756727218628, 0.027265507727861404, -0.014618344604969025, -0.02831881120800972, 0.016702380031347275, -0.04938487708568573, 0.019230308011174202, -0.014234641566872597, 0.027957677841186523, 0.013384475372731686, 0.03406683728098869, -0.032351456582546234, -0.017951296642422676, -0.014061598107218742, 0.014054074883460999, -0.013467234559357166, 0.005537365563213825, -0.024511871859431267, 0.015295468270778656, 0.0007043965742923319, 0.013760654255747795, 0.0360831618309021, 0.027716923505067825, -0.05624639242887497, -0.03424740210175514, -0.0026125682052224874, 0.008524232544004917, -0.03126806020736694, 0.008810129016637802, 0.03397655487060547, 0.026347627863287926, -0.0036207300145179033, -0.018929364159703255, -0.019155072048306465, -0.026362676173448563, -0.015558794140815735, -0.008531756699085236, -0.015558794140815735, 0.0004370738170109689, -0.012240888550877571, -0.008441473357379436, 0.04694722965359688, -0.01879393868148327, -0.006244583521038294, 0.008283478207886219, -0.01255687978118658, 0.0416807159781456, -0.006782520562410355, -0.021051017567515373, 0.02455701306462288, 0.044509585946798325, -0.0058495947159826756, 0.010961877182126045, -0.019200213253498077, 0.0019316829275339842, -0.0027686827816069126, 0.02398522011935711, -0.03454834595322609, 0.0035285658668726683, -0.02403036132454872, 0.0332241952419281, -0.010916735976934433, -0.015588887967169285, -0.012007657438516617, -0.01213555783033371, 0.0209005456417799, -0.029311925172805786, 0.02746112085878849, -0.0017736874287948012, 0.02713008224964142, 0.007147415075451136, -0.006733617279678583, 0.024391494691371918, 0.015483558177947998, -0.019486110657453537, 0.017966344952583313, -0.00552231865003705, 0.03650448098778725, -0.014580726623535156, 0.03809948265552521, 0.006970610469579697, 0.017379503697156906, -0.021427197381854057, -0.017003323882818222, -0.000197141693206504, 0.06217498704791069, -0.03524051606655121, 0.00022794140386395156, -0.02433130517601967, 0.011804520152509212, -0.02494823932647705, -0.01045027282088995, -0.030816644430160522, 0.017048465088009834, -0.005398179404437542, 0.04848204553127289, -0.0030526984483003616, -0.010269707068800926, -0.06711046397686005, 0.005044570192694664, -0.040687598288059235, -0.02016323432326317, -0.0062032039277255535, 0.036293819546699524, -0.004446444567292929, 0.008253383450210094, 0.03415711969137192, 0.009449634701013565, -0.022736303508281708, 0.03153890743851662, -0.01441520731896162, -0.008509185165166855, 0.0011059683747589588, 0.021216537803411484, 0.0005294729489833117, 0.00012602021161001176, 0.04071769490838051, 0.0010476605966687202, -0.0074370731599628925, 0.01507728360593319, -0.027446072548627853, -0.026738855987787247, 0.000536526320502162, -0.009103549644351006, 0.030244851484894753, 0.020569507032632828, 0.005778120830655098, 0.006617001723498106, 0.0004718704440165311, 0.04529203847050667, -0.02654324285686016, -0.0020783930085599422, 0.03050065226852894, -0.004213212989270687, 0.02073502726852894, 0.026799043640494347, -0.0037561545614153147, -0.010209517553448677, -0.022059179842472076, 0.0097054373472929, -0.02392503060400486, 0.010931783355772495, -0.006135491654276848, -0.008411378599703312, -0.026452958583831787, -0.030967116355895996, -0.0008036139770410955, -0.030395323410630226, -0.025820976123213768, 0.030244851484894753, 0.05892479419708252, 0.0060301609337329865, 0.01370046567171812, 0.019140025600790977, 0.01685285195708275, 0.0022439120803028345, 0.010405131615698338, 0.011360627599060535, -0.008697275072336197, 0.03939354047179222, 0.0011181943118572235, -0.0014097335515543818, 0.0004098007921129465, 0.0037016086280345917, 0.012970677576959133, 0.02016323432326317, 0.005962448660284281, -0.031719475984573364, -0.014309877529740334, -0.024060456082224846, -0.018192052841186523, 0.03289315477013588, 0.020644742995500565, -0.0034759007394313812, -0.015054713003337383, 0.04631524905562401, -0.004785006400197744, -0.05070902779698372, 0.010894165374338627, 0.018824033439159393, -0.02460215426981449, 0.019440969452261925, -0.0014040909009054303, 0.011586335487663746, 0.03518033027648926, -0.040507033467292786, 0.03812957927584648, -0.023022199049592018, 0.03448815643787384, 0.004382493905723095, -0.0022345075849443674, -0.02746112085878849, -0.002383098704740405, -0.028183385729789734, 0.03244173899292946, 0.020704932510852814, 0.007414502557367086, 0.013038389384746552, 0.017575116828083992, -0.008388807997107506, -0.014039027504622936, -0.037828635424375534, -0.014821481890976429, -0.007128606084734201, 0.014941859059035778, -0.013835890218615532, 0.01677761599421501, -0.005827024113386869, -0.05167204886674881, 0.021622810512781143, 0.0208403579890728, -0.017484834417700768, 0.0004993785987608135, 0.01861337386071682, 0.004589392803609371, -0.026121919974684715, 0.010706075467169285, 0.014076645486056805, 0.023428473621606827, 0.029026027768850327, -0.018914317712187767, 0.0011736807646229863, -0.035541459918022156, 0.020945686846971512, 0.02272125519812107, 0.0235187578946352, 0.0021799616515636444, 0.0002868370502255857, 0.00930668693035841, -0.05188271030783653, 0.009359351359307766, 0.013738083653151989, -0.017108654603362083, 0.019170118495821953, -0.05022751912474632, 0.02985362336039543, -0.004077788442373276, -0.020825309678912163, -0.028679942712187767, -0.004532965831458569, 0.027777111157774925, 0.027220366522669792, -0.03289315477013588, -0.06235555186867714, 0.01850804314017296, -0.07258763909339905, -0.0007899774354882538, -0.015423369593918324, -0.004201927687972784, -0.024451682344079018, -0.003741107415407896, 0.026452958583831787, 0.05416988208889961, -0.01826728880405426, -0.0291163120418787, 0.024256069213151932, 0.031027304008603096, -0.05257488042116165, 0.02706989459693432, 0.008268430829048157, -0.0015216469764709473, 0.006564336363226175, 0.001607227954082191, -0.022600878030061722, 0.0001899707713164389, 0.020238470286130905, -0.006989419460296631, -0.009020790457725525, -0.0052815633825957775, -0.020629696547985077, 0.021306820213794708, -0.033946458250284195, 0.03241164609789848, 0.002467739162966609, -0.0060263993218541145, 0.03048560582101345, 0.012579450383782387, -0.019094882532954216, 0.036053065210580826, -0.046856947243213654, 0.06217498704791069, 0.02186356671154499, -0.05293601378798485, 0.00805024616420269, 0.007485976908355951, -0.008072816766798496, 0.0018508043140172958, -0.058954887092113495, -0.04312524572014809, 0.03072636015713215, 0.021562622860074043, 0.0012225841637700796, 0.034909479320049286, -0.04065750539302826, -0.0471578910946846, 0.028409093618392944, -0.00376179744489491, 0.03837033361196518, -0.023894935846328735, 0.011751854792237282, 0.03361542150378227, 0.05486205220222473, -0.049595534801483154, -0.034969668835401535, -0.007666543126106262, -0.0008572195656597614, 0.04556288942694664, 0.0056615048088133335, -0.0005210089148022234, -0.003099720925092697, -0.014114263467490673, -0.021667953580617905, 0.011541194282472134, 0.008095388300716877, -0.01599516160786152, -0.011142443865537643, -0.00747845321893692, -0.0017482952680438757, 0.00466839037835598, -0.0015263492241501808, 0.022450406104326248, -0.007154938764870167, 0.02226983942091465, 0.039875052869319916, -0.01850804314017296, -0.0012931178789585829, -0.0069367541000247, -0.03448815643787384, -0.0016834043199196458, -0.007677828427404165, -0.00733926659449935, -0.030741408467292786, -0.019997714087367058, 0.01998266763985157, -0.03352513909339905, -0.01838766597211361, 0.004265878349542618, 0.05486205220222473, 0.017334362491965294, -0.019275449216365814, -0.030274944379925728, -0.0419214703142643, 0.03448815643787384, 0.04646572098135948, -0.028002819046378136, -0.01810176856815815, 0.0012470358051359653, 0.0037561545614153147, -0.0006028280477039516, 0.001577133545652032, -0.0008003223920240998, 0.013264097273349762, -0.005526080261915922, 0.04613468423485756, 0.04797044023871422, 0.009178785607218742, 0.008486614562571049, 0.012842776253819466, -0.002573069417849183, 0.042613640427589417, -0.045472607016563416, 0.01724407821893692, -0.036564670503139496, -0.008486614562571049, 0.020945686846971512, -0.026392770931124687, 0.01564907655119896, 0.01347475778311491, -0.018703656271100044, 0.054380543529987335, -0.016928087919950485, 0.0019081716891378164, 0.03367561101913452, -0.031599096953868866, 0.008998218923807144, -0.04760930687189102, 0.03129815310239792, -0.038851842284202576, -0.014370066113770008, -0.03265240043401718, -0.00010215630754828453, 0.037888821214437485, 0.010563126765191555, -0.008983172476291656, 0.023533804342150688, 0.008035198785364628, 0.013211431913077831, 0.025760788470506668, -0.03135834261775017, -0.012248411774635315, 0.013166290707886219, 0.03689570724964142, -0.017545022070407867, -0.006470291409641504, -0.005048332270234823, 0.028845462948083878, -0.005811976734548807, -0.0027235413435846567, -0.025820976123213768, 0.020569507032632828, -0.011292915791273117, 0.02985362336039543, -0.0021912469528615475, -0.0067712352611124516, -0.011240250431001186, 0.008795082569122314, -0.009427064098417759, -0.010186946950852871, 0.0024244782980531454, 0.0027066131588071585, 0.009359351359307766, -0.03460853546857834, -0.0035793501883745193, -0.0043486375361680984, -0.007756826002150774, 0.00013660026888828725, 0.02204413339495659, -0.05931602045893669, 0.014046551659703255, 0.04140986502170563, -0.03232136368751526, -0.014302353374660015, -0.01147348154336214, -0.020704932510852814, -0.04995666816830635, 0.01849299669265747, 0.014806434512138367, 0.006252107210457325, 0.014407684095203876, 0.012481643818318844, -0.024105597287416458, 0.039483826607465744, 0.014460349455475807, 0.02249554730951786, -0.027491215616464615, -0.018282335251569748, -0.004352399613708258, -0.019486110657453537, 0.028800319880247116, -0.007064655423164368, 0.014625867828726768, -0.009050884284079075, -0.0016542504308745265, 0.05413978919386864, 0.004608201794326305, -0.0003004735626745969, -0.02791253663599491, 0.02809310331940651, 0.009946192614734173, 0.005906021688133478, -0.035029858350753784, -0.01593497395515442, -0.03466872498393059, 0.0008327678660862148, -0.008885364979505539, -0.03111758828163147, 0.02284163422882557, -0.004446444567292929, 0.022194603458046913, 0.0010561245726421475, 0.04511147364974022, 0.009743055328726768, 0.046104587614536285, 0.047819968312978745, -0.0027799683157354593, 0.014633391983807087, 0.05206327512860298, 0.02374446578323841, -0.024617202579975128, 0.031027304008603096, 0.006252107210457325, 0.03912269324064255, 0.010721122846007347, 0.04047694057226181, -0.030064284801483154, 0.0042508309707045555, -0.013692942447960377, 0.03202041983604431, -0.06506405025720596, -0.0011746211675927043, 0.04213213175535202, -0.020419035106897354, 0.005420750007033348, 0.01347475778311491, -0.040747787803411484, -0.010254659689962864, 0.004950525239109993, -0.010164376348257065, 0.0020313705317676067, 0.018718702718615532, -0.019049741327762604, 0.012827728874981403, 0.05022751912474632, -0.015483558177947998, -0.004611963406205177, -0.009427064098417759, -0.000587780843488872, -0.017033418640494347, 0.01734940893948078, -0.009690389968454838, 0.017725588753819466, -0.002796896267682314, 0.035932689905166626, -0.013106102123856544, -0.03196023032069206, 0.030229803174734116, -0.001493433490395546, -0.003122291760519147, -0.021156348288059235, 0.041018638759851456, -0.0181619580835104, 0.0035906354896724224, -0.01765035279095173, 0.00703456113114953, 0.019952572882175446, -0.013346857391297817, 0.014528061263263226, 0.006545527372509241, -0.02598649635910988, 0.03650448098778725, -0.006838947534561157, 0.01792120188474655, 0.0528758242726326, 0.04664628580212593, 0.01742464490234852, 0.015363180078566074, 0.0011313605355098844, 0.043817415833473206, 0.021848518401384354, -0.010337418876588345, 0.03244173899292946, 0.01677761599421501, 0.00216115266084671, 0.010442749597132206, 0.01765035279095173, 0.005341752432286739, 0.017229031771421432, 0.027987772598862648, 0.006267154589295387, -0.024873003363609314, 0.025053570047020912, 0.013361903838813305, 0.04309514909982681, -0.046616192907094955, 0.008968125097453594, -0.014625867828726768, 0.006376246456056833, 0.0010015785228461027, 0.03050065226852894, 0.037317030131816864, -0.011586335487663746, 0.013993886299431324, 0.0664483904838562, -0.031087493523955345, 0.012150605209171772, -0.02141215093433857, 0.02008799836039543, -0.0031486244406551123, -0.02204413339495659, 0.015400798059999943, 0.009998857043683529, 0.004021361470222473, 0.020990829914808273, 0.01062331534922123, -0.039092596620321274, -0.005131091456860304, 0.015257850289344788, -0.026874279603362083, 0.019155072048306465, 0.0026727570220828056, -0.005574983544647694, 0.012887917459011078, 0.01593497395515442, 0.009750578552484512, -0.002364289714023471, -0.025369562208652496, 0.013098577968776226, 0.032170891761779785, 0.023488663136959076, -0.008178147487342358, -0.03912269324064255, -0.020689886063337326, 0.0038088199216872454, 0.03050065226852894, 0.013850937597453594, 0.01883908174932003, 0.009554965421557426, -0.0040589794516563416, -0.04842185601592064, 0.015739360824227333, 0.03111758828163147, 0.03487938642501831, -0.0014727436937391758, 0.011548717506229877, -0.009938668459653854, -0.01067598070949316, 0.0016749402275308967, -0.00819319486618042, -0.023112483322620392, 0.019034694880247116, -0.0049994285218417645, 0.018944410607218742, -0.011089778505265713, -0.016235917806625366, -0.023217814043164253, -0.02494823932647705, -0.01124777365475893, 0.019907431676983833, 0.021457292139530182, 0.007373122964054346, -0.005898498464375734, -0.02112625353038311, -0.03518033027648926, -0.027671780437231064, -0.013286667875945568, -0.00596621073782444, 0.009622677229344845, -0.013143720105290413, -0.013738083653151989, -0.03232136368751526, 0.014144358225166798, 0.017198937013745308, 0.012624591588973999, -0.01900460012257099, 0.018598325550556183, -0.020539414137601852, -0.009840861894190311, -0.0018150672549381852, 0.017048465088009834, -0.021457292139530182, 0.010209517553448677, 0.007203842047601938, 0.0206597913056612, 0.0024019076954573393, -0.04962563142180443, -0.015333086252212524, -0.0005619184812530875, -0.0014736840967088938, -0.005319181364029646, -0.02849937602877617, -0.0016674166545271873, -0.008930507116019726, -0.004043932072818279, -0.00649286201223731, 0.0090809790417552, -0.02038894221186638, 0.022029085084795952, -0.006703522987663746, 0.017319314181804657, 0.013346857391297817, -0.0138735082000494, 0.004785006400197744, -0.0013316762633621693, -0.003573707537725568, 0.01196251530200243, -0.05477176979184151, 0.037888821214437485, -0.007583783473819494, 0.0012263458920642734, 0.026452958583831787, 0.026452958583831787, -0.0034947097301483154, -0.03524051606655121, 0.02175823599100113, 0.02615201473236084, 0.0024940716102719307, -0.0021254154853522778, -0.0010119235375896096, -0.008659657090902328, -0.01707855984568596, 0.0027987773064523935, 0.010931783355772495, 0.013068484142422676, -0.009923621080815792, -0.027897488325834274, -0.021908707916736603, -0.03927316516637802, 0.002100963843986392, 0.03843052312731743, 0.020644742995500565, 0.018929364159703255, 0.0074107409454882145, 0.021953849121928215, -0.007869680412113667, 0.0206597913056612, -0.03803929314017296, -0.02523413673043251, 0.03126806020736694, -0.0044426824897527695, 0.0008449937449768186, -0.032742682844400406, -0.021502433344721794, 0.007794443983584642, -0.005236421711742878, 0.010344943031668663, -0.00036606990033760667, 0.019155072048306465, -0.016882946714758873, -0.04014590010046959, -0.009073454886674881, -0.003938601817935705, -0.019456015899777412, 0.008742417208850384, -0.0011078492971137166, -0.042673829942941666, -0.009818291291594505, 0.0025072379503399134, -0.019049741327762604, 0.007463405840098858, 0.000640916230622679, -0.008719846606254578, 0.022254792973399162, -0.014798910357058048, -0.018131863325834274, 0.007580021861940622, -0.003477781545370817, 0.008042722940444946, 0.003972458187490702, 0.0076966374181210995, 0.05143129453063011, -0.022871727123856544, 0.009524870663881302, 0.01734940893948078, -0.029763340950012207, 0.00600759033113718, 0.0010655290680006146, 0.03174956887960434, -0.024241022765636444, 0.0011840256629511714, 0.016085445880889893, 0.014347495511174202, 0.02163785882294178, 0.022585831582546234, -0.0027573974803090096, -0.01036751363426447, 0.0037693209014832973, 7.424406703648856e-06, 0.01005152240395546, 0.010487890802323818, 0.015287944115698338, -0.012571927160024643, -0.025279277935624123, -0.010209517553448677, -0.006398817058652639, 0.011518623679876328, -0.0021686761174350977, -0.007004466839134693, 0.011593859642744064, 0.03048560582101345, 0.04246316850185394, 0.002112249145284295, -0.004645819775760174, 0.019726864993572235, 0.00022124071256257594, 0.006361199542880058, 0.034969668835401535, -0.009013266302645206, -0.02210432104766369, -0.00013424914504867047, 0.002471500774845481, 0.004717293661087751, -0.023142578080296516, 0.004491586238145828, -0.010879117995500565, -0.015965068712830544, 0.004555536434054375, -0.006955563090741634, 0.03123796544969082, -0.02488805167376995, 0.0033799749799072742, 0.029131358489394188, 0.0036075636744499207, 0.02231498248875141, 0.017108654603362083, 0.0011087898164987564, -0.015408322215080261, -0.02157766930758953, -0.031839851289987564, -0.008877841755747795, 0.02141215093433857, 0.005902260076254606, 0.02010304480791092, 0.0002520404232200235, -0.05474167317152023, 0.0442989245057106, -0.004378732293844223, 0.008787558414041996, -0.01769549399614334, 0.005127329844981432, -0.009765625931322575, 0.0003804117441177368, 0.009178785607218742, 0.016807710751891136, -0.0025523793883621693, 0.0011294796131551266, -0.0008595706894993782, -0.0004182648553978652, -0.0002384039107710123, -0.021096158772706985, -0.03361542150378227, 0.008268430829048157, 0.04195156320929527, -0.01724407821893692, -0.0014040909009054303, 0.019937526434659958, -0.022029085084795952, 0.007854633033275604, -0.01628105901181698, -0.02597144804894924, 0.014926811680197716, 0.01245154906064272, -0.019395826384425163, 0.022224698215723038, 0.030530747026205063, -0.00605273200199008, -0.025309372693300247, 0.013956268317997456, -0.005405702628195286, 0.0013645919971168041, 0.007474691141396761, 0.004299734253436327, 0.0045367274433374405, 0.0008906055008992553, -0.0362035371363163, -0.005082188174128532, -0.034909479320049286, -0.0076025924645364285, 0.00378248724155128, -0.012970677576959133, 0.021773282438516617, 0.029612869024276733, -0.002541094087064266, 0.002815705258399248, -0.006673428695648909, -0.015799548476934433, -0.004916669335216284, 0.0009949953528121114, -0.027370836585760117, -0.009434587322175503, 0.007542403880506754, -0.00853927992284298, -0.014919288456439972, 0.0003016491245944053, 0.008260906673967838, 0.0442989245057106, 0.010540556162595749, -0.01438511349260807, -0.004119168035686016, -0.01561898272484541, -0.0020464176777750254, -0.020253516733646393, -0.01062331534922123, 0.040687598288059235, 0.0031599097419530153, -0.01712370105087757, -0.008524232544004917, 0.02386484295129776, -0.03283296898007393, -0.0045404895208776, 0.013993886299431324, -0.00431101955473423, -0.01498700026422739, 0.007279078010469675, 0.005206327419728041, 0.01107473112642765, 0.001072112238034606, 0.012880394235253334, 0.008268430829048157, -0.010879117995500565, -0.025715647265315056, -0.023684276267886162, 0.011917374096810818, 0.011684142984449863, 0.011232727207243443, 0.01734940893948078, -0.00680885324254632, 0.004935478325933218, 0.0011087898164987564, 0.0050897118635475636, -0.0008633324760012329, -0.028002819046378136, -0.025595268234610558, -0.010864070616662502, -0.0019081716891378164, -0.016822757199406624, -0.026076778769493103, -0.02449682354927063, -0.011323009617626667, 0.0008464044076390564, 0.013226479291915894, -0.012308601289987564, 0.012835252098739147, 0.012775063514709473, 0.013986362144351006, -0.01242145523428917, -0.023097435012459755, -0.0032539546955376863, -0.001502837985754013, -0.016341248527169228, 0.0016946897376328707, -0.023533804342150688, -0.001892184023745358, -0.00022512006398756057, 0.014595774002373219, 0.01201518066227436, 0.02181842550635338, 0.021321866661310196, 0.0004394249408505857, 0.0034853052347898483, 0.0030545794870704412, -0.010036475025117397, 0.0329834409058094, 0.005010714288800955, -0.01685285195708275, -0.01986229047179222, -0.0003131696430500597, -0.008200718089938164, -0.015739360824227333, -0.0027762064710259438, 0.04309514909982681, 0.01861337386071682, -0.01849299669265747, -0.031719475984573364, 0.0279275830835104, -0.00930668693035841, 0.004446444567292929, -0.00864461064338684, 0.0009319852688349783, -0.016913041472434998, 0.005353037733584642, -0.03328438475728035, -0.008546803146600723, -0.030244851484894753, -0.02564041130244732, -0.01415940560400486, -0.008441473357379436, -0.023488663136959076, 0.017108654603362083, -0.0023022200912237167, -0.005100997164845467, -0.011503576301038265, 0.006511671002954245, -0.008704799227416515, -0.016521813347935677, -0.03457844257354736, -0.00266899517737329, -0.018357571214437485, 0.013519899919629097, 0.01873375102877617, -0.0090809790417552, 0.013542470522224903, 0.011383199132978916, -0.006925468798726797, 0.00543579738587141, 0.02895079180598259, 0.02118644304573536, 0.004555536434054375, 0.005274039693176746, 0.011954992078244686, -0.009126120246946812, 0.03412702679634094, -0.0017266649520024657, -0.048451948910951614, -0.007090988103300333, -0.00011696838919306174, -0.007700399029999971, 0.018658515065908432, -0.013068484142422676, -0.015069760382175446, 0.004055217374116182, -0.009291639551520348, 0.00632358156144619, 0.016371341422200203, 0.01616068184375763, 0.003976219799369574, -0.006797567941248417, -0.010570650920271873, 0.01820709928870201, 0.005981257651001215, 0.008561850525438786, 0.018342524766921997, 0.0022420312743633986, -0.000683236459735781, 0.010111710987985134, 0.0031674334313720465, -0.02449682354927063, -0.03367561101913452, -0.04195156320929527, 0.002520404290407896, -0.00043237156933173537, -0.0055674598552286625, 0.019606487825512886, -0.0064063407480716705, 0.007794443983584642, 0.005672790575772524, 0.023669229820370674, -0.027942631393671036, -0.0011774426093325019, 0.003780606435611844, 0.007064655423164368, -0.006462767720222473, -0.004946763627231121, 0.016702380031347275, 0.021562622860074043, -0.005845833104103804, -0.019892385229468346, -0.006959325168281794, -0.04423873499035835, 0.022691162303090096, -0.00342511641792953, 0.0305457953363657, -0.024000266566872597, -0.004164309706538916, -0.003750511910766363, -0.009359351359307766, -0.019260402768850327, -0.00578188244253397, 0.01250421442091465, -0.01067598070949316, -0.022510595619678497, 0.0035793501883745193, 0.013911126181483269, 0.008795082569122314, -0.01769549399614334, -0.03316400572657585, -0.0013890436384826899, 0.022600878030061722, -0.0022119367495179176, -0.0014774459414184093, -0.012195747345685959, -0.015664124861359596, -0.025670504197478294, -0.010307325050234795, -0.011947467923164368, 0.009457158856093884, -0.02843918837606907, 0.018056627362966537, -0.0015498604625463486, 0.007147415075451136, -0.007049608044326305, 0.0035379703622311354, 0.022871727123856544, -0.027596544474363327, -0.018237194046378136, -0.013850937597453594, -0.01518261432647705, -0.01050293818116188, 0.0059323543682694435, -0.010585697367787361, -0.003259597346186638, -0.0029116312507539988, 0.0021254154853522778, -0.004864003974944353, 0.005307896062731743, 0.00502576120197773, 0.01883908174932003, -0.016070397570729256, 0.000598596001509577, -0.004702246747910976, 0.0013486043317243457, -0.0003479662409517914, 0.005710408557206392, 0.013798272237181664, 0.01804158091545105, -0.016371341422200203, -0.024963287636637688, -0.03226117417216301, 0.01087159477174282, -0.017620258033275604, -0.013196385465562344, 0.0390625037252903, -0.04053713008761406, -9.363348362967372e-05, 0.022194603458046913, 0.02096073515713215, -0.011315486393868923, 0.01352742314338684, -0.012474119663238525, 0.013896079733967781, 0.016190776601433754, -0.028243575245141983, 0.005766835529357195, -0.0008007925935089588, 0.009840861894190311, 0.004363684915006161, 0.016085445880889893, 0.011992610059678555, -0.010292277671396732, -0.006413864437490702, 0.003509756876155734, 0.014272259548306465, 0.008501661941409111, -0.001020387513563037, 0.022736303508281708, -0.01349732931703329, 0.01272992230951786, 0.015242802910506725, -0.0034965905360877514, -0.008388807997107506, 0.010931783355772495, -0.0035887546837329865, -0.004111644346266985, -0.0033141435123980045, 0.00493923993781209, 0.004743626341223717, -0.005593792535364628, -0.0027235413435846567, 0.006127967964857817, -0.018056627362966537, -0.017198937013745308, -0.0073430282063782215, -0.007346790283918381, 0.0004570583696477115, -0.0031373389065265656, -0.024075502529740334, -0.015190137550234795, 0.02466234378516674, 0.015235279686748981, 0.002992509864270687, 0.01792120188474655, 0.0017953177448362112, 0.024165786802768707, -0.003709132084622979, 0.006842709146440029, -0.023669229820370674, -0.006150538567453623, -0.006481576710939407, -0.014249688014388084, -0.016070397570729256, -0.0006291606114245951, 0.010036475025117397, 0.020419035106897354, 0.016296105459332466, -0.01099197193980217, 0.00016998621867969632, -0.015679171308875084, 0.011924897320568562, 0.0005708527751266956, -0.021442245692014694, -0.0041417391039431095, 0.00586840370669961, 0.015002047643065453, 0.005642695818096399, -0.007008228451013565, 0.02288677543401718, 0.005958687048405409, 0.005010714288800955, 0.011541194282472134, -0.010487890802323818, -0.02026856504380703, 0.0010692909127101302, 0.017966344952583313, -0.02615201473236084, -0.007670304737985134, 0.017680447548627853, -0.01370046567171812, 0.012218317948281765, -0.020403988659381866, -0.004205689299851656, 0.0004664628650061786, -0.00529661076143384, -0.011315486393868923, -0.0012028346536681056, -0.003174956887960434, 0.012045275419950485, 0.000851576856803149, 0.006996943149715662, -0.02705484628677368, 0.0004215564113110304, 0.016371341422200203, 0.011894803494215012, 0.009818291291594505, -0.010946830734610558, -0.024421587586402893, 0.01918516680598259, -0.012624591588973999, 0.0223300289362669, 0.005420750007033348, -0.0021893661469221115, 0.017259126529097557, -0.002460215473547578, 0.010299800895154476, -0.01370046567171812, -0.010833976790308952, 0.03653457760810852, 0.030395323410630226, 0.017394550144672394, -0.023308096453547478, -0.008877841755747795, -0.01401645690202713, 0.02123158425092697, -0.020118093118071556, 0.012737445533275604, 0.007621401455253363, -0.015393274836242199, -0.023834748193621635, 0.00222698412835598, 0.002196889603510499, -0.0010241493582725525, -0.0003719477099366486, -0.0028326334431767464, 0.01272992230951786, -0.010578174144029617, -0.019967621192336082, -0.0029454873874783516, 0.00047116511268541217, 0.014084169641137123, 0.019726864993572235, -0.0011275988072156906, -0.0337057039141655, -0.0009818291291594505, 0.0061204442754387856, 0.024752626195549965, -0.020057903602719307, 0.01406912226229906, 0.0033762131351977587, -0.007395693566650152, -0.003449568059295416, 0.026633525267243385, 0.03843052312731743, 0.0004989083972759545, -0.03168937936425209, 0.0007217948441393673, 0.009570012800395489, 0.004837671294808388, -0.03424740210175514, 0.016536861658096313, -0.006485338788479567, -0.001261142548173666, -0.014144358225166798, 0.001973062753677368, 0.007354313973337412, -0.01241393107920885, 0.028303762897849083, 0.013136195950210094, 0.015107378363609314, -0.014212070032954216, -0.025023475289344788, 0.0002401672536507249, 0.004130453336983919, 0.0012197628384456038, -0.007636448834091425, 0.009682866744697094, -0.006474053021520376, -0.012248411774635315, -0.0008101970888674259, 0.023157624527812004, 0.0038370334077626467, 0.0007321398006752133, -0.008802605792880058, 0.0206597913056612, -0.010472843423485756, 0.023428473621606827, -0.0010260302806273103, -0.019892385229468346, 0.006609478034079075, 0.019365733489394188, 0.002529808785766363, 0.0063010104931890965, 0.006669666618108749, -0.0031975277233868837, -0.03208060935139656, -0.018974505364894867, -0.009464682079851627, 0.0061242058873176575, 0.0018686727853491902, 0.013602659106254578, -0.023849794641137123, -0.02580592967569828, -0.008321096189320087, -0.012218317948281765, 0.00805024616420269, 0.0021724379621446133, 0.002386860316619277, -0.009645248763263226, -0.013482281938195229, -0.006331104785203934, -0.00022735362290404737, 0.03587250038981438, 0.00170221331063658, 0.002522285096347332, 0.006376246456056833, 0.010841500014066696, 0.02038894221186638, -0.011571289040148258, 0.00435616122558713, -3.4620290534803644e-05, 0.02506861835718155, -0.010833976790308952, -0.01695818267762661, -0.0038708895444869995, 0.00725274533033371, -0.012323647737503052, 0.0009606690146028996, -0.008930507116019726, 0.011180061846971512, 0.0089906957000494, -0.010179423727095127, -0.016882946714758873, -0.019486110657453537, -0.0019373255781829357, -0.013768178410828114, -0.0037787253968417645, -0.0053643230348825455, 0.007053370121866465, 0.014866623096168041, 0.03129815310239792, 0.018342524766921997, -0.0025185232516378164, 0.003276525530964136, -0.0097957206889987, -0.024301210418343544, -0.017951296642422676, -0.03193013742566109, 0.008546803146600723, -0.0024094311520457268, -0.011180061846971512, 0.0001711617805995047, 0.03421730920672417, -0.0031599097419530153, -0.01147348154336214, 0.0029605345334857702, 0.008870318531990051, -0.001082457136362791, -0.007779397070407867, -0.00881765317171812, 0.00947972945868969, -0.03933335468173027, -0.023503709584474564, -0.02306734211742878, 0.018026532605290413, -0.01344466395676136, 0.01227850653231144, -0.012699827551841736, 0.01022456493228674, 0.00796748697757721, 0.023834748193621635, -0.007282839622348547, 0.0004213213105686009, 0.013369427993893623, -0.017168842256069183, 0.020599601790308952, 0.02699465863406658, 0.009607630781829357, -0.02147233858704567, -0.00573674077168107, -0.014287305995821953, 0.029883718118071556, -0.014618344604969025, -0.00046293617924675345, 0.014746245928108692, -0.0013928054831922054, -0.003058341331779957, -0.028168339282274246, -0.00168058299459517, 0.009013266302645206, -0.013060959987342358, 0.0014153762022033334, 0.011571289040148258, -0.010864070616662502, -0.010006381198763847, -0.008772511035203934, -0.02877022698521614, 0.017168842256069183, -0.0006206965772435069, -0.0017906154971569777, 0.026332581415772438, -0.0058383094146847725, -4.640529732569121e-05, -0.02055446058511734, 0.008268430829048157, 0.016085445880889893, -0.009103549644351006, -0.0038201052229851484, 0.014400159940123558, 0.016371341422200203, -0.004359923303127289, -0.0008017330546863377, -0.019425921142101288, 0.009712960571050644, -0.015242802910506725, 0.012865346856415272, -0.005262754391878843, 0.000609411159530282, -0.019034694880247116, -0.016476672142744064, 0.002921035746112466, -0.009314210154116154, -0.007215127348899841, -0.00298310536891222, -0.008471567183732986, -0.0195914413779974, 0.03077150322496891, -0.003543613012880087, -0.02016323432326317, 0.013211431913077831, 0.0011501695262268186, -0.010262182913720608, -0.016371341422200203, -0.018854128196835518, 0.016025256365537643, 0.0010438987519592047, 0.0069630867801606655, 0.00799758080393076, -0.006372484844177961, -0.004284687340259552, 0.004397541284561157, -0.008238336071372032, -0.008388807997107506, 0.048843175172805786, -0.03250192850828171, -0.016973229125142097, -0.006729855667799711, 0.0017087964806705713, -0.00930668693035841, -0.00373922660946846, 0.01518261432647705, -0.026016591116786003, -0.0006710105808451772, -0.01569421775639057, 0.004258354660123587, -0.0025862357579171658, 0.009223926812410355, 0.006244583521038294, 0.017710542306303978, 0.002458334667608142, 0.01671742834150791, -0.01035998947918415, -0.006135491654276848, -0.010856547392904758, 0.005236421711742878, -0.007809491362422705, -0.008780035190284252, -0.025775834918022156, -0.010811405256390572, -0.014889193698763847, 0.006289725191891193, -0.0017887346912175417, -0.029041076079010963, -0.01236126571893692, 0.011134919710457325, 0.008652133867144585, -0.005168709438294172, -0.02374446578323841, -0.019561346620321274, 0.006158062256872654, -0.005225136410444975, -0.004235783591866493, -0.0032426693942397833, -0.00030541091109625995, -0.008456520736217499, 0.0026972086634486914, 0.0038896985352039337, -0.01561898272484541, 0.01918516680598259, 0.04812091216444969, 0.013143720105290413, -0.01027723029255867, 0.018688609823584557, 0.0031072446145117283, 0.020057903602719307, -0.009840861894190311, -0.015002047643065453, -0.015107378363609314, 0.0029059883672744036, 0.002121653640642762, 0.005037046503275633, 0.01353494729846716, -0.01963658258318901, -0.002057703211903572, 0.009231450967490673, -0.0075311181135475636, -0.02032875269651413, 0.02329305000603199, -0.023278001695871353, -0.026106873527169228, 0.01518261432647705, -0.030786549672484398, -0.005274039693176746, 0.0027592782862484455, 0.010976924560964108, 0.011240250431001186, 0.023172670975327492, 0.013316762633621693, 0.0223300289362669, 0.024075502529740334, -0.008953077718615532, 0.014460349455475807, 0.010555603541433811, 0.03126806020736694, 0.011435863561928272, 0.0007960903458297253, 0.011292915791273117, -0.0037279410753399134, 0.014896717853844166, 0.0016975110629573464, -0.036444291472435, -0.006541765760630369, 0.006090349983423948, 0.02672380767762661, 0.009291639551520348, -0.0207199789583683, -0.0164917204529047]" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As with everything else in CrateDB, vector similarity queries are performed using SQL. This means that they can also be combined with other query clauses. Here, we're looking for wind farms whose vectors have some similarity to our query, and only considering those wind farms that have more than 100 turbines. We'll order the results by the relative relevance score returned from `knn_match`:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
_scorenamedescription
01.585061London Array 1The London Array is a 175-turbine 630 MW Round 2 offshore wind farm located 20 kilometres (12 mi) off the Kent coast in the outer Thames Estuary in the United Kingdom. It was the largest offshore wind farm in the world until Walney Extension reached full production in September 2018. Construction of phase 1 of the wind farm began in March 2011 and was completed by mid 2013, being formally inaugurated by the Prime Minister, David Cameron on 4 July 2013. The second phase of the project was refused planning consent in 2014 due to concerns over the impact on sea birds.
11.583606Greater GabbardGreater Gabbard is a 504 MW wind farm, built on sandbanks 23 kilometres (14 mi) off the coast of Suffolk in England at a cost of £1.5 billion. It was completed on 7 September 2012 with all of the Siemens SWT3.6–107 turbines connected. Developed as a joint venture between Airtricity and Fluor, it is now jointly owned by SSE Renewables and RWE. A 336 MW extension of the wind farm called Galloper was commissioned in April 2018.
21.561188East Anglia OneEast Anglia ONE is located in the southern area of the East Anglia Zone, and is approximately 43 km (27 miles) from the shore. The initial proposal was for an installed capacity of 1200 MW. Cabling for East Anglia ONE lands near the River Deben at Bawdsey, runs north of Ipswich and is connected to the National Grid at Bramford. A plan was formally submitted to the government in December 2012, and planning consent was granted in June 2014. In October 2014 ScottishPower announced that it intended to scale down East Anglia ONE because of insufficient subsidies. In February 2015 it was announced that ScottishPower would proceed with a scaled-down 714 MW project. A contract for £119/MWh was published on 27 April 2016, using 102 Siemens Wind Power direct-drive 7 MW turbines. Nacelles were built in Cuxhaven, while blades were made in Hull. Due to water depths between 30-40m, the turbines use jacketed foundations. Cabling is at 66 kV as opposed to the traditional 33 kV. Two export cables at 220 kV AC send the power to shore. A support vessel is powered by used vegetable oil.
\n", + "
" + ], + "text/plain": [ + " _score name \\\n", + "0 1.585061 London Array 1 \n", + "1 1.583606 Greater Gabbard \n", + "2 1.561188 East Anglia One \n", + "\n", + " description \n", + "0 The London Array is a 175-turbine 630 MW Round 2 offshore wind farm located 20 kilometres (12 mi) off the Kent coast in the outer Thames Estuary in the United Kingdom. It was the largest offshore wind farm in the world until Walney Extension reached full production in September 2018. Construction of phase 1 of the wind farm began in March 2011 and was completed by mid 2013, being formally inaugurated by the Prime Minister, David Cameron on 4 July 2013. The second phase of the project was refused planning consent in 2014 due to concerns over the impact on sea birds. \n", + "1 Greater Gabbard is a 504 MW wind farm, built on sandbanks 23 kilometres (14 mi) off the coast of Suffolk in England at a cost of £1.5 billion. It was completed on 7 September 2012 with all of the Siemens SWT3.6–107 turbines connected. Developed as a joint venture between Airtricity and Fluor, it is now jointly owned by SSE Renewables and RWE. A 336 MW extension of the wind farm called Galloper was commissioned in April 2018. \n", + "2 East Anglia ONE is located in the southern area of the East Anglia Zone, and is approximately 43 km (27 miles) from the shore. The initial proposal was for an installed capacity of 1200 MW. Cabling for East Anglia ONE lands near the River Deben at Bawdsey, runs north of Ipswich and is connected to the National Grid at Bramford. A plan was formally submitted to the government in December 2012, and planning consent was granted in June 2014. In October 2014 ScottishPower announced that it intended to scale down East Anglia ONE because of insufficient subsidies. In February 2015 it was announced that ScottishPower would proceed with a scaled-down 714 MW project. A contract for £119/MWh was published on 27 April 2016, using 102 Siemens Wind Power direct-drive 7 MW turbines. Nacelles were built in Cuxhaven, while blades were made in Hull. Due to water depths between 30-40m, the turbines use jacketed foundations. Cabling is at 66 kV as opposed to the traditional 33 kV. Two export cables at 220 kV AC send the power to shore. A support vessel is powered by used vegetable oil. " + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Slide 26.\n", + "\n", + "query = f\"\"\"\n", + "SELECT \n", + " _score, name, description \n", + "FROM \n", + " windfarms \n", + "WHERE \n", + " knn_match(\n", + " description_vec, \n", + " {query_vec}, \n", + " 2) \n", + " AND turbines['howmany'] > 100\n", + "ORDER BY _score DESC\n", + "\"\"\"\n", + "\n", + "pd.read_sql(query, CONNECTION_STRING)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Continue your Learning Journey\n", + "\n", + "To learn more about CrateDB, sign up for our free courses at the CrateDB Academy. We recommend the [CrateDB Fundamentals course](https://learn.cratedb.com/cratedb-fundamentals) for a comprehensive overview, and our [Advanced Time Series course](https://learn.cratedb.com/time-series) for a deep dive into time series data modelling, queries and aggregations." + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "venv", + "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.12.2" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/topic/multi-model/multi-model-offshore-wind-farms.jpg b/topic/multi-model/multi-model-offshore-wind-farms.jpg new file mode 100644 index 00000000..15368a62 Binary files /dev/null and b/topic/multi-model/multi-model-offshore-wind-farms.jpg differ