From ebe37f04dd0597c39860c36c8c01fca7a4f43844 Mon Sep 17 00:00:00 2001 From: Joy Arulraj Date: Thu, 5 Oct 2023 10:30:40 -0400 Subject: [PATCH] updates --- docs/_toc.yml | 14 +++ docs/source/usecases/classification.rst | 25 ++++ docs/source/usecases/forecasting.rst | 25 ++++ docs/source/usecases/homerental-predict.rst | 124 ------------------ docs/source/usecases/homesale-forecast.rst | 133 -------------------- 5 files changed, 64 insertions(+), 257 deletions(-) delete mode 100644 docs/source/usecases/homerental-predict.rst delete mode 100644 docs/source/usecases/homesale-forecast.rst diff --git a/docs/_toc.yml b/docs/_toc.yml index 4cad836f24..bb10004961 100644 --- a/docs/_toc.yml +++ b/docs/_toc.yml @@ -97,7 +97,11 @@ parts: ======= - file: source/usecases/forecasting.rst title: Forecasting +<<<<<<< HEAD - file: source/usecases/classification.rst +======= + - file: source/usecases/prediction.rst +>>>>>>> c317ee2f (updates) title: Classification >>>>>>> 17103d35 (updates) >>>>>>> 591a8656 (updates) @@ -118,6 +122,9 @@ parts: <<<<<<< HEAD <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) ======= - file: source/overview/connect-to-database title: Connect to Database @@ -206,9 +213,12 @@ parts: ======= <<<<<<< HEAD >>>>>>> 591a8656 (updates) +<<<<<<< HEAD ======= <<<<<<< HEAD >>>>>>> f028c383 (release: merge staging into master (#1032)) +======= +>>>>>>> c317ee2f (updates) - file: source/usecases/homesale-forecast.rst title: Home Sale Forecasting - file: source/usecases/homerental-predict.rst @@ -254,6 +264,7 @@ parts: ======= >>>>>>> 17103d35 (updates) <<<<<<< HEAD +<<<<<<< HEAD >>>>>>> 591a8656 (updates) ======= ======= @@ -439,6 +450,9 @@ parts: >>>>>>> 40a10ce1 (Bump v0.3.4+ dev) >>>>>>> 6d6a14c8 (Bump v0.3.4+ dev) >>>>>>> ae08f806 (Bump v0.3.4+ dev) +======= +>>>>>>> 591a8656 (updates) +>>>>>>> c317ee2f (updates) - caption: User Reference chapters: diff --git a/docs/source/usecases/classification.rst b/docs/source/usecases/classification.rst index bf22bc5ee3..6ff9ac88ff 100644 --- a/docs/source/usecases/classification.rst +++ b/docs/source/usecases/classification.rst @@ -10,6 +10,9 @@ Prediction <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) Run on Google Colab @@ -19,6 +22,7 @@ Prediction Download notebook ======= Run on Google Colab +<<<<<<< HEAD ======= Run on Google Colab >>>>>>> fbfc3ace (docs: updates) @@ -33,6 +37,15 @@ Prediction ======= Download notebook >>>>>>> fbfc3ace (docs: updates) +======= + + + View source on GitHub + + + Download notebook +>>>>>>> 591a8656 (updates) +>>>>>>> c317ee2f (updates)

@@ -90,13 +103,19 @@ We set the training time out to be ``3600`` seconds. <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) The :ref:`ludwig` page lists all the configurable parameters for the model training framework. ======= The :ref:`ludwig` page lists all the configurable paramters for the model training framework. >>>>>>> 591a8656 (updates) +<<<<<<< HEAD ======= The :ref:`ludwig` page lists all the configurable parameters for the model training framework. >>>>>>> 5b27053e (ran spellchecker) +======= +>>>>>>> c317ee2f (updates) This query returns the trained model: @@ -153,11 +172,17 @@ Here is the query's output: .. include:: ../shared/footer.rst <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) .. include:: ../shared/designs/design10.rst ======= >>>>>>> 591a8656 (updates) +<<<<<<< HEAD ======= .. include:: ../shared/designs/design10.rst >>>>>>> e867f37e (docs: updated images) +======= +>>>>>>> c317ee2f (updates) diff --git a/docs/source/usecases/forecasting.rst b/docs/source/usecases/forecasting.rst index 920c4be8c3..2cfabb8a72 100644 --- a/docs/source/usecases/forecasting.rst +++ b/docs/source/usecases/forecasting.rst @@ -10,6 +10,9 @@ Home Sale Forecasting <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) Run on Google Colab @@ -19,6 +22,7 @@ Home Sale Forecasting Download notebook ======= Run on Google Colab +<<<<<<< HEAD ======= Run on Google Colab >>>>>>> fbfc3ace (docs: updates) @@ -33,6 +37,15 @@ Home Sale Forecasting ======= Download notebook >>>>>>> fbfc3ace (docs: updates) +======= + + + View source on GitHub + + + Download notebook +>>>>>>> 591a8656 (updates) +>>>>>>> c317ee2f (updates)

@@ -104,13 +117,19 @@ This query returns the trained model: <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) The :ref:`forecast` page lists all the configurable parameters for the forecasting model. ======= The :ref:`forecast` page lists all the configurable paramters for the forecasting model. >>>>>>> 591a8656 (updates) +<<<<<<< HEAD ======= The :ref:`forecast` page lists all the configurable parameters for the forecasting model. >>>>>>> 5b27053e (ran spellchecker) +======= +>>>>>>> c317ee2f (updates) In the ``home_sales`` dataset, we have two different types of properties -- houses and units, and price gap between them is large. To get better forecasts, we specify the ``propertytype`` column as the ``ID`` of the time series data. @@ -162,11 +181,17 @@ Here is the query's output: .. include:: ../shared/footer.rst <<<<<<< HEAD <<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c317ee2f (updates) .. include:: ../shared/designs/design11.rst ======= >>>>>>> 591a8656 (updates) +<<<<<<< HEAD ======= .. include:: ../shared/designs/design11.rst >>>>>>> e867f37e (docs: updated images) +======= +>>>>>>> c317ee2f (updates) diff --git a/docs/source/usecases/homerental-predict.rst b/docs/source/usecases/homerental-predict.rst deleted file mode 100644 index 5339ff4eae..0000000000 --- a/docs/source/usecases/homerental-predict.rst +++ /dev/null @@ -1,124 +0,0 @@ -.. _homerental-predict: - -Home Rental Prediction -======================= - -.. raw:: html - - - - - - -
- Run on Google Colab - - View source on GitHub - - Download notebook -


