Database connection and processing data through supervised and unsupervised learning.
In Artificial Intelligence achieved through Java part 2 we created the database and its tables. In part 3 of this tutorial, we will add columns and data to the database, initializing memory and thought patterns in the brain of our AI sport-bot. Lastly start to build an understanding of the two forms of machine learning, supervised and unsupervised learning.
Lastly, we will look at of the two forms of machine learning, supervised and unsupervised learning.
Creating the database columns
We are only going to populate certain database tables with new columns, we will create columns for the outstanding table’s as we progress through this tutorial series. In order to save time, I will describe the process for creating one of the columns in a table in the sportbot database, then list the columns that need to be created in their corresponding table with their required column type and any additional required configuration information. Open pgAdmin and let’s get started.
Creating a new column
-Expand Tables then expand the players table
-Right click on columns and click New column…
Enter column properties
-Name: id
-Data Type: bigint
Repeat the step 1 and 2 and create the following columns in their respective tables
Table players:
– column name: sport_type , data type: bigint
– column name: name , data type: character varying , length: 256
– column name: surname , data type: character varying , length: 256
Table sport_type:
– column name: id , data type: bigint
– column name: sport , data type: character varying , length: 256
Table teams:
– column name: id , data type: bigint
– column name: sport , data type: character varying , length: 256
– column name: sport_type , data type: bigint
Create constraints
– Right click on the players table
– Click properties
– Click on the constraints tab
– add a primary key and set the id column as the primary key
Repeat step 4 and create the following constraints in their respective tables
NOTE : you will have to set the primary key constraints first on all the tables before you can set the foreign key relationships.
Table sport_type:
-Primary key on id column
Table players:
-Primary key on id column
-Foreign key sport_type column references sport_type table’s id column
Table teams:
-Primary key on id column
-Foreign key sport_type column references sport_type table’s id column
-If you are unfamiliar with the concept of constraints you can find more information at postgresql constraints
Building knowledge through data
We have now set up the foundation to provide our sport-bot with data on different sports types, player’s and teams. The first objective we want to achieve is to enable our sport-bot to have knowledge of a sports type, the teams in that sports type and the players in those teams. In order to achieve this goal, we must add data to these tables.
Each year soccer receives massive support globally with one of the most followed leagues in the sport being the premier league. The first data we are going to provide our sport-bot database is the sports type soccer with the top 2 teams Leicester City and Arsenal and each team’s players in the premier league.
For the sake of saving time and to spare you from the tedious task of manually entering the date into the database, I have created a database backup including all the data already that can be downloaded from github.com/sport-bot
If you do not know how to perform a database backup in pgAdmin you can use the following tutorial: pdAdmin DB restore
Supervised and unsupervised Learning in artificial intelligent systems
Supervised and unsupervised learning refers to two methods by which AI systems learn from data being provided determined by mathematical algorithms.
In supervised learning, the output datasets are provided which are used to train the machine and get the desired outputs whereas in unsupervised learning no datasets are provided, instead, the data is clustered into different classes by forming patterns in the data.
An example of unsupervised learning is Google’s news feed, clustering news headlines trending on the web without a provided dataset. For our project, we will use supervised learning and unsupervised learning in coming tutorials.
In the next tutorial, we will connect our maven sport-bot to our database and start looking at the math involved in supervised learning and applying that math though java algorithms.