{"id":46793,"date":"2024-02-29T00:00:00","date_gmt":"2024-02-29T08:00:00","guid":{"rendered":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/"},"modified":"2025-11-13T12:56:54","modified_gmt":"2025-11-13T20:56:54","slug":"predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb","status":"publish","type":"post","link":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/","title":{"rendered":"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted is known as the <code>dependent<\/code> variable while the variable used for predicting other variables is known as the <code>independent variable<\/code>. It estimates the coefficients of the linear equation with one or more independent variables. Linear regression creates a straight line that minimizes the differences between the predicted and the expected output values.<\/p>\n<p>In this article, we will be creating a linear regression model that predicts the number of ice cream sales based on temperature using Java and GridDB. <code>Temperature<\/code> will be the indepedent variable while <code>ice cream sales<\/code> will be the dependent variable.<\/p>\n<h2>Import Packages<\/h2>\n<p>Let&#8217;s begin by importing the java libraries that will enable us to work with GridDB:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import 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;\nimport java.util.*;\n\n\nimport java.util.Scanner;\nimport java.io.IOException;\nimport java.util.ArrayList;\nimport java.util.Properties;\nimport java.util.logging.Level;\nimport java.util.logging.Logger;<\/code><\/pre>\n<\/div>\n<h2>Write the Data into GridDB<\/h2>\n<p>The dataset to be used shows the number of ice cream sales for different temperature values. It has been divided into two, that is, training and test datasets.<br \/>\nHowever, we want to move the training dataset into GridDB as it offers various benefits including faster query performance. We will define a GridDB container for storing the data. The container will be defined as a java class as shown below:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\"> static class SalesData {\n    @RowKey int id;\n        double temperature;\n    double icecreamsales;\n     }<\/code><\/pre>\n<\/div>\n<p>A GridDB container can be seen as a SQL table.<\/p>\n<p>For us to write data into the GridDB container, we should first connect to GridDB. We have to create a <code>Properties<\/code> file from the <code>java.util<\/code> package and provide the credentials of our GridDB installation using the <code>key:value<\/code> pairs syntax as shown below:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Properties props = new Properties();\nprops.setProperty(\"notificationMember\", \"127.0.1.1:10001\");\nprops.setProperty(\"clusterName\", \"myCluster\");\nprops.setProperty(\"user\", \"admin\");\nprops.setProperty(\"password\", \"admin\");\nGridStore store = GridStoreFactory.getInstance().getGridStore(props);<\/code><\/pre>\n<\/div>\n<p>We have also created the <code>store<\/code> variable of type <code>GridStore<\/code> to help us interact with the database.<\/p>\n<h2>Store the Training Dataset in GridDB<\/h2>\n<p>We want to store the training dataset into GridDB. Let us first define the data rows as instances of the <code>SalesData<\/code> class.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">SalesData  row1 = new SalesData();\nrow1.id=1;\nrow1.temperature=14.2;\nrow1.icecreamsales=215;\n\nSalesData  row2 = new SalesData();\nrow2.id=2;\nrow2.temperature=16.4;\nrow2.icecreamsales=325;\n\nSalesData  row3 = new SalesData();\nrow3.id=3;\nrow3.temperature=11.9;\nrow3.icecreamsales=185;\n\nSalesData  row4 = new SalesData();\nrow4.id=4;\nrow4.temperature=15.2;\nrow4.icecreamsales=332;\n\nSalesData  row5 = new SalesData();\nrow5.id=5;\nrow5.temperature=18.5;\nrow5.icecreamsales=406;\n\nSalesData  row6 = new SalesData();\nrow6.id=6;\nrow6.temperature=19.4;\nrow6.icecreamsales=412;\n\nSalesData  row7 = new SalesData();\nrow7.id=7;\nrow7.temperature=25.1;\nrow7.icecreamsales=614;\n\nSalesData  row8 = new SalesData();\nrow8.id=8;\nrow8.temperature=23.4;\nrow8.icecreamsales=544;\n\nSalesData  row9 = new SalesData();\nrow9.id=9;\nrow9.temperature=18.1;\nrow9.icecreamsales=421;\n\nSalesData  row10 = new SalesData();\nrow10.id=10;\nrow10.temperature=22.6;\nrow10.icecreamsales=445;\n\nSalesData  row11 = new SalesData();\nrow11.id=11;\nrow11.temperature=17.2;\nrow11.icecreamsales=408;<\/code><\/pre>\n<\/div>\n<p>Let us now select the <code>SalesData<\/code> GridDB container where the data will be stored:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Collection<String, SalesData> sd= store.putCollection(\"SalesData\", SalesData.class);<\/code><\/pre>\n<\/div>\n<p>We can use the <code>put()<\/code> function to add the data into the container:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">sd.put(row1);\nsd.put(row2);\nsd.put(row3);\nsd.put(row4);\nsd.put(row5);\nsd.put(row6);\nsd.put(row7);\nsd.put(row8);\nsd.put(row9);\nsd.put(row10);\nsd.put(row11);<\/code><\/pre>\n<\/div>\n<h2>Retrieve the Training Data<\/h2>\n<p>We now want to retrieve the training data from GridDB and use it to fit a machine learning model. We will write a TQL query to retrieve all the data in the <code>SalesData<\/code> container as shown below:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Query<SalesData> query = sd.query(\"select *\");\nRowSet<SalesData> rs = query.fetch(false);\n\nwhile (rs.hasNext()) {\nSalesData sd1 = rs.next();\ndouble[][] data = {{sd1.temperature},{sd1.icecreamsales}};\n}<\/code><\/pre>\n<\/div>\n<p>We have used the <code>select *<\/code> TQL statement to retrieve all the data stored in the container. The data has then been stored in a 2D array named <code>data<\/code>.<\/p>\n<h2>Create Weka Instances<\/h2>\n<p>We will use the Weka machine learning library to fit a linear regression model. Hence, we must convert our data into Weka instances. We will first create attributes for the dataset and store them in a FastVector data structure. We can then create Weka instances of the dataset.<\/p>\n<p>Let&#8217;s first create the data structures for storing the attributes and the instances:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">int numInstances = data[0].length;\nFastVector atts = new FastVector();\nList<Instance> instances = new ArrayList<Instance>();<\/code><\/pre>\n<\/div>\n<p>Next, we create a <code>for<\/code> loop and use it to iterate over the data items and populate the FastVector data structure with the attributes:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">for(int dim = 0; dim < 2; dim++)\n    {\n        Attribute current = new Attribute(\"Attribute\" + dim, dim);\n\n        if(dim == 0)\n        {\n            for(int obj = 0; obj < numInstances; obj++)\n            {\n                instances.add(new SparseInstance(numInstances));\n            }\n        }\n\n        for(int obj = 0; obj < numInstances; obj++)\n        {\n            instances.get(obj).setValue(current, data[dim][obj]);\n            \n        }\n        atts.addElement(current);\n    }<\/code><\/pre>\n<\/div>\n<p>Let's use the <code>Instance<\/code> class of Weka to generate instances and store them in an Instance variable named <code>newDataset<\/code>.<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Instances newDataset = new Instances(\"Dataset\", atts, instances.size());<\/code><\/pre>\n<\/div>\n<h2>Fit a Linear Regression Model<\/h2>\n<p>Since the data instances are ready, we can fit a machine learning model. But first, let us import the necessary libraries from Weka:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">import weka.classifiers.Classifier;\nimport weka.classifiers.Evaluation;\nimport weka.core.Attribute;\nimport weka.core.FastVector;\nimport weka.core.Instance;\nimport weka.core.Instances;\nimport weka.core.SparseInstance;<\/code><\/pre>\n<\/div>\n<p>Let us specify the class attribute for the dataset before feeding it into the model:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">newDataset.setClassIndex(1);<\/code><\/pre>\n<\/div>\n<p>We can now use the <code>LinearRegression()<\/code> function of the Weka library to fit a Linear Regression classifier:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">newDataset.setClassIndex(1);\nfor(Instance inst : instances)\nnewDataset.add(inst);\nClassifier classifier = new weka.classifiers.functions.LinearRegression();\n\nclassifier.buildClassifier(newDataset);\n        System.out.println(classifier);<\/code><\/pre>\n<\/div>\n<p>Our linear regression model is now ready!<\/p>\n<h2>Evaluate and Test Model<\/h2>\n<p>We will evaluate the model using the training dataset and test it using the test dataset. Let us define an array named <code>data2<\/code> and populate it with the test data:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">    static double[][] data2 = {{14.2,16.4,11.9},{215,325,185}};<\/code><\/pre>\n<\/div>\n<p>For us to feed the data into the model, we must first convert it into Weka instances. We will store the attributes in a FastVector data structure and the instances in an ArrayList. Let us define them:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">int numInstances2 = data2[0].length;\n        FastVector atts2 = new FastVector();\n        List<Instance> instances2 = new ArrayList<Instance>();<\/code><\/pre>\n<\/div>\n<p>We can now use a <code>for<\/code> loop to iterate over the data and populate the attributes into the FastVector:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">for(int dim2 = 0; dim2 < 2; dim2++)\n    {\n        Attribute current2 = new Attribute(\"Attribute\" + dim2, dim2);\n\n        if(dim2 == 0)\n        {\n            for(int obj2 = 0; obj2 < numInstances2; obj2++)\n            {\n                instances2.add(new SparseInstance(numInstances2));\n            }\n        }\n\n        for(int obj2 = 0; obj2 < numInstances2; obj2++)\n        {\n            instances2.get(obj2).setValue(current2, data2[dim2][obj2]);\n            \n        }\n        atts2.addElement(current2);\n    }<\/code><\/pre>\n<\/div>\n<p>Let us create instances of the training dataset and store them in an Instance variable named <code>newDataset2<\/code>:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">    Instances newDataset2 = new Instances(\"Dataset\", atts2, instances2.size());<\/code><\/pre>\n<\/div>\n<p>Let us specify the class attribute of the dataset before feeding it into the model:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">newDataset2.setClassIndex(1);<\/code><\/pre>\n<\/div>\n<p>Next, we feed the data into the model and print the evaluation summary:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">for(Instance inst2 : instances2)\n       newDataset2.add(inst2);\n\n       Evaluation eval = new Evaluation(newDataset);\n        eval.evaluateModel(classifier, newDataset2);\n    \n        System.out.println(eval.toSummaryString());<\/code><\/pre>\n<\/div>\n<h2>Make a Prediction<\/h2>\n<p>We can now use our model to predict the number of ice cream sales for a particular temperature value. Let's use the last instance of the test dataset to make the prediction:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-java\">Instance pd = newDataset2.lastInstance();\ndouble value = classifier.classifyInstance(pd);              \n    System.out.println(value);<\/code><\/pre>\n<\/div>\n<h2>Execute the Model<\/h2>\n<p>Download the Weka API from the following URL:<\/p>\n<p><code>http:\/\/www.java2s.com\/Code\/Jar\/w\/weka.htm<\/code><br \/>\nI will be using Weka version 3.7.0.<\/p>\n<p>Set the class paths for the <code>gridstore.jar<\/code> and <code>weka-3-7-0.jar<\/code> files by executing the following commands on the terminal:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">export CLASSPATH=$CLASSPATH:\/usr\/share\/java\/gridstore.jar<\/code><\/pre>\n<\/div>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">export CLASSPATH=$CLASSPATH:\/mnt\/c\/Users\/user\/Desktop\/weka-3.7.0.jar<\/code><\/pre>\n<\/div>\n<p>Note that the above commands may change depending on the location of the files.<\/p>\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 IceSales.java<\/code><\/pre>\n<\/div>\n<p>Execute the generated .class file using the following command:<\/p>\n<div class=\"clipboard\">\n<pre><code class=\"language-sh\">java IceSales<\/code><\/pre>\n<\/div>\n<p>The model returned a correlation coefficient of 0.9456. Correlation values range between -1 and 1, where 1 is very strong and linear correlation, -1 is inverse linear relation and 0 means no relation. The model also predicted 198 ice cream sales.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted is known as the dependent variable while the variable used for predicting other variables is known as the independent variable. It estimates the coefficients of the linear equation with one [&hellip;]<\/p>\n","protected":false},"author":41,"featured_media":30008,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[121],"tags":[],"class_list":["post-46793","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>Predicting Ice Cream Sales Based on Temperature Using Java and GridDB | GridDB: Open Source Time Series Database for IoT<\/title>\n<meta name=\"description\" content=\"Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted\" \/>\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\/predicting-ice-cream-sales-based-on-temperature-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=\"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB | GridDB: Open Source Time Series Database for IoT\" \/>\n<meta property=\"og:description\" content=\"Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted\" \/>\n<meta property=\"og:url\" content=\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-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=\"2024-02-29T08:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-13T20:56:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/griddb.net\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1536\" \/>\n\t<meta property=\"og:image:height\" content=\"1536\" \/>\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=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/\"},\"author\":{\"name\":\"griddb-admin\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\"},\"headline\":\"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB\",\"datePublished\":\"2024-02-29T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:56:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/\"},\"wordCount\":837,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg\",\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/\",\"url\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/\",\"name\":\"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB | GridDB: Open Source Time Series Database for IoT\",\"isPartOf\":{\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage\"},\"thumbnailUrl\":\"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg\",\"datePublished\":\"2024-02-29T08:00:00+00:00\",\"dateModified\":\"2025-11-13T20:56:54+00:00\",\"description\":\"Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage\",\"url\":\"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg\",\"contentUrl\":\"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg\",\"width\":1536,\"height\":1536},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization\",\"name\":\"Fixstars\",\"url\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233\",\"name\":\"griddb-admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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":"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB | GridDB: Open Source Time Series Database for IoT","description":"Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted","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\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/","og_locale":"en_US","og_type":"article","og_title":"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB | GridDB: Open Source Time Series Database for IoT","og_description":"Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted","og_url":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-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":"2024-02-29T08:00:00+00:00","article_modified_time":"2025-11-13T20:56:54+00:00","og_image":[{"width":1536,"height":1536,"url":"https:\/\/griddb.net\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.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":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#article","isPartOf":{"@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/"},"author":{"name":"griddb-admin","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233"},"headline":"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB","datePublished":"2024-02-29T08:00:00+00:00","dateModified":"2025-11-13T20:56:54+00:00","mainEntityOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/"},"wordCount":837,"commentCount":0,"publisher":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg","articleSection":["Blog"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/","url":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/","name":"Predicting Ice Cream Sales Based on Temperature Using Java and GridDB | GridDB: Open Source Time Series Database for IoT","isPartOf":{"@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage"},"image":{"@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage"},"thumbnailUrl":"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg","datePublished":"2024-02-29T08:00:00+00:00","dateModified":"2025-11-13T20:56:54+00:00","description":"Introduction Linear regression analysis helps us to predict the value of a variable based on the value of another variable. The variable to be predicted","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb.net\/en\/blog\/predicting-ice-cream-sales-based-on-temperature-using-java-and-griddb\/#primaryimage","url":"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg","contentUrl":"\/wp-content\/uploads\/2024\/02\/Gemini_Generated_Image-3.jpeg","width":1536,"height":1536},{"@type":"WebSite","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#website","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#organization","name":"Fixstars","url":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.net\/en\/#\/schema\/person\/4fe914ca9576878e82f5e8dd3ba52233","name":"griddb-admin","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/griddb-linux-hte8hndjf8cka8ht.westus-01.azurewebsites.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\/46793","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=46793"}],"version-history":[{"count":1,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46793\/revisions"}],"predecessor-version":[{"id":51455,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/posts\/46793\/revisions\/51455"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media\/30008"}],"wp:attachment":[{"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/media?parent=46793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/categories?post=46793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/griddb.net\/en\/wp-json\/wp\/v2\/tags?post=46793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}