DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Predicting Ad Viewability With XGBoost Regressor Algorithm
  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm
  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • Discover Hidden Patterns with Intelligent K-Means Clustering

Trending

  • 7 Technology Waves I’ve Seen in 30 Years of Software — Will AI Be the Next Real Transformation?
  • 5 Common Security Pitfalls in Serverless Architectures
  • Chaos Engineering Has a Blind Spot. Agentic AI Lives in It.
  • Every Cache Miss Is a Tiny Tax on Your Performance
  1. DZone
  2. Data Engineering
  3. AI/ML
  4. Classification With XGBoost Algorithm in a Database

Classification With XGBoost Algorithm in a Database

Oracle 21c features support for the hot new ML algorithm on the block.

By 
Emrah Mete user avatar
Emrah Mete
·
Jan. 03, 21 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
5.7K Views

Join the DZone community and get the full member experience.

Join For Free

In this article, we will look at how to apply the XGBoost algorithm, one of the most popular ensemble learner methods, in a database. Hopefully, it will be a useful study in terms of awareness.

Advanced analytical applications can be developed using machine learning algorithms in Oracle database software since version 9i. As the database versions are renewed, new ones are added to these algorithm options. The current algorithm list that comes with Oracle 19c version is as follows.

Oracle machine learning algorithms

With Oracle 21c, new algorithms have been added to this list. Undoubtedly, the most interesting of these algorithms was the XGBoost algorithm, one of the industry's most frequently used ensemble methods. XGBoost, which has proved its learning capacity with its success in ML competitions opened over Kaggle, is now ready for use in the Oracle database.

Let's create an XGBoost model with Oracle 21c and test how it is used. To do this test, I will revive an Autonomous Data Warehouse service that comes with Oracle 21c version on Oracle Cloud Infrastructure.

Oracle database information

In this example, I will solve a classification problem, but it should not be forgotten that it will be done in regression with this infrastructure and algorithm. The dataset I will use will be Iris. After downloading the data set, I upload it to the database via the SQL Developer web interface.

SQL
 




x


 
1
CREATE TABLE ADMIN.IRIS 
2
    ( 
3
     sepal_length FLOAT , 
4
     sepal_width  FLOAT , 
5
     petal_length FLOAT , 
6
     petal_width  FLOAT , 
7
     class        VARCHAR2(4000) 
8
    ) ;



We have loaded our data into the database, so now we can go to the editing part of our model.

We create a table to determine the algorithm parameters. We will write the parameters that will run the algorithm in this table to be used later.

PLSQL
 




xxxxxxxxxx
1
25


 
1
CREATE TABLE ADMIN.ALGO_VARIABLES (
2
    SETTING_NAME   VARCHAR2(4000),
3
    SETTING_VALUE  VARCHAR2(4000)
4
);
5

          
6
BEGIN
7
    
8
  INSERT INTO ADMIN.ALGO_VARIABLES (setting_name, setting_value) VALUES
9
    (dbms_data_mining.xgboost_objective, 'multi:softprob');
10

          
11
  INSERT INTO ADMIN.ALGO_VARIABLES (setting_name, setting_value) VALUES
12
    (dbms_data_mining.algo_name, dbms_data_mining.algo_xgboost);
13

          
14
  INSERT INTO ADMIN.ALGO_VARIABLES (setting_name, setting_value) VALUES
15
    (dbms_data_mining.xgboost_max_depth, '3');
16

          
17
  INSERT INTO ADMIN.ALGO_VARIABLES (setting_name, setting_value) VALUES
18
    (dbms_data_mining.xgboost_eta, '1');
19

          
20
  INSERT INTO ADMIN.ALGO_VARIABLES (setting_name, setting_value) VALUES
21
    (dbms_data_mining.xgboost_num_round, '5');
22

          
23
COMMIT;
24
    
25
END;



I have set my algorithm parameters. You can access detailed information about these parameters and options by following the link.

We loaded the data and set the values of our algorithm parameters. Now we can move on to the training phase.

PLSQL
 




xxxxxxxxxx
1
16


 
1
BEGIN
2
    DBMS_DATA_MINING.CREATE_MODEL(
3
                                 MODEL_NAME           => 'XGBoost_Model',
4
                                 MINING_FUNCTION      => DBMS_DATA_MINING.CLASSIFICATION,
5
                                 DATA_TABLE_NAME      => 'iris',
6
                                 CASE_ID_COLUMN_NAME  =>  NULL,
7
                                 TARGET_COLUMN_NAME   => 'class',
8
                                 SETTINGS_TABLE_NAME  => 'algo_variables'
9
    );
10
END;
11
    
12
SELECT *
13
  FROM user_mining_model_attributes
14
 WHERE model_name = 'XGBOOST_MODEL'
15
ORDER BY attribute_name;


Now let's move on to testing the model we developed. We can use the model in two ways. One of these might be to predict all the values in a table.

SQL
 




xxxxxxxxxx
1


 
1
select 
2
   PETAL_LENGTH,PETAL_WIDTH,SEPAL_LENGTH,SEPAL_WIDTH,
3
   prediction (XGBOOST_MODEL using *) prediction
4
from iris_test t ;


The other might be to guess for a single record.


Database Algorithm XGBoost Machine learning

Opinions expressed by DZone contributors are their own.

Related

  • Predicting Ad Viewability With XGBoost Regressor Algorithm
  • Building a High-Throughput Distributed Sequence Generator Using the Hi-Lo Algorithm
  • The Quantum Computing Mirage: What Three Years of Broken Promises Have Taught Me
  • Discover Hidden Patterns with Intelligent K-Means Clustering

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook