Predicting child's height

Tom Chęckiewicz
05 OCTOBER 2016

Introduction

This application has been developed as Coursera Data Products course project, which is a part of Data Science specialisation.

The main purpose of the application is to use the predictive model, designed and developed based on GaltonFamilies data set and Random Forest machine learning algorithm in order to peredict child's height based on the following features:

  • Father's Height
  • Mother's Height
  • Number of children in the family
  • Number of this child within the family
  • Child's gender

Predictive Model Input Data, Design

The predictive model used in the application, processes GaltonFamilies data set as an input data. This data set is part of HistData library in R.
Random Forest Machine Learning algorithm has beed applied to train the predictive model for the application.

library(HistData)
library(plyr)
library(dplyr)
library(caret)
library(ranger)

df <- tbl_df(GaltonFamilies)
#Splitting the data set into training and testing
inTrain <- createDataPartition(df$childHeight, p=.7, list = FALSE)
training <- df[inTrain, ]
testing <- df[-inTrain, ]
#Training the model
train_Control <- trainControl(method = "cv", number = 5, allowParallel = TRUE)
ModFit_RF <- train(childHeight~., data=training, method="ranger", trControl=train_Control)
saveRDS(ModFit_RF, "./ModFit_RF.rds")

Application input Widgets

The ui.R part of the application utilises the following input widgets in order to collect data points necessary to apply the predictive model:

  • numericInput which collects the numeric data about Father's Height, Mother's Height, Number of children in your family and Number of this child within family

  • radioButtons which collects the category of child's gender

  • submitButton which gives the users a control over triggering the reactive calculations within server.R

Application Server Calculations and Output

Based on the input data collected by input Widgets within ui.R, the server part of the application calls ModFit_RF predictive model, stored in the application folder in order to generate as an output:

  • Tab Prediction with Child's predicted height in inch
  • Tab Plot with Visualisation of the height of the parents and the child
  • Tab HowItWorks with short explanation of the way the application works

Application Links and Code repository

The application has been deployed on RStudio shinyapps.io server and available under the following link:

(https://oli2.shinyapps.io/Predict_Your_Child_Height/)

The application ui.R and server.R files as well as the ModFit_RF predictive model are available on Github here:

(https://github.com/Oli2/Data-Products.git)