{"id":46674,"date":"2021-11-08T00:00:00","date_gmt":"2021-11-08T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/email-spam-classification-using-java-and-griddb\/"},"modified":"2025-11-13T12:55:39","modified_gmt":"2025-11-13T20:55:39","slug":"email-spam-classification-using-java-and-griddb","status":"publish","type":"post","link":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/","title":{"rendered":"Email Spam Classification using Java and GridDB"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords in the subject or message, there are cases where this isn&#8217;t easy, and additional parts of the email should be considered. One way to solve this problem is by gathering example spam and non-spam emails, then train a machine learning model.<\/p>\n<p>We will use a dataset that contains over 4000 spam (1) and non-spam (0) emails.<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/11\/img1.png\"><img fetchpriority=\"high\" decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/11\/img1.png\" alt=\"\" width=\"543\" height=\"273\" class=\"aligncenter size-full wp-image-27878\" srcset=\"\/wp-content\/uploads\/2021\/11\/img1.png 543w, \/wp-content\/uploads\/2021\/11\/img1-300x151.png 300w\" sizes=\"(max-width: 543px) 100vw, 543px\" \/><\/a><\/p>\n<p>The dataset is in a CSV format. Each email has 48 features that describe the frequency of occurrence of particular words in the email: 6 features describe the occurrence of particular characters, 3 features describe the occurrence of capital letters, and the last feature that shows the spam\/non-spam label. Since the emails will be categorized as either spam or not spam, this is a <em>binary classification<\/em> task.<\/p>\n<p>We will follow the steps given below to build the binary classifier:<\/p>\n<p><strong>Step 1:<\/strong> Move the CSV data into GridDB.<\/p>\n<p><strong>Step 2:<\/strong> Read the GridDB data and create an in-memory dataset.<\/p>\n<p><strong>Step 3:<\/strong> Create a neural network model to perform binary classification.<\/p>\n<p><strong>Step 4:<\/strong> Use the loaded dataset to train the neural network model.<\/p>\n<p><strong>Step 5:<\/strong> Test the performance of the trained model.<\/p>\n<h2>Import Packages<\/h2>\n<p>Let&#8217;s begin by importing the packages to be used:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import java.io.IOException;\nimport java.util.Collection;\nimport java.util.Properties;\nimport java.util.Scanner;\n\nimport com.toshiba.mwcloud.gs.Collection;\nimport com.toshiba.mwcloud.gs.GSException;\nimport com.toshiba.mwcloud.gs.GridStore;\nimport com.toshiba.mwcloud.gs.GridStoreFactory;\nimport com.toshiba.mwcloud.gs.Query;\nimport com.toshiba.mwcloud.gs.RowKey;\nimport com.toshiba.mwcloud.gs.RowSet;<\/code><\/pre>\n<\/div>\n<h2>Write Data into GridDB<\/h2>\n<p>The CSV data has been stored in a file named <code>spam.csv<\/code>. Our goal is to move this data into a GridDB container. Let&#8217;s create a static class to represent the container schema:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> public static class Emails{\n    \n         @RowKey String word1;\n     String word2,word3,word4,word5,word6,word7,word8,word9,word10,word11,word12,word13,word14,word15,word16,word17,word18,word19,word20,word21,word22,word23,word24,word25,word26,word27,word28,word29,word30,word31,word32,word33,word34,word35,word36,word37,word38,word39,word40,word41,word42,word43,word44,word45,word46,word47,word48,char1,char2,char3,char4,char5,char6,capitalAvg,capitalLongest,capitalTotal,isSpam;\n    \n    }<\/code><\/pre>\n<\/div>\n<p>The above class will create a GridDB container, which is similar to a SQL table, with 58 columns.<\/p>\n<p>We can now connect to our GridDB instance. We will create an instance of GridDB that features the details of our GridDB installation:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">        Properties props = new Properties();\n        props.setProperty(\"notificationAddress\", \"239.0.0.1\");\n        props.setProperty(\"notificationPort\", \"31999\");\n        props.setProperty(\"clusterName\", \"defaultCluster\");\n        props.setProperty(\"user\", \"admin\");\n        props.setProperty(\"password\", \"admin\");\n        GridStore store = GridStoreFactory.getInstance().getGridStore(props);<\/code><\/pre>\n<\/div>\n<p>Let us select the <code>Emails<\/code> container as we want to work on it:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Collection&lt;String, Emails> coll = store.putCollection(\"col01\", Emails.class);<\/code><\/pre>\n<\/div>\n<p>The above code creates an instance of the <code>Emails<\/code> container and gives it the name <code>coll<\/code>. We will be using this name to refer to the container.<\/p>\n<p>Let us now read data from the <code>spam.csv<\/code> file and store it in GridDB:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">File file1 = new File(\"spam.csv\");\n                Scanner sc = new Scanner(file1);\n                String data = sc.next();\n \n                while (sc.hasNext()){\n                        String scData = sc.next();\n                        String dataList[] = scData.split(\",\");\n                        String word1 = dataList[0];\n                        String word2 = dataList[1];\n                        String word3 = dataList[2];\n                        String word4 = dataList[3];\n                        String word5 = dataList[4];\n                        String word6 = dataList[5];\n                        String word7 = dataList[6];\n                        String word8 = dataList[7];\n                        String word9 = dataList[8];\n                        String word10 = dataList[9];\n                        String word11 = dataList[10];\n                        String word12 = dataList[11];\n                        String word13 = dataList[12];\n                        String word14 = dataList[13];\n                        String word15 = dataList[14];\n                        String word16 = dataList[15];\n                        String word17 = dataList[16];\n                        String word18 = dataList[17];\n                        String word19 = dataList[18];\n                        String word20 = dataList[19];\n                        String word21 = dataList[20];\n                        String word22 = dataList[21];\n                        String word23 = dataList[22];\n                        String word24 = dataList[23];\n                        String word25 = dataList[24];\n                        String word26 = dataList[25];\n                        String word27 = dataList[26];\n                        String word28 = dataList[27];\n                        String word29 = dataList[28];\n                        String word30 = dataList[29];\n                        String word31 = dataList[30];\n                        String word32 = dataList[31];\n                        String word33 = dataList[32];\n                        String word34 = dataList[33];\n                        String word35 = dataList[34];\n                        String word36 = dataList[35];\n                        String word37 = dataList[36];\n                        String word38 = dataList[37];\n                        String word39 = dataList[38];\n                        String word40 = dataList[39];\n                        String word41 = dataList[40];\n                        String word42 = dataList[41];\n                        String word43 = dataList[42];\n                        String word44 = dataList[43];\n                        String word45 = dataList[44];\n                        String word46 = dataList[45];\n                        String word47 = dataList[46];\n                        String word48 = dataList[47];\n                        String char1 = dataList[48];\n                        String char2 = dataList[49];\n                        String char3 = dataList[50];\n                        String char4 = dataList[51];\n                        String char5 = dataList[52];\n                        String char6 = dataList[53];\n                        String capitalAvg =dataList[54];\n                        String capitalLongest = dataList[55];\n                        String capitalTotal = dataList[56];\n                        String isSpam = dataList[57];\n\n                        \n                        \n                        Emails emails = new Emails();\n                        \n                        emails.word1 =word1;\n                        emails.word2 =word2;\n                        emails.word3 =word3;\n                        emails.word4 =word4;\n                        emails.word5 =word5;\n                        emails.word6 =word6;\n                        emails.word7 =word7;\n                        emails.word8 =word8;\n                        emails.word9 =word9;\n                        emails.word10 =word10;\n                        emails.word11 =word11;\n                        emails.word12 =word12;\n                        emails.word13 =word13;\n                        emails.word14 =word14;\n                        emails.word15 =word15;\n                        emails.word16 =word16;\n                        emails.word17 =word17;\n                        emails.word18 =word18;\n                        emails.word19 =word19;\n                        emails.word20 =word20;\n                        emails.word21 =word21;\n                        emails.word22 =word22;\n                        emails.word23 =word23;\n                        emails.word24 =word26;\n                        emails.word27 =word27;\n                        emails.word28 =word28;\n                        emails.word29 =word29;\n                        emails.word30 =word30;\n                        emails.word31 =word31;\n                        emails.word32 =word32;\n                        emails.word33 =word33;\n                        emails.word34 =word34;\n                        emails.word35 =word35;\n                        emails.word36 =word36;\n                        emails.word37 =word37;\n                        emails.word38 =word38;\n                        emails.word39 =word39;\n                        emails.word41 =word41;\n                        emails.word42 =word42;\n                        emails.word43 =word43;\n                        emails.word44 =word44;\n                        emails.word45 =word45;\n                        emails.word46 =word46;\n                        emails.word47 =word47;\n                        emails.word48 =word48;\n                        emails.char1 = char1;\n                        emails.char2 = char2;\n                        emails.char3 = char3;\n                        emails.char4 = char4;\n                        emails.char5 = char5;\n                        emails.char6 = char6;\n                        emails.capitalAvg = capitalAvg;\n                        emails.capitalLongest = capitalLongest;\n                        emails.capitalTotal = capitalTotal;\n                        emails.isSpam = isSpam;\n    \n                        \n                        coll.append(emails);\n                 }<\/code><\/pre>\n<\/div>\n<p>We have created an object named <code>emails<\/code> and appended it to the GridDB container.<\/p>\n<h2>Query the Data from GridDB<\/h2>\n<p>Use the following code to pull the data from GridDB:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Query&lt;emails> query = coll.query(\"select *\");\n                RowSet&lt;\/emails>&lt;emails> rs = query.fetch(false);\n            RowSet res = query.fetch();&lt;\/emails><\/code><\/pre>\n<\/div>\n<p>The <code>select *<\/code>helps us to select all the data stored in the container.<\/p>\n<h2>Build the Binary Classifier<\/h2>\n<p>First, let&#8217;s import all the Java libraries that we will need to build the binary classifier:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import deepnetts.data.DataSets;\nimport deepnetts.eval.Evaluators;\nimport deepnetts.data.norm.MaxNormalizer;\nimport javax.visrec.ml.eval.EvaluationMetrics;\nimport deepnetts.net.layers.activation.ActivationType;\nimport deepnetts.net.loss.LossType;\nimport deepnetts.net.FeedForwardNetwork;\nimport deepnetts.util.DeepNettsException;\nimport java.io.IOException;\nimport javax.visrec.ml.classification.BinaryClassifier;\nimport javax.visrec.ml.ClassificationException;\nimport javax.visrec.ml.data.DataSet;\nimport deepnetts.data.MLDataItem;\nimport javax.visrec.ri.ml.classification.FeedForwardNetBinaryClassifier;<\/code><\/pre>\n<\/div>\n<p>We can now build a binary classifier that uses a feed-forward neural network. Here is the code for this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">DataSet emailsDataSet= DataSets(res, 57, 1, true); \n\n\/\/ create a feed forward neural network using builder\nFeedForwardNetwork nn = FeedForwardNetwork.builder()\n                               .addInputLayer(57)                                                                                                                                        \n                               .addFullyConnectedLayer(15) \n                               .addOutputLayer(1, ActivationType.SIGMOID)                                           \n                               .lossFunction(LossType.CROSS_ENTROPY) \n                               .build();<\/code><\/pre>\n<\/div>\n<p>The feed-forward neural network is a machine learning algorithm which can be represented as a graph:<\/p>\n<p><a href=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/11\/network.png\"><img decoding=\"async\" src=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/11\/network.png\" alt=\"\" width=\"472\" height=\"284\" class=\"aligncenter size-full wp-image-27879\" srcset=\"\/wp-content\/uploads\/2021\/11\/network.png 472w, \/wp-content\/uploads\/2021\/11\/network-300x181.png 300w\" sizes=\"(max-width: 472px) 100vw, 472px\" \/><\/a><\/p>\n<p>Every node in the graph does a calculation to transform the input. Each node applies a function to the input it receives from its preceeding node, and then sends it to the next node. In the above code, we are using <em>sigmoid<\/em> as the actovation function. The nodes are organized into groups known as <em>layers<\/em>.<\/p>\n<h2>Split the Data into Training and Test Sets<\/h2>\n<p>The goal is to train a machine learning model using a subset of our emails dataset and use the other subset of the dataset to test the accuracy of the model. We will split the data into two sets, training and test sets (60% for training and 40% for testing).<\/p>\n<p>The following code will help us to split the data into these two sets:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">\/\/ split the data\nDataSet[] trainTestData = emailsDataSet.split(0.6, 0.4);\n\n\n\/\/ Normalize the data\nMaxNormalizer norm = new MaxNormalizer(trainTestData[0]); \nnorm.normalize(trainTestData[0]); \/\/ normalize the training set\nnorm.normalize(trainTestData[1]); \/\/ normalize the test set\nDataSet trainingSet = trainTestData[0];\nDataSet testSet = trainTestData[1];<\/code><\/pre>\n<\/div>\n<p>Note that in the above code, after splitting the data, we have normalized it.<\/p>\n<h2>Train the Neural Network<\/h2>\n<p>Now that the data is trained, it is time to train the neural network model. The feed-forward neural network will be trained using the <em>backpropagation algorithm<\/em>. The Deep Netts API has implemented this algorithm in the Backpropagation Trainer class. We will use its <code>NeuralNetwork.getTrainer()<\/code> method to create an instance of the trainer that will be used for training the parent network. We will also set a number of parameters for the algorithm like the maximum number of epochs (the number of passes through the training set) and the learnimg rate.<\/p>\n<p>Use the following code:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">\/\/ configure the trainer\n      nn.getTrainer().setMaxError(0.03f)\n                              .setMaxEpochs(10000)\n                              .setLearningRate(0.001f);\n\n      \/\/ start the training \n      nn.train(trainingSet);<\/code><\/pre>\n<\/div>\n<p>When executed, the code will return something similar to this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">Epoch:1, Time:72ms, TrainError:0.66057104, TrainErrorChange:0.66057104, TrainAccuracy: 0.6289855\nEpoch:2, Time:18ms, TrainError:0.6435114, TrainErrorChange:-0.017059624, TrainAccuracy: 0.65072465\nEpoch:3, Time:17ms, TrainError:0.6278175, TrainErrorChange:-0.015693903, TrainAccuracy: 0.6786232\nEpoch:4, Time:14ms, TrainError:0.60796565, TrainErrorChange:-0.019851863, TrainAccuracy: 0.726087\nEpoch:5, Time:15ms, TrainError:0.58832765, TrainErrorChange:-0.019638002, TrainAccuracy: 0.74746376<\/code><\/pre>\n<\/div>\n<p>Thus, the model returns the results of each epoch.<\/p>\n<h2>Testing the Classifier<\/h2>\n<p>We need to be sure that the classifier will give accurate results when classifying new emails as either spam or not spam. Thus, we should test it.<\/p>\n<p>The classifier will be tested using the test data that has not been used in training the model. It will calculate the correct and wrong classifications, and calculate other metrics to help you understand the classifier.<\/p>\n<p>The following code can help us to test the classifier:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">EvaluationMetrics metrics = Evaluators.evaluateClassifier(nn, testSet);\nSystem.out.println(metrics);<\/code><\/pre>\n<\/div>\n<p>The code will return metrics such as accuracy, precision, recall, and F1Score of the classifier.<\/p>\n<h2>Using the Trained Model<\/h2>\n<p>We need to use the trained classifier to classify new emails. The following code demonstrates this:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">\/\/ create a binary classifier using the trained network\n        BinaryClassifier bc = new FeedForwardNetBinaryClassifier(nn);        \n        \/\/ get the test email as an array of features\n        float[] testEmail = testSet.get(0).getInput().getValues();\n\n        \/\/ get the probability score that the email is spam\n        Float output = bc.classify(testEmail);\n        System.out.println(\"Spam probability: \"+output);<\/code><\/pre>\n<\/div>\n<p>We have used the <code>FeedForwardNetBinaryClassifier<\/code> class to wrap the trained network. The <code>BinaryClassifier<\/code> is an interface that uses generics to specify the inputs of a binary classifier, which is an array of email features in our case. We have then passed an email to be classified from the test dataset as an array of email features. The array has then been passed to the <code>classify<\/code> method of the binary classifier.<\/p>\n<h2>Compile and Execute the Code<\/h2>\n<p>Login as the <code>gsadm<\/code> user. Move your <code>.java<\/code> file to the <code>bin<\/code> folder of your GridDB located in the following path:<\/p>\n<p>\/griddb_4.6.0-1_amd64\/usr\/griddb-4.6.0\/bin<\/p>\n<p>Next, run the following command on your Linux terminal to set the path for the gridstore.jar file:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">export CLASSPATH=$CLASSPATH:\/home\/osboxes\/Downloads\/griddb_4.6.0-1_amd64\/usr\/griddb-4.6.0\/bin\/gridstore.jar<\/code><\/pre>\n<\/div>\n<p>Next, run the following command to compile your <code>.java<\/code> file:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">javac EmailSpamFilter.java<\/code><\/pre>\n<\/div>\n<p>Run the .class file that is generated by running the following command:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">java EmailSpamFilter<\/code><\/pre>\n<\/div>\n<p>The result will be a probability score, which shows the probability of an email being a spam.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords in the subject or message, there are cases where this isn&#8217;t easy, and additional parts of the email should be considered. One way to solve this problem is by [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":27888,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46674","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>Email Spam Classification using Java and GridDB | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords\" \/>\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\/email-spam-classification-using-java-and-griddb\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Email Spam Classification using Java and GridDB | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/\" \/>\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=\"2021-11-08T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:55:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb.net\/wp-content\/uploads\/2021\/11\/email-spam.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1160\" \/>\n\t<meta property=\"og:image:height\" content=\"653\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\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=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"Email Spam Classification using Java and GridDB\",\"datePublished\":\"2021-11-08T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/\"},\"wordCount\":963,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2021\/11\/email-spam.png\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/\",\"name\":\"Email Spam Classification using Java and GridDB | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2021\/11\/email-spam.png\",\"datePublished\":\"2021-11-08T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:55:39+00:00\",\"description\":\"Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2021\/11\/email-spam.png\",\"contentUrl\":\"\/wp-content\/uploads\/2021\/11\/email-spam.png\",\"width\":1160,\"height\":653},{\"@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":"Email Spam Classification using Java and GridDB | GridDB: Open Source Time Series Database for IoT","description":"Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords","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\/email-spam-classification-using-java-and-griddb\/","og_locale":"en_US","og_type":"article","og_title":"Email Spam Classification using Java and GridDB | GridDB: Open Source Time Series Database for IoT","og_description":"Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords","og_url":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/","og_site_name":"GridDB: Open Source Time Series Database for IoT","article_publisher":"https:\/\/www.facebook.com\/griddbcommunity\/","article_published_time":"2021-11-08T08:00:00+00:00","article_modified_time":"2025-11-13T20:55:39+00:00","og_image":[{"width":1160,"height":653,"url":"https:\/\/griddb.net\/wp-content\/uploads\/2021\/11\/email-spam.png","type":"image\/png"}],"author":"griddb-admin","twitter_card":"summary_large_image","twitter_creator":"@GridDBCommunity","twitter_site":"@GridDBCommunity","twitter_misc":{"Written by":"griddb-admin","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"Email Spam Classification using Java and GridDB","datePublished":"2021-11-08T08:00:00+00:00","dateModified":"2025-11-13T20:55:39+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/"},"wordCount":963,"commentCount":0,"publisher":{"@id":"https:\/\/griddb.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2021\/11\/email-spam.png","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/","url":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/","name":"Email Spam Classification using Java and GridDB | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2021\/11\/email-spam.png","datePublished":"2021-11-08T08:00:00+00:00","dateModified":"2025-11-13T20:55:39+00:00","description":"Introduction In email spam classification, the task is to determine whether an email is a spam or not spam. Although this is mostly determined by keywords","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/email-spam-classification-using-java-and-griddb\/#primaryimage","url":"\/wp-content\/uploads\/2021\/11\/email-spam.png","contentUrl":"\/wp-content\/uploads\/2021\/11\/email-spam.png","width":1160,"height":653},{"@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\/46674","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=46674"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46674\/revisions"}],"predecessor-version":[{"id":51348,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46674\/revisions\/51348"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media\/27888"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46674"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46674"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46674"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}