{"id":46685,"date":"2022-02-10T00:00:00","date_gmt":"2022-02-10T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/"},"modified":"2025-11-13T12:55:49","modified_gmt":"2025-11-13T20:55:49","slug":"how-to-implement-a-decision-tree-algorithm-in-java","status":"publish","type":"post","link":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/","title":{"rendered":"How to Implement a Decision Tree Algorithm in Java"},"content":{"rendered":"<p>The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that serve as support systems in many fields. These methods have acquired the importance to become vital in different sectors and industries.<\/p>\n<p>This article describes the implementation of a decision tree algorithm in Java. The article begins by describing the dataset used in this article. Later, the implementation of the algorithm using the Weka J48 decision tree is presented. After that, we describe different interactions with GridDB, which is our main database. In this case, we write the original dataset into GridDB, we store the data, and we retrieve it for its later use to build the decision tree.<\/p>\n<h1>Requirements<\/h1>\n<p>In this section we describe the requirements and configuration used in this article.<\/p>\n<p>Weka 3.9: Download and place weka.jar file in the <em>\/usr\/share\/java\/<\/em> path.<\/p>\n<p>GridDB 4.6: After installation, a GridDB cluster has to be active.<\/p>\n<p>Make sure to add the Weka library path to CLASSPATH. We perform the same operation for GridDB. Here are the corresponding command lines:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">$ export CLASSPATH=${CLASSPATH}:\/usr\/share\/java\/weka.jar\n$ export CLASSPATH=$CLASSPATH:\/usr\/share\/java\/gridstore.jar<\/code><\/pre>\n<\/div>\n<h1>The dataset<\/h1>\n<p>For the purpose of this article we have chosen to use a dataset for the iris plant. This dataset is open source and available <a href=\"https:\/\/gist.github.com\/myui\/143fa9d05bd6e7db0114\">here<\/a>.The dataset is composed of 149 entries with 5 attributes, that are described as follows:<\/p>\n<ol>\n<li>Sepal length in cm. Measures the sepal length of an Iris plant sample<\/li>\n<li>Sepal width in cm. Measures the sepal width of an Iris plant sample <\/li>\n<li>Petal length in cm. Measures the petal length of an Iris plant sample <\/li>\n<li>Petal width in cm. Measures the pepal width of an Iris plant sample <\/li>\n<li>Class: Indicates the Iris subspecies. The possible values are: Iris Setos, Iris Versicolour, Iris Virginica.<\/li>\n<\/ol>\n<p>Here is an extract of the dataset:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">4.6,3.2,1.4,0.2,Iris-setosa\n5.3,3.7,1.5,0.2,Iris-setosa\n5.0,3.3,1.4,0.2,Iris-setosa\n7.0,3.2,4.7,1.4,Iris-versicolor\n6.4,3.2,4.5,1.5,Iris-versicolor<\/code><\/pre>\n<\/div>\n<p>The dataset is presented in the form of a .CSV file, that is readed, parsed and temporarily placed in variables for its future storage in a GridDB collection. The following code performs these operations:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">\/\/ Handlig Dataset and storage to GridDB\n            File data = new File(\"\/home\/ubuntu\/griddb\/gsSample\/iris.csv\");\n            Scanner sc = new Scanner(data);  \n            sc.useDelimiter(\"n\");\n            while (sc.hasNext())  \/\/returns a boolean value  \n            {  \n            Row row = collection.createRow();\n\n            String line = sc.next();\n            String columns[] = line.split(\",\");\n            float slenght = Float.parseFloat(columns[0]);\n            float swidth = Float.parseFloat(columns[1]);\n            float plenght = Float.parseFloat(columns[2]);\n            float pwidth = Float.parseFloat(columns[3]);\n            String irisclass = columns[4];\n            }<\/code><\/pre>\n<\/div>\n<p>Do not forget to close your scanner when finished!<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> sc.close();<\/code><\/pre>\n<\/div>\n<p>The decision tree is implemented in order to predict the Iris subspecies according to the petal and sepal dimensions. In the following section, we describe the implementation of a decision tree in Java.<\/p>\n<h1>Implementing a Decision Tree Algorithm in Java<\/h1>\n<p>As mentioned in earlier sections, this article will use the J48 decision tree available at the Weka package. This class generates pruned or unpruned C4.5 decision trees. Let\u2019s have a closer look at the implementation. We begin by importing the required packages for Weka:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import weka.core.Instances;\nimport weka.core.converters.ConverterUtils.DataSource;\nimport weka.classifiers.trees.J48;\nimport weka.classifiers.Evaluation;<\/code><\/pre>\n<\/div>\n<p>The J48 decision tree algorithm has a series of attributes that can be fine tuned to match the dataset with the algorithm. In our case we set the following two options:<\/p>\n<pre><code>**-C . Pruning confidence**. Set confidence threshold for pruning. \n<\/code><\/pre>\n<p>\u200b <strong>-M . Minimum number of instances<\/strong>. Set a minimum number of instances per leaf.<\/p>\n<p>In our case, we set the pruning confidence to 0.25, and 30 as the minimum number of instances. We achieve this with the following code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">String[] options = new String[4];\n        options[0] = \"-C\";\n        options[1] = \"0.25\";\n        options[2] = \"-M\";\n        options[3] = \"30\";\n<\/code><\/pre>\n<\/div>\n<p>Our decision tree is ready to be used! Now we will prepare the data and use it to build the algorithm.<\/p>\n<h1>Import packages<\/h1>\n<p>We use different classes from the java.util package. ArrayList and List are used to organize our data. The Properties class is used to pass to GridDB store instance the cluster connection parameters. Finally, the Random class is used to randomize the seed parameter in the cross validation phase of building the decision tree.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import java.util.ArrayList;\nimport java.util.List;\nimport java.util.Properties;\nimport java.util.Random;<\/code><\/pre>\n<\/div>\n<p>Different packages are imported to connect and interact with GridDB.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import com.toshiba.mwcloud.gs.Collection;\nimport com.toshiba.mwcloud.gs.ColumnInfo;\nimport com.toshiba.mwcloud.gs.Container;\nimport com.toshiba.mwcloud.gs.ContainerInfo;\nimport com.toshiba.mwcloud.gs.GSType;\nimport com.toshiba.mwcloud.gs.GridStore;\nimport com.toshiba.mwcloud.gs.GridStoreFactory;\nimport com.toshiba.mwcloud.gs.Query;\nimport com.toshiba.mwcloud.gs.Row;\nimport com.toshiba.mwcloud.gs.RowSet;<\/code><\/pre>\n<\/div>\n<p>Finally, we import packages to interact with the file containing the original dataset.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import java.io.IOException;\nimport java.util.Scanner;\nimport java.io.File;\nimport java.io.BufferedReader;\nimport java.io.FileReader;<\/code><\/pre>\n<\/div>\n<h1>Write Data into GridDB<\/h1>\n<p>In order to write data into GridDB, we begin by setting the connection properties to our desired cluster. In the same way, we create our GridStore instance that will hold our container referenced by its name <strong>containerName<\/strong>.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Properties prop = new Properties();\n            prop.setProperty(\"notificationAddress\", \"239.0.0.1\");\n            prop.setProperty(\"notificationPort\", \"31999\");\n            prop.setProperty(\"clusterName\", \"cluster\");\n            prop.setProperty(\"database\", \"public\");\n            prop.setProperty(\"user\", \"admin\");\n            prop.setProperty(\"password\", \"admin\");\n \n            GridStore store = GridStoreFactory.getInstance().getGridStore(prop);\n            store.getContainer(\"newContainer\");\n            String containerName = \"last\";\n<\/code><\/pre>\n<\/div>\n<p>Now we have successfully created our store and container, we can start defining the container schema, by setting the container information and the list of columns with their corresponding data types.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">\/\/ Define ontainer schema and columns\n        ContainerInfo containerInfo = new ContainerInfo();\n        List&lt;columninfo> columnList = new ArrayList&lt;\/columninfo>&lt;columninfo>();\n        columnList.add(new ColumnInfo(\"key\", GSType.INTEGER));\n        columnList.add(new ColumnInfo(\"slenght\", GSType.FLOAT));\n        columnList.add(new ColumnInfo(\"swidth\", GSType.FLOAT));\n        columnList.add(new ColumnInfo(\"plenght\", GSType.FLOAT));\n        columnList.add(new ColumnInfo(\"pwidth\", GSType.FLOAT));\n        columnList.add(new ColumnInfo(\"irisclass\", GSType.STRING));\n\n        containerInfo.setColumnInfoList(columnList);\n        containerInfo.setRowKeyAssigned(true);&lt;\/columninfo><\/code><\/pre>\n<\/div>\n<p>GridDB offers two types of containers. In our case, we choose the <strong>Collection<\/strong> type used to manage general data. For this purpose, we create our collection, and a list of rows to organize our data. We will also instantiate the Row class, that will hold a data row in each iteration to obtain data from the original CSV file.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Collection&lt;Void, Row> collection = store.putCollection(containerName, containerInfo, false);\nList&lt;row> rowList = new ArrayList&lt;\/row>&lt;row>();\nRow row = collection.createRow();\n\n&lt;\/row><\/code><\/pre>\n<\/div>\n<h1>Store the Data in GridDB<\/h1>\n<p>At this moment, we recall the variables used to temporarily store the values obtained from the dataset, and insert them into each row. After that, we add each row into the row list defined in the previous section.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">           row.setInteger(0,key);\n            row.setFloat(1,slenght );\n            row.setFloat(2, swidth);\n            row.setFloat(3, plenght);\n            row.setFloat(4, pwidth);\n            row.setString(5, irisclass);\n            rowList.add(row);\n    <\/code><\/pre>\n<\/div>\n<p>To store the data into GridDB, we use the following line of code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">collection.put(rowList);<\/code><\/pre>\n<\/div>\n<h1>Retrieve the Data from GridDB<\/h1>\n<p>In order to retrieve the data we have just stored in GridDB, we perform a TQL query, that in our case, will select all data in our container.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Query&lt;row> query = container.query(\"SELECT * \");\n        RowSet&lt;\/row>&lt;row> rs = query.fetch();&lt;\/row><\/code><\/pre>\n<\/div>\n<p>In case we would like to visualize our data:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">while ( rs.hasNext() ) {\n            Row row = rs.next();\n            float slenght = row.getFloat(0);\n            float swidth = row.getFloat(1);\n            float plenght = row.getFloat(2);\n            float pwidth = row.getFloat(3);\n            String irisclass = row.getString(4);\n            System.out.println(\" slenght=\" + slenght + \", swidth=\" + swidth + \", plenght=\" + plenght +\", pwidth=\" + pwidth+\", irisclass=\" + irisclass);\n        }\n<\/code><\/pre>\n<\/div>\n<h1>Build the Decision Tree<\/h1>\n<p>Now outr data is stored in GridDB, we are ready to build the decision tree with this data. The Weka function that builds the classification tree, takes data Instances as parameters, so we will need to include the following lines of code in order to have our data suitable for Weka functions.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">BufferedReader bufferedReader= new BufferedReader(new FileReader(res));\n    Instances datasetInstances= new Instances(bufferedReader);\n<\/code><\/pre>\n<\/div>\n<p>At this level, we simply proceed to build the classifier.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">mytree.buildClassifier(datasetInstances);<\/code><\/pre>\n<\/div>\n<p>Last but not least, we generate an evaluation for the classifier tree we have just built.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Evaluation eval = new Evaluation(datasetInstances);  eval.crossValidateModel(mytree, datasetInstances, 10, new Random(1));<\/code><\/pre>\n<\/div>\n<p>We observe in the last line of code that we perform a cross validation to our data instances. This process will ensure that the dataset is split in different ways to obtain unbiased results, specially that we count with a limited dataset.<\/p>\n<p>Finally, we print the evaluation summary:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">    System.out.println(eval.toSummaryString(\"n ****** J48 *****n\", true));<\/code><\/pre>\n<\/div>\n<h1>Compile and Run the Code<\/h1>\n<p>In our context, a .java file is located at the level of the gsSample default folder and contains the code described in this article. Navigate to your GridDB folder, and execute the following commands to compile and run the code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">~\/griddb$ javac gsSample\/Select.java\n~\/griddb$ java gsSample\/Select.java<\/code><\/pre>\n<\/div>\n<p>As we can observe, running the code does not need any additional cluster parameters in the command line, as these were hardcoded in our java file.<\/p>\n<h1>Conclusion<\/h1>\n<p>Here is an extract of the evaluation summary print in the previous sections:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">---Registering Weka Editors---\nTrying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?\n\n ****** J48 *****\n\nCorrectly Classified Instances         141               94.6309 %\nIncorrectly Classified Instances         8                5.3691 %\nKappa statistic                          0.9195\nK&B Relative Info Score              13340.283  %\nK&B Information Score                  211.4385 bits      1.4191 bits\/instance\nClass complexity | order 0             236.1698 bits      1.585  bits\/instance\nClass complexity | scheme             2179.3992 bits     14.6268 bits\/instance\nComplexity improvement     (Sf)      -1943.2293 bits    -13.0418 bits\/instance\nMean absolute error                      0.0578\nRoot mean squared error                  0.1831\nRelative absolute error                 13.0031 %\nRoot relative squared error             38.8358 %\nTotal Number of Instances              149<\/code><\/pre>\n<\/div>\n<p>As we highlight, the decision tree has been able to reach an accuracy of <strong>94&#46;6%<\/strong> on classifying the iris plants into their classes. Please visit the official documentation for Weka J48 in order to learn more about the results and their interpretation.<\/p>\n<p>Do not forget to close the TQL query, the container, and the GridDB store:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> query.close();\n container.close();\n store.close();<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that serve as support systems in many fields. These methods have acquired the importance to become vital in different sectors and industries. This article describes the implementation of a decision tree algorithm in Java. The article [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":28046,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46685","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Implement a Decision Tree Algorithm in Java | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Implement a Decision Tree Algorithm in Java | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\" \/>\n<meta property=\"og:site_name\" content=\"GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/griddbcommunity\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-02-10T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:55:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb.net\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"2560\" \/>\n\t<meta property=\"og:image:height\" content=\"1707\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"griddb-admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:site\" content=\"@GridDBCommunity\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"griddb-admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"How to Implement a Decision Tree Algorithm in Java\",\"datePublished\":\"2022-02-10T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:49+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\"},\"wordCount\":1095,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\",\"name\":\"How to Implement a Decision Tree Algorithm in Java | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg\",\"datePublished\":\"2022-02-10T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:49+00:00\",\"description\":\"The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg\",\"contentUrl\":\"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg\",\"width\":2560,\"height\":1707},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb.net\/en\/#website\",\"url\":\"https:\/\/griddb.net\/en\/\",\"name\":\"GridDB: Open Source Time Series Database for IoT\",\"description\":\"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL\",\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"contentUrl\":\"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png\",\"width\":200,\"height\":83,\"caption\":\"Fixstars\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/griddbcommunity\/\",\"https:\/\/x.com\/GridDBCommunity\",\"https:\/\/www.linkedin.com\/company\/griddb-by-toshiba\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g\",\"caption\":\"griddb-admin\"},\"url\":\"https:\/\/griddb.net\/en\/author\/griddb-admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Implement a Decision Tree Algorithm in Java | GridDB: Open Source Time Series Database for IoT","description":"The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/","og_locale":"en_US","og_type":"article","og_title":"How to Implement a Decision Tree Algorithm in Java | GridDB: Open Source Time Series Database for IoT","og_description":"The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that","og_url":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2022-02-10T08:00:00+00:00","article_modified_time":"2025-11-13T20:55:49+00:00","og_image":[{"width":2560,"height":1707,"url":"https:\/\/griddb.net\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg","type":"image\/jpeg"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"How to Implement a Decision Tree Algorithm in Java","datePublished":"2022-02-10T08:00:00+00:00","dateModified":"2025-11-13T20:55:49+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/"},"wordCount":1095,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/","url":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/","name":"How to Implement a Decision Tree Algorithm in Java | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg","datePublished":"2022-02-10T08:00:00+00:00","dateModified":"2025-11-13T20:55:49+00:00","description":"The combination of statistical methods, machine learning, and artificial intelligence have allowed the development of various data mining techniques that","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/how-to-implement-a-decision-tree-algorithm-in-java\/#primaryimage","url":"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg","contentUrl":"\/wp-content\/uploads\/2022\/01\/abstract_3840x2560-scaled.jpeg","width":2560,"height":1707},{"@type":"WebSite","@id":"https:\/\/griddb.net\/en\/#website","url":"https:\/\/griddb.net\/en\/","name":"GridDB: Open Source Time Series Database for IoT","description":"GridDB is an open source time-series database with the performance of NoSQL and convenience of SQL","publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/","url":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","contentUrl":"https:\/\/griddb.net\/wp-content\/uploads\/2019\/04\/fixstars_logo_web_tagline.png","width":200,"height":83,"caption":"Fixstars"},"image":{"@id":"https:\/\/griddb.net\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/griddbcommunity\/","https:\/\/x.com\/GridDBCommunity","https:\/\/www.linkedin.com\/company\/griddb-by-toshiba"]},{"@type":"Person","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5bceca1cafc06886a7ba873e2f0a28011a1176c4dea59709f735b63ae30d0342?s=96&d=mm&r=g","caption":"griddb-admin"},"url":"https:\/\/griddb.net\/en\/author\/griddb-admin\/"}]}},"_links":{"self":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46685","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/users\/41"}],"replies":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/comments?post=46685"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46685\/revisions"}],"predecessor-version":[{"id":51359,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46685\/revisions\/51359"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media\/28046"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}