In this example we use VerbaGPT to create and compare a neural network model to linear regression while using the famous Abalone dataset 1. We then ask it to generate a report for us.
Video:
User question: Give me a neural network and a linear regression model to predict rings. Compare their performance.
VerbaGPT response: ![]()
Cost of query: $0.00
Neural Network MSE: 4.49
Linear Regression MSE: 5.00
VerbaGPT answers the question correctly and gives us the analysis that we asked for. We then use the magic command “report>” to generate a fairly comprehensive report on our analysis.
Note: the report is amazingly comprehensive in this example only because we are using a very famous publicly available dataset. The intent of this example is to demonstrate what an large language model (LLM) can achieve. VerbaGPT prioritizes data privacy and the LLM has no access to the data, so in other cases the report will not be at this level of detail.
VerbaGPT is a simple yet powerful way to analyze your data. A user can ask any kind of similar question in natural language, and the app does the work to add context, and normalize inputs and outputs so they have a better chance of producing a useful outcome. Check out the full VerbaGPT read-out by click on below.
VerbaGPT Message Window
import pandas as pd
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.neural_network import MLPRegressor
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error
# Load data from MS SQL database
query = "SELECT * FROM d_Abalone"
data = pd.read_sql(query, conn)
# Preprocess data
data = pd.get_dummies(data, columns=['Sex'])
X = data.drop('Rings', axis=1)
y = data['Rings']
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=0)
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)
# Train and evaluate neural network model
nn_model = MLPRegressor(hidden_layer_sizes=(100,), max_iter=1000)
nn_model.fit(X_train, y_train)
nn_pred = nn_model.predict(X_test)
nn_mse = mean_squared_error(y_test, nn_pred)
print(f'Neural Network MSE: {nn_mse}')
# Train and evaluate linear regression model
lr_model = LinearRegression()
lr_model.fit(X_train, y_train)
lr_pred = lr_model.predict(X_test)
lr_mse = mean_squared_error(y_test, lr_pred)
print(f'Linear Regression MSE: {lr_mse}')
# Compare performance of models
if nn_mse < lr_mse:
print('Neural Network has better performance')
else:
print('Linear Regression has better performance')
VerbaGPT Report
Abalone Age Prediction Using Machine Learning
Introduction
The goal of this project is to predict the age of abalones (a type of marine snail) based on their physical characteristics, such as length, diameter, height, weight, and sex. The age of an abalone is determined by the number of rings on its shell, which can be counted under a microscope. However, this is a tedious and time-consuming process, so it would be useful to have a machine learning model that can estimate the age from the other features.
Data
The data used for this project comes from the UCI Machine Learning Repository[^1^ It contains 4177 observations of abalones, with 8 attributes:
- Sex: nominal; M (male), F (female), I (infant)
- Length: continuous; longest shell measurement (in mm)
- Diameter: continuous; perpendicular to length (in mm)
- Height: continuous; with meat in shell (in mm)
- Whole weight: continuous; whole abalone (in grams)
- Shucked weight: continuous; weight of meat (in grams)
- Viscera weight: continuous; gut weight after bleeding (in grams)
- Shell weight: continuous; after being dried (in grams)
- Rings: integer; +1.5 gives the age in years
The data was loaded from a MS SQL database using the pandas library in Python. The sex attribute was converted into dummy variables using the pd.get_dummies function. The target variable was the rings attribute, and the rest were used as predictors. The data was split into training and testing sets, with 80% of the data for training and 20% for testing. The predictor variables were scaled using the StandardScaler class from the scikit-learn library.
Models
Two machine learning models were trained and evaluated on the data: a neural network and a linear regression. The neural network was implemented using the MLPRegressor class from scikit-learn, with one hidden layer of 100 neurons and a maximum of 1000 iterations. The linear regression was implemented using the LinearRegression class from scikit-learn. Both models were fitted on the training data and used to make predictions on the testing data. The performance metric used to compare the models was the mean squared error (MSE), which measures the average squared difference between the actual and predicted values.
Results
The results of running the code are shown below:
Neural Network MSE: 4.490159956140617
Linear Regression MSE: 5.006878548779924
Neural Network has better performance
The neural network model achieved a lower MSE than the linear regression model, indicating that it was able to capture the nonlinear relationship between the predictors and the target better than the linear model. Therefore, the neural network model is preferred for this task.
Conclusion
In this project, a neural network model and a linear regression model were trained and evaluated on a dataset of abalone characteristics and age. The neural network model outperformed the linear regression model in terms of MSE, suggesting that it is more suitable for predicting the age of abalones from their physical features.

Leave a Reply