<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Johnson Adebayo on Medium]]></title>
        <description><![CDATA[Stories by Johnson Adebayo on Medium]]></description>
        <link>https://medium.com/@mailjohnson.adebayo?source=rss-1d3d0a064fa1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*-u5ufQwAINUW_5C1ufa2Ug.jpeg</url>
            <title>Stories by Johnson Adebayo on Medium</title>
            <link>https://medium.com/@mailjohnson.adebayo?source=rss-1d3d0a064fa1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:29:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mailjohnson.adebayo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building Insurance Pricing Platform with R — InsurrApp]]></title>
            <link>https://medium.com/building-insurance-pricing-platform-with-r/building-insurance-pricing-platform-with-r-insurrapp-12eb00f5fd7e?source=rss-1d3d0a064fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/12eb00f5fd7e</guid>
            <dc:creator><![CDATA[Johnson Adebayo]]></dc:creator>
            <pubDate>Thu, 27 Aug 2020 00:48:31 GMT</pubDate>
            <atom:updated>2020-08-27T12:12:48.852Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Insurance Pricing Platform with R — InsurrApp</h3><h3>Building Insurance Pricing Platform with R — InsurrApp</h3><ol><li><strong>Introduction</strong></li></ol><p>InsurrApp is an insurance pricing platform that uses both machine learning and predictive analytics to predict medical insurance costs of customers using their information such as age, number of children, BMI, Smoking status, region and sex. The model that this platform works on was built using Linear Regression algorithm to predict the medical charges of customers.</p><p>This article highlights the various processes for building InsurrApp Model, building web platform with Flexdashboard and shiny, and steps for deploying the app on shinyapps.io.</p><p><strong>2.</strong> <strong>Description of Dataset</strong></p><p>The dataset (insurance.csv) used in building model that this platform makes prediction with was gotten from <a href="https://www.kaggle.com/mirichoi0218/insurance">https://www.kaggle.com/mirichoi0218/insurance</a>.</p><p>The insurance dataset has seven columns with their descriptions below:</p><p>· age: Age of primary beneficiary.</p><p>· age: Age of primary beneficiary.</p><p>· sex: insurance contractor gender (female, male).</p><p>· bmi: Body mass index, providing an understanding of body, weights that are relatively high or low relative to height, objective index of body weight (kg / m ^ 2) using the ratio of height to weight, ideally 18.5 to 24.9.</p><p>· children: Number of children covered by health insurance / Number of dependents.</p><p>· smoker: Smoking (yes, no).</p><p>· region: The beneficiary’s residential area in the US (northeast, southeast, southwest, northwest).</p><p>· charges: Individual medical costs billed by health insurance</p><p><strong>3.</strong> <strong>Understanding the data:</strong></p><p>To understand the dataset we load the insurance.csv with the code below, then check its structure using str() function.</p><pre># Loading required packages</pre><pre>library(flexdashboard)<br>library(shiny)<br>library(shinythemes)<br>library(e1071)<br>library(caret)</pre><pre>insuranceDT &lt;- read.csv(“insurance.csv”)</pre><pre># insuranceDT2 created for EDA<br>insuranceDT2 &lt;- insuranceDT</pre><pre>head(insuranceDT)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*RNk9sCYlbBa51AoUaA7rzA.jpeg" /></figure><pre># Checking the structure of the dataset</pre><pre>Str(insuranceDT)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*BUBLoB-ViryC50FHzRcIzg.jpeg" /></figure><pre># Checking missing values in the dataset</pre><pre>anyNa(insuranceDT)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*BmTu_ESNsFM3_OUu-ZD6kA.jpeg" /></figure><p><strong>4.</strong> <strong>Exploratory Data Analysis</strong></p><p>Here we created simple chats that gave us more insights on the data used in building the model used in InsurrApp.</p><pre>par(mfrow=c(1,2)) # To create two plots in a row</pre><pre>plot(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges Against Age&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;blue&quot;)</pre><pre>scatter.smooth(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges against Age with Linear Line&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;red&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1p9wtfBmeKC4zmB6Sk0xQ.jpeg" /></figure><p>From the plot above, we see that as Age goes up Charges for health insurance also trends up.</p><pre>plot(x=insuranceDT2$smoker, y=insuranceDT2$charges, main =&quot;Boxplot of Charges Against Smoking Status&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Smoker&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ZLA3DcxJtSKmqMQCoyKV_Q.jpeg" /></figure><p>The boxplot above shows that charges for smokers are higher than non-smokers.</p><pre>par(mfrow=c(1,3))</pre><pre>plot(density(insuranceDT2$age), main=&quot;Density Plot: Age&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$age), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$age), col=&quot;blue&quot;)</pre><pre>plot(density(insuranceDT2$bmi), main=&quot;Density Plot: BMI&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$bmi), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$bmi), col=&quot;orange&quot;)</pre><pre>plot(density(insuranceDT2$charges), main=&quot;Density Plot: Charges&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$charges), 2)))  # density plot for &#39;charges&#39;</pre><pre>polygon(density(insuranceDT2$charges), col=&quot;red&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4i4eKguWy0pJygRDCmHug.jpeg" /></figure><p>The density plot shows the distribution of the continuous data (Age, BMI and Charges).</p><p><strong>5.</strong> <strong>Data Preprocessing</strong></p><p>This is the stage of processing the dataset to make it suitable for building the model. For this project we convert the categorical variables sex, smoker and region into numeric using the syntax below;</p><pre>insuranceDT[&#39;sex&#39;] &lt;- sapply(insuranceDT[,&quot;sex&quot;], function(y){ifelse(y==&quot;female&quot;,1,0)}) # Convert &#39;female&#39; to 1 and male to 0</pre><pre>insuranceDT[&#39;smoker&#39;] &lt;- sapply(insuranceDT[,&quot;smoker&quot;], function(z){ ifelse(z==&quot;yes&quot;,1,0)}) # convert &#39;yes&#39; to 1 and &#39;no&#39; to 0</pre><pre>insuranceDT[&#39;region&#39;] &lt;-  sapply(insuranceDT[,&#39;region&#39;], function(x){</pre><pre>if(x==&#39;southwest&#39;){</pre><pre>x = 1</pre><pre>}else if(x==&#39;southeast&#39;){</pre><pre>x=2</pre><pre>}else if(x==&#39;northwest&#39;){</pre><pre>x=3</pre><pre>}else{</pre><pre>x=4</pre><pre>}</pre><pre>}) # Convert &#39;southwest&#39;,&#39;southeast&#39;,&#39;northwest&#39;and northeast to 1,2,3 and 4 respectively</pre><p><strong>6.</strong> <strong>Training the Model used for InsurrApp</strong></p><p>The model used in predicting medical charges in InsurrApp was built with Linear Regression algorithm with the following steps:</p><p>Step 1: Data Splitting</p><p>This is the step that involves splitting the dataset (insurance.csv) into a training set and a testing set. We will train our model (insurrModel) on the training set and then use the test set to evaluate the model (predict ‘charges’ variable).</p><pre>set.seed(100)</pre><pre>insurance_index &lt;- createDataPartition(insuranceDT$charges, p=0.8, list=FALSE)</pre><pre>train_insurance &lt;- insuranceDT[insurance_index,]</pre><pre>test_insurance &lt;- insuranceDT[-insurance_index,]</pre><pre># Optional</pre><pre>x_train &lt;- train_insurance[,c(1:6)]</pre><pre>y_train &lt;- train_insurance[,c(7)]</pre><pre>x_test &lt;- test_insurance[,c(1:6)]</pre><pre>y_test &lt;- test_insurance[&quot;charges&quot;]</pre><p>For this model, training set represents 80% of the whole dataset and test set take 20%.</p><p>To check the number of rows in both training and testing set</p><pre>nrow(train_insurance) # 1072</pre><pre>nrow(test_insurance) # 266</pre><pre>nrow(insuranceDT) # 1338</pre><p>Step 2: Train and Test Model</p><p>Now that we have splitted our dataset into train and test datasets, we can now fit our model using Linear regression and evaluate it to assess its performance.</p><pre>set.seed(100)</pre><pre>insurrModel &lt;- lm(charges~., data = train_insurance)</pre><p>To obtain the summary of the model we use summary()function.</p><pre>summary(insurrModel)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*TCeesTW_d4V5s3mddvxcxw.jpeg" /></figure><p>Step 3: Prediction From our Model (insurrModel)</p><pre>predict_insurance &lt;- predict(insurrModel, test_insurance)</pre><pre># Optional if the dataset is splitted into x and y variables</pre><pre>#predict_insurance &lt;- predict(insurrModel, x_test)</pre><p><strong>7.</strong> <strong>Comparing the Result</strong></p><p><strong>i.</strong> <strong>Let’s compare the result using a table showing ‘actual’ and ‘predicted’ values.</strong></p><pre>actual_predicted &lt;- data.frame(test_insurance$charges, predict_insurance)</pre><pre>colnames(actual_predicted) &lt;- c(&quot;Actual&quot;, &quot;Predicted&quot;)</pre><pre>head(actual_predicted) # To show actual_predicted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*vkUSNQyO4SWisqsOWhID6g.jpeg" /></figure><p><strong>ii.</strong> <strong>Comparing the actual and predicted charges by their correlation.</strong></p><pre>correlation_accuracy &lt;- cor(actual_predicted)</pre><pre>correlation_accuracy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*HaIQTnxGHq-j-unT1U7mag.jpeg" /></figure><p><strong>iii.</strong> <strong>Comparing the actual and predicted charges using Scatter plot</strong></p><pre>plot(x=actual_predicted$Actual, y=actual_predicted$Predicted, xlab =&quot;Actual Charges&quot;,ylab = &quot;Predicted Charges&quot;, main =&quot;Result of Predicted and Actual&quot;,col=&quot;blue&quot;,pch = 16, cex=1.5)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQTOKk5dWX-KGlFfmt-gJQ.jpeg" /></figure><p>From the output of the three methods of comparing the actual and predicted charges, we see that there is a positive correlation between them which shows that the performance of the model is a good one.</p><p>Note: To predict new user’s entry data with the following data;</p><p>age — 40 years</p><p>sex — ‘female’ (1)</p><p>bmi — 45.50</p><p>children — 4</p><p>smoker — ‘no’ (0)</p><p>region — ‘northwest’ (3)</p><p>Firstly, create a function that will convert the user’s input to dataframe with the code below;</p><pre># Creating function that will converts user&#39;s data to a dataframe</pre><pre>data_function &lt;- function(a, b, c,d,e,f){</pre><pre>testData &lt;- data.frame(col1=c(a),col2=c(b),col3=c(c),col4=c(d),col5=c(e),col6=c(f))</pre><pre>colnames(testData) &lt;- colnames(x_test)</pre><pre>return(testData)</pre><pre>}</pre><p>Secondly, pass the user’s data as arguments or parameters into the function created (data_function).</p><pre>newData2 &lt;- data_function(40,1,50,4,0,3)</pre><pre>newData2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*54R5fi2qiO_5Mng3MlAq2g.jpeg" /></figure><p>Thirdly, use the converted user’s data to predict his/her charges with the code below;</p><pre>james_Predict &lt;- predict(insurance_model, newData2)</pre><pre>cat(“Medical Insurance cost of James is: #”, james_Predict)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*r09zVYWSDwNVbmeDM0y3ew.jpeg" /></figure><p><strong>8.</strong> <strong>Collecting User’s Data from the InsurrApp UI</strong></p><p>User’s data are collected from the Insurrapp’s UI using the following functions in shiny package depending on the type of input we want to collect from the user textInput(), numericInput(), selectinput(), submitButton(), actionButton() etc.</p><pre># Customer&#39;s name entry</pre><pre>textInput(&quot;name&quot;,label = &quot;Customer&#39;s Name&quot;, placeholder =&quot;Enter Customer Name&quot;)</pre><pre># Customer’s age input</pre><pre>numericInput(&quot;age&quot;, label =&quot;Age&quot;,value = 1, min = 1, max = 1000 )</pre><pre># Customer’s sex input</pre><pre>selectInput(&quot;sex&quot;, label = &quot;Sex&quot;,choices = c(&quot;male&quot;,&quot;female&quot;))</pre><pre># Customer’s bmi input</pre><pre>numericInput(&quot;bmi&quot;, label =&quot;Body Mass Index (BMI)&quot;,value = 1, min = 1, max = 1000)</pre><pre># customer’s number of children input</pre><pre>numericInput(&quot;children&quot;, label =&quot;Number of Children&quot;,value = 0, min = 0, max = 1000)</pre><pre># Customer’s region selection input</pre><pre>selectInput(&quot;region&quot;, label =&quot;Region&quot;,choices = c(&quot;southwest&quot;,&quot;southeast&quot;,&quot;northwest&quot;,&quot;northeast&quot;))</pre><pre># Customer’s smoking status selection input</pre><pre>selectInput(&quot;smoker&quot;, label =&quot;Smoking Status&quot;,choices = c(&quot;yes&quot;,&quot;no&quot;) )</pre><pre>actionButton(&quot;submit&quot;, &quot;Submit&quot;)</pre><p><strong>9.</strong> <strong>Creating Data Pipeline to Link and Predict User’s Entry from the UI of InsurrApp to the Model (InsurrModel)</strong></p><p>What we are doing here is to make sure we carry out all the various processes of transforming the training dataset on the new user’s entry data using the code below.</p><p>Note: The reactive() function used in the blocks of codes below is an expression that uses widget inputs and returns a value. The reactive expressions will update these values when never the widget changes due to the entries by the user of InsurrApp. This function is used in Flexdashboard (package for building interactive dashboards) to create updatable dashboard.</p><pre># Converting sex, smoker status and region variables from factor to numeric</pre><pre>sex1 &lt;- reactive({</pre><pre>sex2 &lt;- sapply(input$sex, function(y){ifelse(y==&quot;female&quot;,1,0)})</pre><pre>return(sex2)</pre><pre>})</pre><pre>smoker1 &lt;- reactive({</pre><pre>smoker2 &lt;- sapply(input$smoker , function(z){ ifelse(z==&quot;yes&quot;,1,0)})</pre><pre>return(smoker2)</pre><pre>})</pre><pre>region1 &lt;- reactive({</pre><pre>region2 &lt;- sapply(input$region, function(x){</pre><pre>if(x==&#39;southwest&#39;){</pre><pre>x = 1</pre><pre>}else if(x==&#39;southeast&#39;){</pre><pre>x=2</pre><pre>}else if(x==&#39;northwest&#39;){</pre><pre>x=3</pre><pre>}else{</pre><pre>x=4</pre><pre>}</pre><pre>})</pre><pre>return(region2)</pre><pre>})</pre><pre># Combining all the user’s entry and convert to dataframe</pre><pre>userdata_function &lt;- reactive({</pre><pre>if(input$submit&gt;0){</pre><pre>#userDT &lt;- data.frame(col1=c(input$age),col2=c(input$sex),col3=c(input$bmi),col4=c(input$children),col5=c(input$smoker),col6=c(input$region))</pre><pre>userDT &lt;- data.frame(col1=c(input$age),col2=c(sex1()),col3=c(input$bmi),col4=c(input$children),col5=c(smoker1()),col6=c(region1()))<br>  colnames(userDT) &lt;- colnames(x_test) # changing the columns names of userDT to conform with insuranceDT</pre><pre>return(userDT)</pre><pre>}</pre><pre>})</pre><pre># Model training</pre><pre>set.seed(100)</pre><pre>insurance_model &lt;- reactive({</pre><pre>insurrApp &lt;- lm(charges~., data = train_insurance)</pre><pre>return(insurrApp)</pre><pre>})</pre><pre># Using the model to predict the medical charges of new user’s data</pre><pre>model_pred &lt;- reactive({</pre><pre>pred &lt;- round(predict(insurance_model(), userdata_function()),2)</pre><pre>return(pred)</pre><pre>})</pre><p><strong>10.</strong> <strong>Displaying User’s Predicted Medical Charges on the UI of InsurrApp</strong></p><p>The essence of this is to display the amount of insurance charges to the user based on the data entered by the user.</p><pre>renderText({</pre><pre>if(input$submit==0){</pre><pre>paste(&quot;Enter applicant data to obtain charges.&quot;)</pre><pre>}else if(model_pred()&lt;0){</pre><pre>paste(&quot;No prediction make! Check customer&#39;s details entered&quot;)</pre><pre>}else{</pre><pre>paste(input$name, &quot;insurance charges is : #&quot;, model_pred())</pre><pre>}</pre><pre>})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qHbTecUXVNF4SSa1CEZCoQ.jpeg" /></figure><p><strong>11.</strong> <strong>Displaying Plots for EDA on the InsurrApp</strong></p><p>The various EDA carried out earlier were displayed on the InsurrApp with renderPlot() function. The blocks of codes below are used to display the plot on ‘Insurance Data EDA’ storyboard components on InsurrApp.</p><p>A. Boxplots of Customers Ages</p><pre># Boxplot to check outliers in smoker status, sex and region based on age</pre><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>boxplot(insuranceDT2$age~insuranceDT2$smoker, main=&quot;Boxplot of Age against Smoker&quot;,xlab =&quot;Smoker&quot;, ylab = &quot;Age&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><pre>boxplot(insuranceDT2$age~insuranceDT2$region, main=&quot;Boxplot of Age against Region&quot;,xlab =&quot;Region&quot;, ylab = &quot;Age&quot;, col=c(&quot;blue&quot;,&quot;green&quot;,&quot;orange&quot;,&quot;red&quot;))</pre><pre>boxplot(insuranceDT2$age~insuranceDT2$sex, main=&quot;Boxplot of Age against Smoker&quot;,xlab =&quot;Sex&quot;, ylab = &quot;Age&quot;, col=c(&quot;green&quot;,&quot;red&quot;))</pre><pre>})</pre><p>B. Boxplots of Customers BMI</p><pre># Boxplot to check outliers in smoker status, sex and region based on bmi</pre><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>boxplot(insuranceDT2$bmi~insuranceDT2$smoker, main=&quot;Boxplot of BMI against Smoker&quot;,xlab =&quot;Smoker&quot;, ylab = &quot;BMI&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><pre>boxplot(insuranceDT2$bmi~insuranceDT2$region, main=&quot;Boxplot of BMI against Region&quot;,xlab =&quot;Region&quot;,ylab = &quot;BMI&quot;, col=c(&quot;blue&quot;,&quot;green&quot;,&quot;orange&quot;,&quot;red&quot;))</pre><pre>boxplot(insuranceDT2$bmi~insuranceDT2$sex, main=&quot;Boxplot of BMI against Smoker&quot;,xlab =&quot;Sex&quot;, ylab = &quot;BMI&quot;, col=c(&quot;green&quot;,&quot;red&quot;))</pre><pre>})</pre><p>C. Histogram Plots of Continuous Variables</p><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>hist(insuranceDT2$age, main =&quot;Distribution of Ages&quot;, ylab = &quot;Frequency&quot;,xlab =&quot;Age&quot;,col =&quot;blue&quot;)</pre><pre>hist(insuranceDT2$bmi,main =&quot;Distribution of BMI&quot;, ylab = &quot;Frequency&quot;,xlab =&quot;BMI&quot;, col =&quot;orange&quot;)</pre><pre>hist(insuranceDT2$charges, main =&quot;Distribution of Charges&quot;, ylab = &quot;Frequency&quot;,xlab =&quot;Charges&quot;,col = &quot;red&quot;)</pre><pre>})</pre><p>D. Density Plots of Continuous Variables</p><pre># Density Plot of continuous variables</pre><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>plot(density(insuranceDT2$age), main=&quot;Density Plot: Age&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$age), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$age), col=&quot;blue&quot;)</pre><pre>plot(density(insuranceDT2$bmi), main=&quot;Density Plot: BMI&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$bmi), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$bmi), col=&quot;orange&quot;)</pre><pre>plot(density(insuranceDT2$charges), main=&quot;Density Plot: Charges&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$charges), 2)))  # density plot for &#39;charges&#39;<br>  polygon(density(insuranceDT2$charges), col=&quot;red&quot;)</pre><pre>})</pre><p>E. Scatter Plots of Charges Against Ages of Customers</p><pre>renderPlot({</pre><pre>par(mfrow=c(1,2))</pre><pre>plot(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges Against Age&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;blue&quot;)</pre><pre>scatter.smooth(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges against Age with Linear Line&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;red&quot;)</pre><pre>})</pre><p>F. Boxplots of Charges Based on Smoking Status</p><pre>renderPlot({</pre><pre>#par(mfrow=c(1,2))</pre><pre>plot(x=insuranceDT2$smoker, y=insuranceDT2$charges, main =&quot;Boxplot of Charges Against Smoking Status&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Smoker&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><pre>})</pre><p><strong>12.</strong> <strong>Deployment of InsurApp</strong></p><p><strong>i.</strong> <strong>Local deployment: </strong>The run() function is used for deploying the app locally for testing with the code below.</p><pre># rmarkdown::run(&quot;path_to_file/fileName&quot;)</pre><pre>rmarkdown::run(&quot;InsurrApp.Rmd&quot;)</pre><p><strong>ii.</strong> <strong>Cloud deployment (</strong><a href="https://www.shinyapps.io/">https://www.shinyapps.io/</a>)<strong>:</strong> shinyapps.io is a cloud platform for deploying shiny applications. The following steps are taken in deploying the app in shinyapps.io</p><p>· <strong>Create ShinyApps account on</strong> <a href="http://www.shinyapps.io/">http://www.shinyapps.io/</a>.</p><p>· <strong>Set up your account on your local system using rsconnect::setAccountInfo.</strong></p><pre>rsconnect::setAccountInfo(name=&#39;jhonsphorus&#39;,token=&#39;612DAB51005159762881CF2CAA8BC4A4&#39;, secret=&#39;&lt;SECRET&gt;&#39;)</pre><p>· <strong>Use the button below on R Studio to deploy your app to shinyapps.io</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHYFHl-b8G_Oyhp2I4zMOA.jpeg" /></figure><p>· <strong>Then click on ‘Publish’</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cAKniYzkIdA5ivtkqJ19Q.jpeg" /></figure><p><strong>13.</strong> <strong>Navigating through InsurrApp Pages</strong></p><p><strong>i.</strong> <strong>Landing Page/Insurance Charges Prediction</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmUpj9Wjp_61WwvujADlRg.jpeg" /></figure><p><strong>ii.</strong> <strong>Insurance Data EDA Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wVXLc0hJmzp-cURFjzovSQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAcnbETQTTyoFi7b69Ck3g.jpeg" /></figure><p><strong>iii.</strong> <strong>About Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mbNZd6oTKozHIMwDpB8HIg.jpeg" /></figure><p><strong>iv.</strong> <strong>Projects Portfolio Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppcJaLFKbZuBynb4IXOGPg.jpeg" /></figure><p><strong>v.</strong> <strong>Contact Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JXnEmYDQwr3lefsDiZk7CQ.jpeg" /></figure><p><strong>14.</strong> <strong>Link to InsurrApp After Deployment</strong></p><p>The link to InsurrApp is<strong> </strong><a href="https://phorus2.shinyapps.io/InsurrApp/">https://phorus2.shinyapps.io/InsurrApp/</a></p><p>Thank you for taking time to read this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12eb00f5fd7e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/building-insurance-pricing-platform-with-r/building-insurance-pricing-platform-with-r-insurrapp-12eb00f5fd7e">Building Insurance Pricing Platform with R — InsurrApp</a> was originally published in <a href="https://medium.com/building-insurance-pricing-platform-with-r">Building Insurance Pricing Platform with R — InsurrApp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Insurance Pricing Platform with R — InsurrApp]]></title>
            <link>https://medium.com/building-insurance-pricing-platform-with-r/building-insurance-pricing-platform-with-r-insurrapp-dff2c002e168?source=rss-1d3d0a064fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/dff2c002e168</guid>
            <dc:creator><![CDATA[Johnson Adebayo]]></dc:creator>
            <pubDate>Thu, 27 Aug 2020 00:11:17 GMT</pubDate>
            <atom:updated>2020-08-27T12:09:11.187Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Insurance Pricing Platform with R — InsurrApp</h3><ol><li><strong>Introduction</strong></li></ol><p>InsurrApp is an insurance pricing platform that uses both machine learning and predictive analytics to predict medical insurance costs of customers using their information such as age, number of children, BMI, Smoking status, region and sex. The model that this platform works on was built using Linear Regression algorithm to predict the medical charges of customers.</p><p>This article highlights the various processes for building InsurrApp Model, building web platform with Flexdashboard and shiny, and steps for deploying the app on shinyapps.io.</p><p><strong>2.</strong> <strong>Description of Dataset</strong></p><p>The dataset (insurance.csv) used in building model that this platform makes prediction with was gotten from <a href="https://www.kaggle.com/mirichoi0218/insurance">https://www.kaggle.com/mirichoi0218/insurance</a>.</p><p>The insurance dataset has seven columns with their descriptions below:</p><p>· age: Age of primary beneficiary.</p><p>· age: Age of primary beneficiary.</p><p>· sex: insurance contractor gender (female, male).</p><p>· bmi: Body mass index, providing an understanding of body, weights that are relatively high or low relative to height, objective index of body weight (kg / m ^ 2) using the ratio of height to weight, ideally 18.5 to 24.9.</p><p>· children: Number of children covered by health insurance / Number of dependents.</p><p>· smoker: Smoking (yes, no).</p><p>· region: The beneficiary&#39;s residential area in the US (northeast, southeast, southwest, northwest).</p><p>· charges: Individual medical costs billed by health insurance</p><p><strong>3.</strong> <strong>Understanding the data:</strong></p><p>To understand the dataset we load the insurance.csv with the code below, then check its structure using str() function.</p><pre># Loading required packages</pre><pre>library(flexdashboard)<br>library(shiny)<br>library(shinythemes)<br>library(e1071)<br>library(caret)</pre><pre>insuranceDT &lt;- read.csv(“insurance.csv”)</pre><pre>insuranceDT2 &lt;- insuranceDT</pre><pre>head(insuranceDT)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*RNk9sCYlbBa51AoUaA7rzA.jpeg" /></figure><pre># Checking the structure of the dataset</pre><pre>Str(insuranceDT)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*BUBLoB-ViryC50FHzRcIzg.jpeg" /></figure><pre># Checking missing values in the dataset</pre><pre>anyNa(insuranceDT)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*BmTu_ESNsFM3_OUu-ZD6kA.jpeg" /></figure><p><strong>4.</strong> <strong>Exploratory Data Analysis</strong></p><p>Here we created simple chats that gave us more insights on the data used in building the model used in InsurrApp.</p><pre>par(mfrow=c(1,2)) # To create two plots in a row</pre><pre>plot(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges Against Age&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;blue&quot;)</pre><pre>scatter.smooth(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges against Age with Linear Line&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;red&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1p9wtfBmeKC4zmB6Sk0xQ.jpeg" /></figure><p>From the plot above, we see that as Age goes up Charges for health insurance also trends up.</p><pre>plot(x=insuranceDT2$smoker, y=insuranceDT2$charges, main =&quot;Boxplot of Charges Against Smoking Status&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Smoker&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*ZLA3DcxJtSKmqMQCoyKV_Q.jpeg" /></figure><p>The boxplot above shows that charges for smokers are higher than non-smokers.</p><pre>par(mfrow=c(1,3))</pre><pre>plot(density(insuranceDT2$age), main=&quot;Density Plot: Age&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$age), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$age), col=&quot;blue&quot;)</pre><pre>plot(density(insuranceDT2$bmi), main=&quot;Density Plot: BMI&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$bmi), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$bmi), col=&quot;orange&quot;)</pre><pre>plot(density(insuranceDT2$charges), main=&quot;Density Plot: Charges&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$charges), 2)))  # density plot for &#39;charges&#39;</pre><pre>polygon(density(insuranceDT2$charges), col=&quot;red&quot;)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B4i4eKguWy0pJygRDCmHug.jpeg" /></figure><p>The density plot shows the distribution of the continuous data (Age, BMI and Charges).</p><p><strong>5.</strong> <strong>Data Preprocessing</strong></p><p>This is the stage of processing the dataset to make it suitable for building the model. For this project we convert the categorical variables sex, smoker and region into numeric using the syntax below;</p><pre>insuranceDT[&#39;sex&#39;] &lt;- sapply(insuranceDT[,&quot;sex&quot;], function(y){ifelse(y==&quot;female&quot;,1,0)}) # Convert &#39;female&#39; to 1 and male to 0</pre><pre>insuranceDT[&#39;smoker&#39;] &lt;- sapply(insuranceDT[,&quot;smoker&quot;], function(z){ ifelse(z==&quot;yes&quot;,1,0)}) # convert &#39;yes&#39; to 1 and &#39;no&#39; to 0</pre><pre>insuranceDT[&#39;region&#39;] &lt;-  sapply(insuranceDT[,&#39;region&#39;], function(x){</pre><pre>if(x==&#39;southwest&#39;){</pre><pre>x = 1</pre><pre>}else if(x==&#39;southeast&#39;){</pre><pre>x=2</pre><pre>}else if(x==&#39;northwest&#39;){</pre><pre>x=3</pre><pre>}else{</pre><pre>x=4</pre><pre>}</pre><pre>}) # Convert &#39;southwest&#39;,&#39;southeast&#39;,&#39;northwest&#39;and northeast to 1,2,3 and 4 respectively</pre><p><strong>6.</strong> <strong>Training the Model used for InsurrApp</strong></p><p>The model used in predicting medical charges in InsurrApp was built with Linear Regression algorithm with the following steps:</p><p>Step 1: Data Splitting</p><p>This is the step that involves splitting the dataset (insurance.csv) into a training set and a testing set. We will train our model (insurrModel) on the training set and then use the test set to evaluate the model (predict ‘charges’ variable).</p><pre>set.seed(100)</pre><pre>insurance_index &lt;- createDataPartition(insuranceDT$charges, p=0.8, list=FALSE)</pre><pre>train_insurance &lt;- insuranceDT[insurance_index,]</pre><pre>test_insurance &lt;- insuranceDT[-insurance_index,]</pre><pre># Optional</pre><pre>x_train &lt;- train_insurance[,c(1:6)]</pre><pre>y_train &lt;- train_insurance[,c(7)]</pre><pre>x_test &lt;- test_insurance[,c(1:6)]</pre><pre>y_test &lt;- test_insurance[&quot;charges&quot;]</pre><p>For this model, training set represents 80% of the whole dataset and test set take 20%.</p><p>To check the number of rows in both training and testing set</p><pre>nrow(train_insurance) # 1072</pre><pre>nrow(test_insurance) # 266</pre><pre>nrow(insuranceDT) # 1338</pre><p>Step 2: Train and Test Model</p><p>Now that we have splitted our dataset into train and test datasets, we can now fit our model using Linear regression and evaluate it to assess its performance.</p><pre>set.seed(100)</pre><pre>insurrModel &lt;- lm(charges~., data = train_insurance)</pre><p>To obtain the summary of the model we use summary()function.</p><pre>summary(insurrModel)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1013/1*TCeesTW_d4V5s3mddvxcxw.jpeg" /></figure><p>Step 3: Prediction From our Model (insurrModel)</p><pre>predict_insurance &lt;- predict(insurrModel, test_insurance)</pre><pre># Optional if the dataset is splitted into x and y variables</pre><pre>#predict_insurance &lt;- predict(insurrModel, x_test)</pre><p><strong>7.</strong> <strong>Comparing the Result</strong></p><p><strong>i.</strong> <strong>Let’s compare the result using a table showing ‘actual’ and ‘predicted’ values.</strong></p><pre>actual_predicted &lt;- data.frame(test_insurance$charges, predict_insurance)</pre><pre>colnames(actual_predicted) &lt;- c(&quot;Actual&quot;, &quot;Predicted&quot;)</pre><pre>head(actual_predicted) # To show actual_predicted</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1008/1*vkUSNQyO4SWisqsOWhID6g.jpeg" /></figure><p><strong>ii.</strong> <strong>Comparing the actual and predicted charges by their correlation.</strong></p><pre>correlation_accuracy &lt;- cor(actual_predicted)</pre><pre>correlation_accuracy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1002/1*HaIQTnxGHq-j-unT1U7mag.jpeg" /></figure><p><strong>iii.</strong> <strong>Comparing the actual and predicted charges using Scatter plot</strong></p><pre>plot(x=actual_predicted$Actual, y=actual_predicted$Predicted, xlab =&quot;Actual Charges&quot;,ylab = &quot;Predicted Charges&quot;, main =&quot;Result of Predicted and Actual&quot;,col=&quot;blue&quot;,pch = 16, cex=1.5)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aQTOKk5dWX-KGlFfmt-gJQ.jpeg" /></figure><p>From the output of the three methods of comparing the actual and predicted charges, we see that there is a positive correlation between them which shows that the performance of the model is a good one.</p><p>Note: To predict new user’s entry data with the following data;</p><p>age – 40 years</p><p>sex – ‘female’ (1)</p><p>bmi – 45.50</p><p>children – 4</p><p>smoker – ‘no’ (0)</p><p>region – ‘northwest’ (3)</p><p>Firstly, create a function that will convert the user’s input to dataframe with the code below;</p><pre># Creating function that will converts user&#39;s data to a dataframe</pre><pre>data_function &lt;- function(a, b, c,d,e,f){</pre><pre>testData &lt;- data.frame(col1=c(a),col2=c(b),col3=c(c),col4=c(d),col5=c(e),col6=c(f))</pre><pre>colnames(testData) &lt;- colnames(x_test)</pre><pre>return(testData)</pre><pre>}</pre><p>Secondly, pass the user’s data as arguments or parameters into the function created (data_function).</p><pre>newData2 &lt;- data_function(40,1,50,4,0,3)</pre><pre>newData2</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*54R5fi2qiO_5Mng3MlAq2g.jpeg" /></figure><p>Thirdly, use the converted user’s data to predict his/her charges with the code below;</p><pre>james_Predict &lt;- predict(insurance_model, newData2)</pre><pre>cat(“Medical Insurance cost of James is: #”, james_Predict)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1001/1*r09zVYWSDwNVbmeDM0y3ew.jpeg" /></figure><p><strong>8.</strong> <strong>Collecting User’s Data from the InsurrApp UI</strong></p><p>User’s data are collected from the Insurrapp’s UI using the following functions in shiny package depending on the type of input we want to collect from the user textInput(), numericInput(), selectinput(), submitButton(), actionButton() etc.</p><pre># Customer&#39;s name entry</pre><pre>textInput(&quot;name&quot;,label = &quot;Customer&#39;s Name&quot;, placeholder =&quot;Enter Customer Name&quot;)</pre><pre># Customer’s age input</pre><pre>numericInput(&quot;age&quot;, label =&quot;Age&quot;,value = 1, min = 1, max = 1000 )</pre><pre># Customer’s sex input</pre><pre>selectInput(&quot;sex&quot;, label = &quot;Sex&quot;,choices = c(&quot;male&quot;,&quot;female&quot;))</pre><pre># Customer’s bmi input</pre><pre>numericInput(&quot;bmi&quot;, label =&quot;Body Mass Index (BMI)&quot;,value = 1, min = 1, max = 1000)</pre><pre># customer’s number of children input</pre><pre>numericInput(&quot;children&quot;, label =&quot;Number of Children&quot;,value = 0, min = 0, max = 1000)</pre><pre># Customer’s region selection input</pre><pre>selectInput(&quot;region&quot;, label =&quot;Region&quot;,choices = c(&quot;southwest&quot;,&quot;southeast&quot;,&quot;northwest&quot;,&quot;northeast&quot;))</pre><pre># Customer’s smoking status selection input</pre><pre>selectInput(&quot;smoker&quot;, label =&quot;Smoking Status&quot;,choices = c(&quot;yes&quot;,&quot;no&quot;) )</pre><pre>actionButton(&quot;submit&quot;, &quot;Submit&quot;)</pre><p><strong>9.</strong> <strong>Creating Data Pipeline to Link and Predict User’s Entry from the UI of InsurrApp to the Model (InsurrModel)</strong></p><p>What we are doing here is to make sure we carry out all the various processes of transforming the training dataset on the new user’s entry data using the code below.</p><p>Note: The reactive() function used in the blocks of codes below is an expression that uses widget inputs and returns a value. The reactive expressions will update these values when never the widget changes due to the entries by the user of InsurrApp. This function is used in Flexdashboard (package for building interactive dashboards) to create updatable dashboard.</p><pre># Converting sex, smoker status and region variables from factor to numeric</pre><pre>sex1 &lt;- reactive({</pre><pre>sex2 &lt;- sapply(input$sex, function(y){ifelse(y==&quot;female&quot;,1,0)})</pre><pre>return(sex2)</pre><pre>})</pre><pre>smoker1 &lt;- reactive({</pre><pre>smoker2 &lt;- sapply(input$smoker , function(z){ ifelse(z==&quot;yes&quot;,1,0)})</pre><pre>return(smoker2)</pre><pre>})</pre><pre>region1 &lt;- reactive({</pre><pre>region2 &lt;- sapply(input$region, function(x){</pre><pre>if(x==&#39;southwest&#39;){</pre><pre>x = 1</pre><pre>}else if(x==&#39;southeast&#39;){</pre><pre>x=2</pre><pre>}else if(x==&#39;northwest&#39;){</pre><pre>x=3</pre><pre>}else{</pre><pre>x=4</pre><pre>}</pre><pre>})</pre><pre>return(region2)</pre><pre>})</pre><pre># Combining all the user’s entry and convert to dataframe</pre><pre>userdata_function &lt;- reactive({</pre><pre>if(input$submit&gt;0){</pre><pre>#userDT &lt;- data.frame(col1=c(input$age),col2=c(input$sex),col3=c(input$bmi),col4=c(input$children),col5=c(input$smoker),col6=c(input$region))</pre><pre>userDT &lt;- data.frame(col1=c(input$age),col2=c(sex1()),col3=c(input$bmi),col4=c(input$children),col5=c(smoker1()),col6=c(region1()))<br>  colnames(userDT) &lt;- colnames(x_test) # changing the columns names of userDT to conform with insuranceDT</pre><pre>return(userDT)</pre><pre>}</pre><pre>})</pre><pre># Model training</pre><pre>set.seed(100)</pre><pre>insurance_model &lt;- reactive({</pre><pre>insurrApp &lt;- lm(charges~., data = train_insurance)</pre><pre>return(insurrApp)</pre><pre>})</pre><pre># Using the model to predict the medical charges of new user’s data</pre><pre>model_pred &lt;- reactive({</pre><pre>pred &lt;- round(predict(insurance_model(), userdata_function()),2)</pre><pre>return(pred)</pre><pre>})</pre><p><strong>10.</strong> <strong>Displaying User’s Predicted Medical Charges on the UI of InsurrApp</strong></p><p>The essence of this is to display the amount of insurance charges to the user based on the data entered by the user.</p><pre>renderText({</pre><pre>if(input$submit==0){</pre><pre>paste(&quot;Enter applicant data to obtain charges.&quot;)</pre><pre>}else if(model_pred()&lt;0){</pre><pre>paste(&quot;No prediction make! Check customer&#39;s details entered&quot;)</pre><pre>}else{</pre><pre>paste(input$name, &quot;insurance charges is : #&quot;, model_pred())</pre><pre>}</pre><pre>})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qHbTecUXVNF4SSa1CEZCoQ.jpeg" /></figure><p><strong>11.</strong> <strong>Displaying Plots for EDA on the InsurrApp</strong></p><p>The various EDA carried out earlier were displayed on the InsurrApp with renderPlot() function. The blocks of codes below are used to display the plot on ‘Insurance Data EDA’ storyboard components on InsurrApp.</p><p>A. Boxplots of Customers Ages</p><pre># Boxplot to check outliers in smoker status, sex and region based on age</pre><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>boxplot(insuranceDT2$age~insuranceDT2$smoker, main=&quot;Boxplot of Age against Smoker&quot;,xlab =&quot;Smoker&quot;, ylab = &quot;Age&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><pre>boxplot(insuranceDT2$age~insuranceDT2$region, main=&quot;Boxplot of Age against Region&quot;,xlab =&quot;Region&quot;, ylab = &quot;Age&quot;, col=c(&quot;blue&quot;,&quot;green&quot;,&quot;orange&quot;,&quot;red&quot;))</pre><pre>boxplot(insuranceDT2$age~insuranceDT2$sex, main=&quot;Boxplot of Age against Smoker&quot;,xlab =&quot;Sex&quot;, ylab = &quot;Age&quot;, col=c(&quot;green&quot;,&quot;red&quot;))</pre><pre>})</pre><p>B. Boxplots of Customers BMI</p><pre># Boxplot to check outliers in smoker status, sex and region based on bmi</pre><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>boxplot(insuranceDT2$bmi~insuranceDT2$smoker, main=&quot;Boxplot of BMI against Smoker&quot;,xlab =&quot;Smoker&quot;, ylab = &quot;BMI&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><pre>boxplot(insuranceDT2$bmi~insuranceDT2$region, main=&quot;Boxplot of BMI against Region&quot;,xlab =&quot;Region&quot;,ylab = &quot;BMI&quot;, col=c(&quot;blue&quot;,&quot;green&quot;,&quot;orange&quot;,&quot;red&quot;))</pre><pre>boxplot(insuranceDT2$bmi~insuranceDT2$sex, main=&quot;Boxplot of BMI against Smoker&quot;,xlab =&quot;Sex&quot;, ylab = &quot;BMI&quot;, col=c(&quot;green&quot;,&quot;red&quot;))</pre><pre>})</pre><p>C. Histogram Plots of Continuous Variables</p><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>hist(insuranceDT2$age, main =&quot;Distribution of Ages&quot;, ylab = &quot;Frequency&quot;,xlab =&quot;Age&quot;,col =&quot;blue&quot;)</pre><pre>hist(insuranceDT2$bmi,main =&quot;Distribution of BMI&quot;, ylab = &quot;Frequency&quot;,xlab =&quot;BMI&quot;, col =&quot;orange&quot;)</pre><pre>hist(insuranceDT2$charges, main =&quot;Distribution of Charges&quot;, ylab = &quot;Frequency&quot;,xlab =&quot;Charges&quot;,col = &quot;red&quot;)</pre><pre>})</pre><p>D. Density Plots of Continuous Variables</p><pre># Density Plot of continuous variables</pre><pre>renderPlot({</pre><pre>par(mfrow=c(1,3))</pre><pre>plot(density(insuranceDT2$age), main=&quot;Density Plot: Age&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$age), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$age), col=&quot;blue&quot;)</pre><pre>plot(density(insuranceDT2$bmi), main=&quot;Density Plot: BMI&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$bmi), 2)))  # density plot for &#39;age&#39;</pre><pre>polygon(density(insuranceDT2$bmi), col=&quot;orange&quot;)</pre><pre>plot(density(insuranceDT2$charges), main=&quot;Density Plot: Charges&quot;, ylab=&quot;Frequency&quot;, sub=paste(&quot;Skewness:&quot;, round(skewness(insuranceDT2$charges), 2)))  # density plot for &#39;charges&#39;<br>  polygon(density(insuranceDT2$charges), col=&quot;red&quot;)</pre><pre>})</pre><p>E. Scatter Plots of Charges Against Ages of Customers</p><pre>renderPlot({</pre><pre>par(mfrow=c(1,2))</pre><pre>plot(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges Against Age&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;blue&quot;)</pre><pre>scatter.smooth(x=insuranceDT2$age, y=insuranceDT2$charges, main =&quot;Scatter Plot of Charges against Age with Linear Line&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Age&quot;, col=&quot;red&quot;)</pre><pre>})</pre><p>F. Boxplots of Charges Based on Smoking Status</p><pre>renderPlot({</pre><pre>#par(mfrow=c(1,2))</pre><pre>plot(x=insuranceDT2$smoker, y=insuranceDT2$charges, main =&quot;Boxplot of Charges Against Smoking Status&quot;, ylab =&quot;Charges&quot;, xlab = &quot;Smoker&quot;, col=c(&quot;blue&quot;,&quot;green&quot;))</pre><pre>})</pre><p><strong>12.</strong> <strong>Deployment of InsurApp</strong></p><p><strong>i.</strong> <strong>Local deployment: </strong>The run() function is used for deploying the app locally for testing with the code below.</p><pre># rmarkdown::run(&quot;path_to_file/fileName&quot;)</pre><pre>rmarkdown::run(&quot;InsurrApp.Rmd&quot;)</pre><p><strong>ii.</strong> <strong>Cloud deployment (</strong><a href="https://www.shinyapps.io/">https://www.shinyapps.io/</a>)<strong>:</strong> shinyapps.io is a cloud platform for deploying shiny applications. The following steps are taken in deploying the app in shinyapps.io</p><p>· <strong>Create ShinyApps account on</strong> <a href="http://www.shinyapps.io/">http://www.shinyapps.io/</a>.</p><p>· <strong>Set up your account on your local system using rsconnect::setAccountInfo.</strong></p><pre>rsconnect::setAccountInfo(name=&#39;jhonsphorus&#39;,token=&#39;612DAB51005159762881CF2CAA8BC4A4&#39;, secret=&#39;&lt;SECRET&gt;&#39;)</pre><p>· <strong>Use the button below on R Studio to deploy your app to shinyapps.io</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tHYFHl-b8G_Oyhp2I4zMOA.jpeg" /></figure><p>· <strong>Then click on ‘Publish’</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8cAKniYzkIdA5ivtkqJ19Q.jpeg" /></figure><p><strong>13.</strong> <strong>Navigating through InsurrApp Pages</strong></p><p><strong>i.</strong> <strong>Landing Page/Insurance Charges Prediction</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmUpj9Wjp_61WwvujADlRg.jpeg" /></figure><p><strong>ii.</strong> <strong>Insurance Data EDA Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wVXLc0hJmzp-cURFjzovSQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAcnbETQTTyoFi7b69Ck3g.jpeg" /></figure><p><strong>iii.</strong> <strong>About Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mbNZd6oTKozHIMwDpB8HIg.jpeg" /></figure><p><strong>iv.</strong> <strong>Projects Portfolio Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ppcJaLFKbZuBynb4IXOGPg.jpeg" /></figure><p><strong>v.</strong> <strong>Contact Page</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JXnEmYDQwr3lefsDiZk7CQ.jpeg" /></figure><p><strong>14.</strong> <strong>Link to InsurrApp After Deployment</strong></p><p>The link to InsurrApp is<strong> </strong><a href="https://phorus2.shinyapps.io/InsurrApp/">https://phorus2.shinyapps.io/InsurrApp/</a></p><p>Thank you for taking time to read this article.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff2c002e168" width="1" height="1" alt=""><hr><p><a href="https://medium.com/building-insurance-pricing-platform-with-r/building-insurance-pricing-platform-with-r-insurrapp-dff2c002e168">Building Insurance Pricing Platform with R — InsurrApp</a> was originally published in <a href="https://medium.com/building-insurance-pricing-platform-with-r">Building Insurance Pricing Platform with R — InsurrApp</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an R Bot (with “PhorusBot” as a case study)]]></title>
            <link>https://medium.com/@mailjohnson.adebayo/building-an-r-bot-with-phorusbot-as-a-case-study-753980a3333?source=rss-1d3d0a064fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/753980a3333</guid>
            <dc:creator><![CDATA[Johnson Adebayo]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 20:05:18 GMT</pubDate>
            <atom:updated>2020-07-03T20:05:18.907Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1.</strong> <strong>Introduction</strong></p><p>PhorusBot is an analytics bot built with R using Telegram API Token. The bot was built to share my projects, contact, social media handle, links to dataset, business news, analytics etc. with users and allow users to have access to other bots such as Youtube Bot, Wikipedia Search Bot, Classical Music Bot, VoteBot etc.</p><p><strong>2.</strong> <strong>How PhorusBot was Built</strong></p><p>PhorusBot was built by generating API Access Token from Telegram chat bot called BotFather (@BotFather). The following steps should be taken to build a Bot with R;</p><p><strong>Step 1: Generate Access Token</strong></p><p>To generate access token connect with @BotFather (<a href="https://telegram.me/botfather">https://telegram.me/botfather</a>) and follow the steps described here (<a href="https://core.telegram.org/bots#6-botfather">https://core.telegram.org/bots#6-botfather</a>).</p><p><strong>Step 2: Install and Load the </strong><strong>telegram.bot Package</strong></p><p># installing telegram.bot package</p><p>install.packages(“telegram.bot”)</p><p># loading or importing telegram.bot package</p><p>library(telegram.bot)</p><p><strong>Step 3: Create an Object of Your Bot</strong></p><p>You create an object of your bot, in this case object of PhorusBot, using the code below and replace the “TOKEN” with Telegram Bot’s API Access Token generated from step 1 above. The token should look like this; 1234567890:AAEjAF9yJycaPofoLjKupZFeOQjJd9ers4J</p><p>bot &lt;- Bot(token = “TOKEN”)</p><p><strong>Step 4: Creating the updater object</strong></p><p>The Updater class continuously fetches new updates from Telegram and passes them on to the Dispatcher class. If you create an Updater object, it will create a Dispatcher.</p><p>Create the updater object using the “Updater” function by replacing the “TOKEN” with Telegram Bot’s API Access Token generated from step 1 above, in the code below. The token should look like this 1234567890:AAEjAF9yJycaPofoLjKupZFeOQjJd9ers4J</p><p>updater &lt;- Updater(token = “TOKEN”)</p><p><strong>Step 5: Create Function(s)</strong></p><p>The next step is to create function(s) that should process a specific type of update that you desired.</p><p>In the case of PhorusBot, I created the functions below;</p><p>start &lt;- function(bot, update){</p><p>bot$sendMessage(chat_id = update$message$chat_id,text = print(“Hello! Welcome to Phorus Analytics”))</p><p>}</p><p>email &lt;- function(bot, update){</p><p>bot$sendMessage(chat_id = update$message$chat_id,text = print(“mailphorus@gmail.com”))</p><p>}</p><p>The goal is to have these functions called every time the Bot (PhorusBot) receives a Telegram message that contains the /start command (for start function) and /email command (for email function). To accomplish that, you can use a CommandHandler (one of the provided Handler sub-classes) and register it in the updaters’s dispatcher (which is done with the +operator):</p><p>Note: You can create as many functions as possible, learn more on how to do this using this link (<a href="https://github.com/ebeneditos/telegram.bot/wiki/Introduction-to-the-API">https://github.com/ebeneditos/telegram.bot/wiki/Introduction-to-the-API</a>).</p><p><strong>Step 6: Create </strong><strong>Handler Update the</strong><strong> updater</strong></p><p>start_handler &lt;- <strong>CommandHandler</strong>(“start”, start)</p><p>email_handler &lt;- CommandHandler(“email”, email)</p><p>updater &lt;- updater + start_handler + email_handler</p><p><strong>Step 7: Starting the Bot</strong></p><p>To start the bot run the code below;</p><pre>updater$<strong>start_polling</strong>()</pre><p>Start a chat with your bot and issue the /start command to the Bot (“PhorusBot” in my own case), it will reply you. To be able to chat with the Bot you search for the name of your Bot (e.g. PhorusBot) on Telegram application.</p><p><strong>3.</strong> <strong>How to Interact with PhorusBot</strong></p><p>To interact with the PhorusBot or the Bot you created. You either have Telegram application installed or you access web version of Telegram using this URL<strong> (</strong><a href="https://web.telegram.org/">https://web.telegram.org/</a><strong>).</strong></p><p><strong>Then, follow the steps below;</strong></p><p>1. Search for the Bot’s name (“PhorusBot” in my own case)</p><p>2. Click on the Bot (e.g. PhorusBot)</p><p>3. Click “Start”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/30/0*UMFt3jaAKsL6zLt2" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/0*Sfju63lSo--dV2Se.png" /></figure><p>4. Enter the command of information you want as reply from the Bot (e.g. “/email”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/30/0*77xmNt1pVUVAv7QI" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/0*vB6618z_LGwY78ti.png" /></figure><p>5. To access other Bots like Youtube Bot, enter “@youtube” and type the title of what you wish to search for (e.g. Obama)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/30/0*XvZ83m-RdHQaJcOZ" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/0*97IfzssuqRnCj8_r.png" /></figure><p>6. You can as well search for other Bots such as @wiki, @sticker, @vid, @pic, @music etc.</p><p><strong>4.</strong> <strong>Usefulness of Bots</strong></p><p>· <strong>Create custom tools</strong>: A bot may provide you with advert, alerts, weather forecasts, translations, formatting or other services e.g. PhorusBot<strong>(</strong><a href="https://t.me/">https://t.me/</a>JhonsphorusBot<strong>), StickerBot (</strong><a href="https://t.me/sticker">https://t.me/sticker</a><strong>),</strong>VoteBot<strong> (</strong><a href="https://t.me/vote">https://t.me/vote</a><strong>), </strong>LikeBot<strong> (</strong><a href="https://t.me/like">https://t.me/like</a><strong>) etc.</strong></p><p>· <strong>Get customized notifications and news: </strong>A bot can act as a smart newspaper, sending you relevant content as soon as it’s published.</p><p>· <strong>Build social services.</strong> A bot could connect people looking for conversation partners based on common interests or proximity.</p><p>· <strong>Integrate with other services:</strong> A bot can enrich chats with content from external services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*dHM0NO8sgWCOfBZ1atyacw.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*BJwi1lXYIDq7As0BiORtIg.jpeg" /></figure><p>References:</p><p>Ernest Benedito — <a href="https://cran.r-project.org/web/packages/telegram.bot/vignettes/telegrambot-building-a-bot.html">https://cran.r-project.org/web/packages/telegram.bot/vignettes/telegrambot-building-a-bot.html</a></p><p><a href="https://core.telegram.org/bots#6-botfather">https://core.telegram.org/bots#6-botfather</a></p><p><a href="https://core.telegram.org/bots">https://core.telegram.org/bots</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=753980a3333" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building an R Bot (with “PhorusBot” as a case study)]]></title>
            <link>https://medium.com/@mailjohnson.adebayo/building-an-r-bot-with-phorusbot-as-a-case-study-df83013a1d35?source=rss-1d3d0a064fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/df83013a1d35</guid>
            <dc:creator><![CDATA[Johnson Adebayo]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 19:43:36 GMT</pubDate>
            <atom:updated>2020-07-03T19:43:36.200Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>1.</strong> <strong>Introduction</strong></p><p>PhorusBot is an analytics bot built with R using Telegram API Token. The bot was built to share my projects, contact, social media handle, links to dataset, business news, analytics etc. with users and allow users to have access to other bots such as Youtube Bot, Wikipedia Search Bot, Classical Music Bot, VoteBot etc.</p><p><strong>2.</strong> <strong>How PhorusBot was Built</strong></p><p>PhorusBot was built by generating API Access Token from Telegram chat bot called BotFather (@BotFather). The following steps should be taken to build a Bot with R;</p><p><strong>Step 1: Generate Access Token</strong></p><p>To generate access token connect with @BotFather (<a href="https://telegram.me/botfather">https://telegram.me/botfather</a>) and follow the steps described here (<a href="https://core.telegram.org/bots#6-botfather">https://core.telegram.org/bots#6-botfather</a>).</p><p><strong>Step 2: Install and Load the </strong><strong>telegram.bot Package</strong></p><p># installing telegram.bot package</p><p>install.packages(“telegram.bot”)</p><p># loading or importing telegram.bot package</p><p>library(telegram.bot)</p><p><strong>Step 3: Create an Object of Your Bot</strong></p><p>You create an object of your bot, in this case object of PhorusBot, using the code below and replace the “TOKEN” with Telegram Bot’s API Access Token generated from step 1 above. The token should look like this; 1234567890:AAEjAF9yJycaPofoLjKupZFeOQjJd9ers4J</p><p>bot &lt;- Bot(token = “TOKEN”)</p><p><strong>Step 4: Creating the updater object</strong></p><p>The Updater class continuously fetches new updates from Telegram and passes them on to the Dispatcher class. If you create an Updater object, it will create a Dispatcher.</p><p>Create the updater object using the “Updater” function by replacing the “TOKEN” with Telegram Bot’s API Access Token generated from step 1 above, in the code below. The token should look like this 1234567890:AAEjAF9yJycaPofoLjKupZFeOQjJd9ers4J</p><p>updater &lt;- Updater(token = “TOKEN”)</p><p><strong>Step 5: Create Function(s)</strong></p><p>The next step is to create function(s) that should process a specific type of update that you desired.</p><p>In the case of PhorusBot, I created the functions below;</p><p>start &lt;- function(bot, update){</p><p>bot$sendMessage(chat_id = update$message$chat_id,text = print(“Hello! Welcome to Phorus Analytics”))</p><p>}</p><p>email &lt;- function(bot, update){</p><p>bot$sendMessage(chat_id = update$message$chat_id,text = print(“mailphorus@gmail.com”))</p><p>}</p><p>The goal is to have these functions called every time the Bot (PhorusBot) receives a Telegram message that contains the /start command (for start function) and /email command (for email function). To accomplish that, you can use a CommandHandler (one of the provided Handler sub-classes) and register it in the updaters’s dispatcher (which is done with the + operator):</p><p>Note: You can create as many functions as possible, learn more on how to do this using this link (<a href="https://github.com/ebeneditos/telegram.bot/wiki/Introduction-to-the-API">https://github.com/ebeneditos/telegram.bot/wiki/Introduction-to-the-API</a>).</p><p><strong>Step 6: Create </strong><strong>Handler Update the</strong><strong> updater</strong></p><p>start_handler &lt;- <strong>CommandHandler</strong>(“start”, start)</p><p>email_handler &lt;- CommandHandler(“email”, email)</p><p>updater &lt;- updater + start_handler + email_handler</p><p><strong>Step 7: Starting the Bot</strong></p><p>To start the bot run the code below;</p><pre>updater$<strong>start_polling</strong>()</pre><p>Start a chat with your bot and issue the /start command to the Bot (“PhorusBot” in my own case), it will reply you. To be able to chat with the Bot you search for the name of your Bot (e.g. PhorusBot) on Telegram application.</p><p><strong>3.</strong> <strong>How to Interact with PhorusBot</strong></p><p>To interact with the PhorusBot or the Bot you created. You either have Telegram application installed or you access web version of Telegram using this URL<strong> (</strong><a href="https://web.telegram.org/">https://web.telegram.org/</a><strong>).</strong></p><p><strong>Then, follow the steps below;</strong></p><p>1. Search for the Bot’s name (“PhorusBot” in my own case)</p><p>2. Click on the Bot (e.g. PhorusBot)</p><p>3. Click “Start”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/704/1*m7cpcOsfAvpfPQWRD3ruhQ.png" /></figure><p>4. Enter the command of information you want as reply from the Bot (e.g. “/email”)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*WX22-cMBlAGmwmPvR-rM3Q.png" /></figure><p>5. To access other Bots like Youtube Bot, enter “@youtube” and type the title of what you wish to search for (e.g. Obama)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/696/1*lsZ-YXYgN9RKAuuRMZY_5g.png" /></figure><p>6. You can as well search for other Bots such as @wiki, @sticker, @vid, @pic, @music etc.</p><p><strong>4.</strong> <strong>Usefulness of Bots</strong></p><p>· <strong>Create custom tools</strong>: A bot may provide you with advert, alerts, weather forecasts, translations, formatting or other services e.g. PhorusBot<strong> (</strong><a href="https://t.me/">https://t.me/</a>JhonsphorusBot<strong>), StickerBot (</strong><a href="https://t.me/sticker">https://t.me/sticker</a><strong>), </strong>VoteBot<strong> (</strong><a href="https://t.me/vote">https://t.me/vote</a><strong>), </strong>LikeBot<strong> (</strong><a href="https://t.me/like">https://t.me/like</a><strong>) etc.</strong></p><p>· <strong>Get customized notifications and news: </strong>A bot can act as a smart newspaper, sending you relevant content as soon as it’s published.</p><p>· <strong>Build social services.</strong> A bot could connect people looking for conversation partners based on common interests or proximity.</p><p>· <strong>Integrate with other services:</strong> A bot can enrich chats with content from external services.</p><p>References:</p><p>Ernest Benedito — <a href="https://cran.r-project.org/web/packages/telegram.bot/vignettes/telegrambot-building-a-bot.html">https://cran.r-project.org/web/packages/telegram.bot/vignettes/telegrambot-building-a-bot.html</a></p><p><a href="https://core.telegram.org/bots#6-botfather">https://core.telegram.org/bots#6-botfather</a></p><p><a href="https://core.telegram.org/bots">https://core.telegram.org/bots</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=df83013a1d35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Time Series (TS) Dataset Forecasting Using TSForecastApp]]></title>
            <link>https://medium.com/@mailjohnson.adebayo/time-series-ts-dataset-forecasting-using-tsforecastapp-99ea7d2d3664?source=rss-1d3d0a064fa1------2</link>
            <guid isPermaLink="false">https://medium.com/p/99ea7d2d3664</guid>
            <category><![CDATA[time-series-model]]></category>
            <category><![CDATA[time-series-forecasting]]></category>
            <category><![CDATA[time-series-analysis]]></category>
            <dc:creator><![CDATA[Johnson Adebayo]]></dc:creator>
            <pubDate>Wed, 01 Apr 2020 23:32:40 GMT</pubDate>
            <atom:updated>2020-04-01T23:32:40.851Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqQduS_Al-x0duv9yMavCg.png" /><figcaption>Fig 1. Time Series image from TSForecastApp</figcaption></figure><p><strong>1.0 TSForecastApp</strong></p><p>TSForecastApp is an application for predicting and forecasting time series dataset. The backend of this application is built with time series forecasting models which includes ARIMA, AutoARIMA, Simple Exponential Smoothening etc. The application allows the user to upload dataset in csv, xlsx and text format.</p><p>TSForecastApp is built with R package called Shiny.</p><p>Shiny is a web application framework for R, it is used for building interactive web applications with R.</p><p>When the user upload dataset and select appropriate value for the starting day, starting month, starting year, frequency, number of years to forecast and type of model, the platform generates the following plots based on the user input;</p><p>a. Time series plot.</p><p>b. Decomposed time series (seasonal, trend, dataset and random).</p><p>c. Seasonal plot.</p><p>d. ACF (Auto-Correlation Function) plot.</p><p>e. PACF (Partial Auto-Correlation Function) plot.</p><p>f. Plot of the stationarized time series dataset.</p><p>g. Augmented Dickey-Fuller Test output (for determining the stationarity of the time series).</p><p>h. Forecast of the future values of the time series.</p><p><strong>2.0 Description of Components on TSForecastApp</strong></p><p><strong>1. File Selection:</strong> This allow user to upload dataset in csv, xlsx and text format.</p><p><strong>2. Day Selection:</strong> This allow user to enter the starting day of the time series.</p><p><strong>3. Month Selection:</strong> This allow user to enter the starting month of the time series.</p><p><strong>4. Year Selection:</strong> This allow user to enter the starting year of the time series.</p><p><strong>5. Frequency:</strong> This allow user to enter the frequency of data collection within a period less than one year e.g. 1 (yearly collection of data), 2, 3, 4 (quarterly collection of data), 12 (monthly collection of data), 365(for daily data collection).</p><p><strong>6. Lines to skip:</strong> Number of lines to skip out from the dataset in case of header in the dataset</p><p><strong>7. Year:</strong> This allow user to enter the number of years to predict or forecast.</p><p><strong>8. Model Selection:</strong> This has list of time series forecasting models such as ARIMA, AutoARIMA, Simple Exponential Smoothening etc. for user to select choice of model for forecasting.</p><p>You can view my app on: <a href="https://jhonsphorus1.shinyapps.io/TSForecastApp/">https://jhonsphorus1.shinyapps.io/TSForecastApp/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=99ea7d2d3664" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>