Logo

dev-resources.site

for different kinds of informations.

Predicting & Visualizing Petroleum Production with MindsDB and Tableau

Published at
10/31/2022
Categories
mindsdb
hacktoberfest
machinelearning
ai
Author
tesprogram
Author
10 person written this
tesprogram
open
Predicting & Visualizing Petroleum Production with MindsDB and Tableau

Introduction

MindsDB is an open-source machine-learning tool that brings automated machine learning to your database. MindsDB offers predictive capabilities in your database. Tableau lets you visualize your data easily and intuitively. In this tutorial, we will be using MindsDB to predict the hourly electricity demand in the United States and visualize results in Tableau. To complete this tutorial, you are required to have a working MindsDB connection, either locally or viaĀ cloud.mindsdb.com. You can use thisĀ guideĀ to connect to the MindsDB cloud.

Data Setup

Connecting the data as a file

Follow the steps below to upload a file to MindsDB Cloud.

  • Log in to yourĀ MindsDB CloudĀ account to open the MindsDB Editor.
  • Navigate toĀ Add dataĀ the section by clicking theĀ Add dataĀ button located in the top right corner.

File Upload into MindsDB

  • Choose the Files tab.

Choose the Files tab

  • Choose theĀ Import FileĀ option.
  • Upload a file ([national_nameplate_capacity.csv](https://www.kaggle.com/datasets/maurosrgiofigueira/fuel-output-capacity-brazil), name a table used to store the file data (here it ispetroleum_productionĀ ), and click theĀ Save and Continue`Ā button.

File upload
Once you are done uploading, you can query the data directly with;

sql
SELECT * FROM files.petroleum_production LIMIT 10;

The output would be:

Table Query Output

Understanding the Dataset

This dataset presents Brazilian petroleum products ouput capacity evolution, from 2011 to 2020 in each Brazilian refinery. Data is displayed in barrels. From the Brazilian National Petroleum Agency.

Context

  • Refinery - They are 19 refinery in this dataset.
  • Year - The year of this dataset ranges from 2011 to 2020.
  • Nameplate Capacity - Nameplate capacity, also known as theĀ rated capacity,Ā nominal capacity ,Ā installed capacity, orĀ maximum effect, is the intended full-load sustained output of a facility such as aĀ power station, fuel plant and etc. (Source: Wikipedia)

Creating the Predictor

To being, letā€™s create a predictor that uses the date to predict the Petroleum Production for refineries. You can learn more about creating a predictor by checkingĀ here. You can predict a classification series model using the following syntax

sql
CREATE PREDICTOR mindsdb.[predictor_name]
FROM [integration_name]
(SELECT [sequential_column], [partition_column], [other_column], [target_column]
FROM [table_name])
PREDICT [target_column]

  • CREATE PREDICTOR: Creates a predictor with the nameĀ predictor_nameĀ in theĀ mindsdbĀ table.
  • FROM files: Points to the table containing the data.
  • PREDICT: Dictates the column to predict.

`sql
CREATE PREDICTOR mindsdb.petroleum_output
FROM files (SELECT refinery, Year, Nameplate_Capacity FROM petroleum_production)
PREDICT Nameplate_Capacity

`

On execution we get:


Query successfully completed

Status of a Predictor

A predictor may take a couple of minutes for the training to complete. You can monitor the status of the predictor by using this SQL command:

sql
SELECT status
FROM mindsdb.predictors
WHERE name='petroleum_output';

Your output should be:

sql
+------------+
| status |
+------------+
| complete |
+------------+

Making Predictions

Now that we have our Prediction Model, we can simply execute some simple SQL query statements to predict the target value based on the feature parameters:

sql
SELECT Year, Nameplate_Capacity
FROM mindsdb.petroleum_output
JOIN files.petroleum_production
LIMIT 100;

Predictions Query Output

Connecting MindsDB to Tableau

Tableau lets you visualize your data easily and intuitively. In this tutorial will use Tableau to create visualizations of our predictions.

How to Connect

  • First, create a new workbook in Tableau and open theĀ ConnectorsĀ tab in theĀ Connect to DataĀ window.
  • Click on MySQL

Connecting MindsDB to Tableau

ā€¢ Input ā€œcloud.mindsdb.comā€ for Server, ā€œ3306ā€ for Port, ā€œmindsdbā€ for Database ā€œyour mindsdb cloud emailā€ for Username, ā€œyour mindsdb cloud passwordā€ for Password, and Sign in.
Inputting Details for connection
Now you are connected and your page should look like this:

Done connecting

Visualizing our Data

Before you can visualize predictions in Tableau, you must first choose a data source. And because the predictions in this article are generated using a SQL statement, you will need to create a custom SQL query in Tableau to generate the data source. To do this:

  • First, select theĀ New Custom SQLon the left side of the window and use the query below to generate the petroleum production for each year. You can preview the results or directly load the data into Tableau.

sql
SELECT Year, Nameplate_Capacity
FROM mindsdb.petroleum_output
JOIN files.petroleum_production

Custom SQL Query

  • Create an extract of the data under the connection heading at the top right of the window. You do this to facilitate data conversion to the appropriate data type. The extraction should take some time.
  • Move to the Sheet tab on the bottom left and right-click on the Nameplate_Capacity and Year to convert their data types to Number(whole) and Date, respectively. Additionally, when right-clicking on the Nameplate_Capacity and Date, choose the option to convert it to a continuous measure.

Changing Data Type
Changing Data Type
Changing Data Type

  • Drag the Nameplate_Capacity measure to the row shelf and the Year dimension to the column shelf. Visualization in Tableau
  • You can also switch the visualization also to line, area and etc. Final Visualization

Whatā€™s Next?

Have fun while trying it out yourself!

Give a like or a comment if this tutorial was helpful

mindsdb Article's
30 articles in total
Favicon
What is a Mind
Favicon
Mind Your Manners: How Politeness Can Make AI Smarter
Favicon
AutoGenius: AI-Powered Car Valuation and Trading Assistant
Favicon
How to build your Developer Portfolio with MindsDB: The symbiotic relationship between developers and Opensource in 2024.
Favicon
Deploying a MindsDB-powered PostgreSQL database on Vercel
Favicon
AI-Powered Selection of Asset Management Companies using MindsDB and LlamaIndex
Favicon
Using Large Language Models inside your database with MindsDB
Favicon
Measure Customer Support Sentiment Analysis with GPT, Airbyte and MindsDB
Favicon
Harnessing the Dual LLM Pattern for Prompt Security with MindsDB
Favicon
Unveiling the Dark Side of AI: How Prompt Hacking Can Sabotage Your AI Systems
Favicon
How to add AI image generation to your application
Favicon
Introducing MindsDB Playground: Your all-in-one MindsDB Companion App
Favicon
How to Make a Gmail Bot with a persona using OpenAI GPT and MindsDB
Favicon
Tutorial to Predict the Type of Glass using MongoDB
Favicon
Tutorial to Predict the Rating of Cars using Mindsdb and MongoDB
Favicon
Tutorial to Predict Gold Prices using Mindsdb and MongoDB
Favicon
How Developers should take advantage of MindsDB's Integration with OpenAI Chat GPT-3
Favicon
Tutorial to Predict the Energy Usage using MindsDB and MongoDB
Favicon
Extract Insights from Text Data inside Databases using OpenAI GPT-3 and MindsDB Integration
Favicon
Classify and label text in your database with Hugging Face and MindsDB integration
Favicon
How to predict purchase intent using SQL
Favicon
Everything You Need to Know about Open-Source Predictive Analytics Platform MindsDB
Favicon
Predicting gold prices with MindsDB and MongoDB
Favicon
Using MindsDB for Time Series Forecasting - Honey Production in the USA
Favicon
Predict Diamond prices with SQL Alchemy and MindsDB
Favicon
Tutorial to Predict the Weather Using MindsDB and MongoDB
Favicon
Predicting Environment Impact of Food Production caused by C02 Emission
Favicon
Predicting & Visualizing Gas Prices with MindsDB and Tableau
Favicon
Predicting & Visualizing Petroleum Production with MindsDB and Tableau
Favicon
Tutorial to Predict the Genre of Books using MindsDB [Mongo API]

Featured ones: