A Demonstration of Artificial Intelligence for Beginners
Introduction
predicted_measurement_a = prediction_coefficient x measurement_b
Once you understand this equation as it applies to artificial intelligence, you will have a solid foundation for understanding the basic functions of artificial intelligence systems like ChatGPT.
The basic functions are:
1. prediction
2. preparation of the system for prediction
To aid understanding of the equation and functions is the purpose of the following demonstration of a very simple artificial intelligence system. Systems like ChatGPT -- although far more complex -- were developed from this type of system.
The Demonstration Part 1
Consider the following data:
length height
23.2 11.52
26.8 13.6
27.6 14.0
28.4 14.26
28.5 14.23
28.7 14.37
29.4 14.95
30.9 15.63
31.4 15.99
31.5 15.52
31.9 16.24
32 16.36
32.7 16.52
37.4 18.64
It's length and height data in centimeters for a group of fish (Bream). In addition to giving information about the fish, the data can also be used to create an equation to predict the height of other Bream using the length of the fish, i.e., the prediction function of the system. The equation is the one given above:
predicted_measurement_a = prediction_coefficient x measurement_b
To deal with the fish data, it is better expressed as:
predicted_height = prediction_coefficient x length
The following are the calculations done by this very simple AI system to produce a value for prediction_coefficient of .5037 and the following equation:
predicted_height = .5037 x length
The calculations are the second of the basic functions in every AI system, i.e., the preparation of the system for prediction.
The Calculations
Take the first record in the data:
length height
23.2 11.52
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0
length = 23.2
Here is the arithmetic:
predicted_height = 0 x 23.2
= 0.0
Next get the amount of error in the prediction using this equation:
error = actual_height - predicted_height
with these values:
actual_height = 11.52
predicted_height = 0.0
Here is the arithmetic:
error = 11.52 - 0.0
= 11.52
Next try to improve the value for prediction_coefficient using this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0
adjustment_factor = 0.001 (The adjustment_factor regulates the amount by which the prediction_coefficient is changed in the effort to improve it. It is established by experiment.)
error = 11.52
Here is the arithmetic:
prediction_coefficient = 0 + 0.001 x 11.52
= 0.0115
These are the only calculations for getting the prediction coefficient! If you do them for every record in the set of records and then keep doing it until the value for error no longer decreases, the prediction_coefficient will become .5037, giving the equation for predicting fish height from fish length:
predicted_height = .5037 x length
Here is a summary of the process:
begin loop
load records
begin loop
get next record
predicted_height = prediction_coefficient x length
error = actual_height - predicted_height
prediction_coefficient = prediction_coefficient +
learning_rate x error
end loop
quit if error has not decreased
end loop
The Demonstration Part 2
If you're curious about what the next few sets of calculations look like, here are the next 5 of them. If not, skip to Part 3, which gives the last set of calculations and concludes the article.
Take the next record in the data:
length height
26.8 13.6
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0.0115
length = 26.8
Here is the arithmetic:
predicted_height = 0.0115 x 26.8
= 0.3082
Next get the amount of error in the prediction:
error = actual_height - predicted_height
with these values:
actual_height = 13.6
predicted_height = 0.3082
Here is the arithmetic:
error = 13.6 - 0.3082
= 13.2918
Next try to improve the value for prediction_coefficient with this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0.0115
adjustment_factor = 0.001
error = 13.2918
Here is the arithmetic:
prediction_coefficient = 0.0115 + 0.001 x 13.2918
= 0.0248
------------------
Take the next record in the data:
length height
27.6 14.0
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0.0248
length = 27.6
Here is the arithmetic:
predicted_height = 0.0248 x 27.6
= 0.6845
Next get the amount of error in the prediction:
error = actual_height - predicted_height
with these values:
actual_height = 14.0
predicted_height = 0.6845
Here is the arithmetic:
error = 14.0 - 0.6845
= 13.3155
Next try to improve the value for prediction_coefficient with this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0.0248
adjustment_factor = 0.001
error = 13.3155
Here is the arithmetic:
prediction_coefficient = 0.0248 + 0.001 x 13.3155
= 0.0381
------------------
Take the next record in the data:
length height
28.4 14.26
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0.0381
length = 28.4
Here is the arithmetic:
predicted_height = 0.0381 x 28.4
= 1.082
Next get the amount of error in the prediction:
error = actual_height - predicted_height
with these values:
actual_height = 14.26
predicted_height = 1.082
Here is the arithmetic:
error = 14.26 - 1.082
= 13.178
Next try to improve the value for prediction_coefficient with this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0.0381
adjustment_factor = 0.001
error = 13.178
Here is the arithmetic:
prediction_coefficient = 0.0381 + 0.001 x 13.178
= 0.0513
------------------
Take the next record in the data:
length height
28.5 14.23
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0.0513
length = 28.5
Here is the arithmetic:
predicted_height = 0.0513 x 28.5
= 1.462
Next get the amount of error in the prediction:
error = actual_height - predicted_height
with these values:
actual_height = 14.23
predicted_height = 1.462
Here is the arithmetic:
error = 14.23 - 1.462
= 12.768
Next try to improve the value for prediction_coefficient with this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0.0513
adjustment_factor = 0.001
error = 12.768
Here is the arithmetic:
prediction_coefficient = 0.0513 + 0.001 x 12.768
= 0.0641
------------------
Take the next record in the data:
length height
28.7 14.37
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0.0641
length = 28.7
Here is the arithmetic:
predicted_height = 0.0641 x 28.7
= 1.8397
Next get the amount of error in the prediction:
error = actual_height - predicted_height
with these values:
actual_height = 14.37
predicted_height = 1.8397
Here is the arithmetic:
error = 14.37 - 1.8397
= 12.5303
Next try to improve the value for prediction_coefficient with this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0.0641
adjustment_factor = 0.001
error = 12.5303
Here is the arithmetic:
prediction_coefficient = 0.0641 + 0.001 x 12.5303
= 0.0766
The Demonstration Part 3
Here's what the last of the calculations looks like:
Take the next record in the data:
length height
37.4 18.64
Get a prediction for the height using this equation:
predicted_height = prediction_coefficient x length
with these values:
prediction_coefficient = 0.5039
length = 37.4
Here is the arithmetic:
predicted_height = 0.5039 x 37.4
= 18.8459
Next get the amount of error in the prediction:
error = actual_height - predicted_height
with these values:
actual_height = 18.64
predicted_height = 18.8459
Here is the arithmetic:
error = 18.64 - 18.8459
= -0.2059
Next try to improve the value for prediction_coefficient with this equation:
prediction_coefficient = prediction_coefficient + adjustment_factor x error
with these values:
prediction_coefficient = 0.5039
adjustment_factor = 0.001
error = -0.2059
Here is the arithmetic:
prediction_coefficient = 0.5039 + 0.001 x -0.2059
= 0.5037
The total number of calculations needed to produce the prediction coefficient of .5037 is 757. Doing the calculations by hand would take most of us a day or so. Using a fast desktop it would take a few seconds. Using the ChatGPT computer, the time shrinks to less than a nanosecond.
Tom Arnall
Eureka, CA
kloro2006@gmail.com
I want to improve this article. Please send me your comments to help me do it.