DEV Community

f2010126
f2010126

Posted on

Predict Yacht Hydrodynamics using MindsDB

Yachts

Ships and resistance

A ship must be designed to move efficiently through the water with a minimum of external force. For thousands of years ship designers and builders of sailing vessels used rules of thumb based on the midship-section area to size the sails for a given vessel. But with the advances in steam power and construction of large iron ships in the mid-19th century, it became clear to ship owners and builders that a more rigorous approach was needed.
Visual Representation of Residuary resistance
In modern times, for the practical evaluation of ship resistance for normal ship forms, it is usual to group wave-making resistance, form resistance, eddy resistance and frictional form resistance into one force:  residuary resistance.

Residuary resistance is formally defined as the sum of the wave-making resistance and eddy resistance that opposes the movement of a vessel through the water.

Role of Machine Learning and MindsDB

The measurement of the residuary resistance per unit weight of displacement is a complex complex task. Calculating the value from measurements of ship’s dimensions, which are easier to determine and can be achieved using regression methods.
When dealing with regression, a machine learning model like an MLP can be used to model the regression better than conventional methods.
Which is where MindsDB comes into play. It acts as a datastore as well as the selector for the correct ML model to fit and train the data. It's an all in one solution when it comes to getting Machine learning involved in your data workflow.

The goal here is to use MindsDB to predict the values of the residuary resistance per unit weight of displacement from the variables describing ship’s dimensions.

Training Data

The data is taken from the UCI Machine Learning Repository here, created by Ship Hydromechanics Laboratory, Maritime and Transport Technology Department, Technical University of Delft. The Delft data set comprises 308 full-scale experiments, which were performed at the Delft Ship Hydromechanics Laboratory. These experiments include 22 different hull forms, derived from a parent form closely related to the ‘Standfast 43’

Attributes:

Variations concern hull geometry coefficients and the Froude number:

  1. Longitudinal position of the center of buoyancy, adimensional.
  2. Prismatic coefficient, adimensional.
  3. Length-displacement ratio, adimensional.
  4. Beam-draught ratio, adimensional.
  5. Length-beam ratio, adimensional.
  6. Froude number, adimensional.
  7. Residuary resistance per unit weight of displacement, adimensional.

Development Environment

As MindsDB offers a cloud version, we can sign up here, or we could use it locally via Pip or Docker. In this tutorial, we will be using MindsDB via the cloud to highlight the ease of access.
Data files are restricted to a maximum size of 10MB.

Connecting to the datasource

For this tutorial, we connect to our database as a CSV file on the MindsDB cloud. We begin by downloading the data file here and uploading the file "yacht_hydrodynamics.csv".  Follow the guide to upload the file to MindsDB and name the table appropriately.

Training

Once named, create and train a predictor with the following command:

CREATE PREDICTOR mindsdb.yacht_model FROM files (SELECT * FROM yacht_hydrodynamics) PREDICT residuary_resistance;

The quantity to predict here is residuary_resistance.

It may take a couple of minutes for the training to complete. You can monitor the status of your model like this:


SELECT * FROM mindsdb.predictors WHERE name='yacht_model';

`

The AutoML will figure out the model, and you can use DESCRIBE to see how this model was built. MindsDB will pick the most optimised one as the result model to make the predictions.


DESCRIBE PREDICTOR mindsdb.yacht_model.model;

The query lists out the candidate models used to train the data along with other metrics like performance, and accuracy.

Describe the model

The model takes very little time to train due to the low number of training points.

Prediction

The SELECT statement fetches predictions from the model table. The data is returned on the fly and not saved.

SELECT residuary_resistance, residuary_resistance_explain FROM mindsdb.yacht_model WHERE prismatic_coeff=0.55 AND froude_no=0.181;

Predicting a query

Final thoughts

MindsDB eases the process of using ML to predict an otherwise complex problem. There are few barriers to getting started, making this a good option for novice users.

Top comments (0)