- - -Introduction ------------- - -In this tutorial, we present how to use :ref:`Prediction AI Engines` in EvaDB to predict home rental prices. EvaDB makes it easy to do predictions using its built-in AutoML engines with your existing databases. - -.. include:: ../shared/evadb.rst - -.. include:: ../shared/postgresql.rst - -We will assume that the input data is loaded into a ``PostgreSQL`` database. -To load the home rental data into your database, see the complete `home rental prediction notebook on Colab `_. - -Preview the Home Sales Data -------------------------------------------- - -We use the `home rental data `_ in this usecase. The data contains eight columns: ``number_of_rooms``, ``number_of_bathrooms``, ``sqft``, ``location``, ``days_on_market``, ``initial_price``, ``neighborhood``, and ``rental_price``. - -.. code-block:: sql - - SELECT * FROM postgres_data.home_rentals LIMIT 3; - -This query previews the data in the home_rentals table: - -.. code-block:: - - +------------------------------+----------------------------------+-------------------+-----------------------+-----------------------------+----------------------------+---------------------------+---------------------------+ - | home_rentals.number_of_rooms | home_rentals.number_of_bathrooms | home_rentals.sqft | home_rentals.location | home_rentals.days_on_market | home_rentals.initial_price | home_rentals.neighborhood | home_rentals.rental_price | - |------------------------------|----------------------------------|-------------------|-----------------------|-----------------------------|----------------------------|---------------------------|---------------------------| - | 1 | 1 | 674 | good | 1 | 2167 | downtown | 2167 | - | 1 | 1 | 554 | poor | 19 | 1883 | westbrae | 1883 | - | 0 | 1 | 529 | great | 3 | 2431 | south_side | 2431 | - +------------------------------+----------------------------------+-------------------+-----------------------+-----------------------------+----------------------------+---------------------------+---------------------------+ - -Train a Home Rental Prediction Model -------------------------------------- - -Let's next train a prediction model from the home_rental table using EvaDB's ``CREATE FUNCTION`` query. -We will use the built-in :ref:`Ludwig` engine for this task. - -.. code-block:: sql - - CREATE OR REPLACE FUNCTION PredictHouseRent FROM - ( SELECT * FROM postgres_data.home_rental ) - TYPE Ludwig - PREDICT 'rental_price' - TIME_LIMIT 3600; - -In the above query, we use all the columns (except ``rental_price``) from ``home_rental`` table to predict the ``rental_price`` column. -We set the training time out to be 3600 seconds. - -.. note:: - - Go over :ref:`ludwig` page on exploring all configurable paramters for the model training frameworks. - -.. code-block:: - - +----------------------------------------------+ - | Function PredictHouseRent successfully added | - +----------------------------------------------+ - -Predict the Home Rental Price using the Trained Model ------------------------------------------------------ - -Next we use the trained ``PredictHouseRent`` to predict the home rental price. - -.. code-block:: sql - - SELECT PredictHouseRent(*) FROM postgres_data.home_rentals LIMIT 3; - -We use ``*`` to simply pass all columns into the ``PredictHouseRent`` function. - -.. code-block:: - - +-------------------------------------------+ - | predicthouserent.rental_price_predictions | - +-------------------------------------------+ - | 2087.763672 | - | 1793.570190 | - | 2346.319824 | - +-------------------------------------------+ - -We have the option to utilize a ``LATERAL JOIN`` to compare the actual rental prices in the ``home_rentals`` dataset with the predicted rental prices generated by the trained model, ``PredictHouseRent``. - -.. code-block:: sql - - SELECT rental_price, predicted_rental_price - FROM postgres_data.home_rentals - JOIN LATERAL PredictHouseRent(*) AS Predicted(predicted_rental_price) - LIMIT 3; - -Here is the query's output: - -.. code-block:: - - +---------------------------+----------------------------------+ - | home_rentals.rental_price | Predicted.predicted_rental_price | - +---------------------------+----------------------------------+ - | 2167 | 2087.763672 | - | 1883 | 1793.570190 | - | 2431 | 2346.319824 | - +------------------ --------+----------------------------------+ - -.. include:: ../shared/footer.rst diff --git a/docs/source/usecases/homesale-forecast.rst b/docs/source/usecases/homesale-forecast.rst deleted file mode 100644 index a1f08bf199..0000000000 --- a/docs/source/usecases/homesale-forecast.rst +++ /dev/null @@ -1,133 +0,0 @@ -.. _homesale-forecasting: - -Home Sale Forecasting -===================== - -.. raw:: html - - - - - - -
- Run on Google Colab - - View source on GitHub - - Download notebook -


- - -Introduction ------------- - -In this tutorial, we present how to use :ref:`Forecasting AI Engines` in EvaDB to predict home sale price. EvaDB makes it easy to do time series predictions using its built-in Auto Forecast function. - -.. include:: ../shared/evadb.rst - -.. include:: ../shared/postgresql.rst - -We will assume that the input data is loaded into a ``PostgreSQL`` database. -To load the home sales data into your database, see the complete `home sale forecasting notebook on Colab `_. - -Preview the Home Sales Data -------------------------------------------- - -We use the `raw_sales.csv of the House Property Sales Time Series `_ in this usecase. The data contains five columns: ``postcode``, ``price``, ``bedrooms``, ``datesold``, and ``propertytype``. - -.. code-block:: sql - - SELECT * FROM postgres_data.home_sales LIMIT 3; - -This query previews the data in the home_sales table: - -.. code-block:: - - +---------------------+------------------+---------------------+---------------------+-------------------------+ - | home_sales.postcode | home_sales.price | home_sales.bedrooms | home_sales.datesold | home_sales.propertytype | - |---------------------|------------------|---------------------|---------------------|-------------------------| - | 2607 | 525000 | 4 | 2007-02-07 | house | - | 2906 | 290000 | 3 | 2007-02-27 | house | - | 2905 | 328000 | 3 | 2007-03-07 | house | - +---------------------+------------------+---------------------+---------------------+-------------------------+ - -Train a Home Sale Forecasting Model ------------------------------------ - -Let's next train a time-series forecasting model from the home_sales table using EvaDB's ``CREATE FUNCTION`` query. -Particularly, we are interested in the price of the properties that have three bedrooms and are in the postcode 2607 area. - -.. code-block:: sql - - CREATE FUNCTION IF NOT EXISTS HomeSaleForecast FROM - ( - SELECT propertytype, datesold, price - FROM postgres_data.home_sales - WHERE bedrooms = 3 AND postcode = 2607 - ) - TYPE Forecasting - PREDICT 'price' - TIME 'datesold' - ID 'propertytype' - FREQUENCY 'W'; - -In the ``home_sales`` dataset, we have two different property types, houses and units, and price gap between them are large. -We'd like to ask EvaDB to analyze the price of houses and units independently. -To do so, we specify the ``propertytype`` column as the ``ID`` of the time series data, which represents an identifier for the series. -Here is the query's output ``DataFrame``: - -.. note:: - - Go over :ref:`forecast` page on exploring all configurable paramters for the forecast model. - -.. code-block:: - - +----------------------------------------------+ - | Function HomeSaleForecast successfully added | - +----------------------------------------------+ - -Predict the Home Price using the Trained Model ----------------------------------------------- - -Next we use the trained ``HomeSaleForecast`` to predict the home sale price for next 3 weeks. - -.. code-block:: sql - - SELECT HomeSaleForecast(3); - -The input of the trained model is the horizon (i.e., week in this case), the steps we want to forecast in the future. Here is the query's output ``DataFrame``: - -.. code-block:: - - +-------------------------------+---------------------------+------------------------+ - | homesaleforecast.propertytype | homesaleforecast.datesold | homesaleforecast.price | - +-------------------------------+---------------------------+------------------------+ - | house | 2019-07-21 | 766572 | - | house | 2019-07-28 | 766572 | - | house | 2019-08-04 | 766572 | - | unit | 2018-12-23 | 417229 | - | unit | 2018-12-30 | 409601 | - | unit | 2019-01-06 | 402112 | - +-------------------------------+---------------------------+------------------------+ - -We can further use ``ORDER BY`` to find out which month in the following year has the lower price. - -.. code-block:: sql - - SELECT * - FROM (SELECT HomeSaleForecast(12)) AS HomeSale - ORDER BY price - LIMIT 1; - -Here is the query's output: - -.. code-block:: - - +-----------------------+-------------------+----------------+ - | HomeSale.propertytype | HomeSale.datesold | HomeSale.price | - +-----------------------+-------------------+----------------+ - | unit | 2019-03-10 | 340584 | - +-----------------------|-------------------|----------------| - -.. include:: ../shared/footer.rst