<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="https://www.r-bloggers.com/employee-retention-with-r-based-data-science-accelerator/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2017/03/employee-retention.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p><em>by Le Zhang (Data Scientist, Microsoft) and Graham Williams (Director of Data Science, Microsoft)</em></p>
<p>Employee retention has been and will continue to be one of the biggest challenges of a company. While classical tactics such as promotion, competitive perks, etc. are practiced as ways to retain employees, it is now a hot trend to rely on machine learning technology to discover behavioral patterns with which a company can understand their employees better.</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8dba088970b-pi"><img title="Employee1" alt="Employee1" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8dba088970b-800wi" border="0"></a></p>
<p>Employee demographic data has been studied and used for analyzing <a target="_blank" rel="nofollow" href="http://amj.aom.org/content/44/6/1102.abstract">employees’ inclination towards leaving a company</a>. Nowadays, with the proliferation of the Internet, employees’ behavior can better be understood and analyzed through such data as internal and external social media postings. Such data can be leveraged for the analysis of, for example, sentiment and thereby <a target="_blank" rel="nofollow" href="http://blog.revolutionanalytics.com/2017/03/employee-retention.html">determination of an employees likelihood of leaving the company</a>. Novel cognitive computing technology based on artificial intelligence tools empower today’s HR departments to identify staff who are likely to churn before they do. Through pro-active intervention HR can better manage staff to encourage them to remain longer term with the company.</p>
<p>This blog post introduces an R based data science accelerator that can be quickly adopted by a data scientist to prototype a <a target="_blank" rel="nofollow" href="https://github.com/Microsoft/acceleratoRs/tree/master/EmployeeAttritionPrediction">solution for the employee attrition prediction scenario</a>.  The prediction is based on two types of employee data that are typically already collected by companies:</p>
<ol>
<li>Static data which does not tend to change over time. This type of data may refer to demographic and organizational data such as age, gender, title, etc. A characteristic of this type of data is that within a certain period they do not change or solely change in a deterministic way. For instance, years of service of an employee is static as the number increments every year.</li>
<li>The second type of data is the dynamically evolving information about an employee. Recent studies revealed that sentiment is playing a critical role in employee attrition prediction. Classical measures of sentiment require employee surveys of work satisfaction work. Social media posts become useful for sentiment analysis as employees may express their feelings about work. Non-structural data such as text can be collected for mining patterns which are indicative of employees with different inclinations for churn.</li>
</ol>
<p>Attrition prediction is a scenario that takes historic employee data as input to then identify individuals that are inclined to leave. The basic procedure is to extract features from the available data that might have previously been manually analyzed and to build predictive models based on a training set with labels relating to the employment status. Normally it can be formalized as a supervised classification problem, while the uniqueness is that population of employees with different employment status may not be equal. Training such an imbalanced data set requires resampling or cost-sensitive learning techniques. For sentiment analysis on unstructured data such as text, pre-processing techniques that extract analysis-friendly quantitative features should be applied. Commonly used feature extraction methods for text analysis include word-to-vector, term frequency, or term frequency and inverse document frequency, etc. Algorithms for building the model depend on the data characteristics. In case a specific algorithm does not yield the desired results, we have found that ensemble techniques can be deployed to effectively boost model performance.</p>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8dba095970b-pi"><img title="Employee2" alt="Employee2" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8dba095970b-800wi" border="0"></a></p>
<p>The data science language R is a convenient tool for performing HR churn prediction analysis. A lightweight data science accelerator that demonstrates the process of predicting employee attrition is shared in this <a target="_blank" rel="nofollow" href="https://github.com/Microsoft/acceleratoRs/tree/master/EmployeeAttritionPrediction">Github repository</a>. The walk-through basically shows cutting-edge machine learning and text mining techniques applied in R.</p>
<p>The code for the analytics is provided in an <a target="_blank" rel="nofollow" href="https://github.com/Microsoft/acceleratoRs/blob/master/EmployeeAttritionPrediction/Code/EmployeeAttritionPrediction.Rmd">R markdown document</a>, which can be interactively executed step by step to aid replication and learning. Documents of various formats (e.g., PDF, html, Jupyter Notebook, etc.) can be produced directly from the markdown document.</p>
<p>Taking <a target="_blank" rel="nofollow" href="https://community.watsonanalytics.com/wp-content/uploads/2015/03/WA_Fn-UseC_-HR-Employee-Attrition.xlsx">this employee attrition</a> data set, for example, one can easily visualize and perform correlation analysis with R packages. For instance, we may plot the distribution of monthly income of employees from different departments and intuitively analyze whether income can be a factor that affects attrition.</p>
<div>
<pre>df <span>&lt;-</span> read.xlsx(<span>&quot;./attrition.xlsx&quot;</span>, 
                sheetIndex<span>=</span><span>1</span>,
                header<span>=</span><span>TRUE</span>,
                colClasses<span>=</span><span>NA</span>)

ggplot(df, aes(x<span>=</span>factor(Department), y<span>=</span>MonthlyIncome, color<span>=</span>factor(Attrition))) <span>+</span>
  geom_boxplot() <span>+</span>
  xlab(<span>&quot;Department&quot;</span>) <span>+</span>
  ylab(<span>&quot;Monthly income&quot;</span>) <span>+</span>
  scale_fill_discrete(guide<span>=</span>guide_legend(title<span>=</span><span>&quot;Attrition&quot;</span>)) <span>+</span>
  theme_bw()
</pre>
</div>
<p><a target="_blank" rel="nofollow" href="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8de2df9970b-pi"><img title="Blog_plot" alt="Blog_plot" src="http://revolution-computing.typepad.com/.a/6a010534b1db25970b01b7c8de2df9970b-800wi" border="0"></a></p>
<p>R packages such as <a target="_blank" rel="nofollow" href="https://cran.r-project.org/package=tm">tm</a> offer handy functions for dealing with text mining tasks on employees’ social media posts. Sometimes text analysis on multiple languages are of great interest to employers that have subsidiaries across different language-speaking locations. This can be done either via language-specific text analysis package (e.g., jiebaR for Chinese segmentation) or on-line translation. <a target="_blank" rel="nofollow" href="https://github.com/Microsoft/acceleratoRs/blob/master/EmployeeAttritionPrediction/Code/EmployeeAttritionPrediction.Rmd#223-multi-lingual-sentiment-analysis">This R code</a> demonstrates how to perform tokenization and term frequency count on English-Chinese text with jiebaR and tm.</p>
<p>For the complete solution for employee attrition, follow the link below.</p>
<p>Github (Microsoft): <a target="_blank" rel="nofollow" href="https://github.com/Microsoft/acceleratoRs/tree/master/EmployeeAttritionPrediction">Data Science Accelerator – Employee Attrition Prediction with Sentiment Analysis</a></p>
</div>
<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2017/03/employee-retention.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="https://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="https://www.r-bloggers.com/search/data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="https://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="https://www.r-bloggers.com/search/map">maps</a>, <a title="Animation in R" rel="nofollow" href="https://www.r-bloggers.com/search/animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="https://www.r-bloggers.com/search/sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="https://www.r-bloggers.com/search/SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="https://www.r-bloggers.com/search/eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="https://www.r-bloggers.com/search/git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="https://www.r-bloggers.com/search/hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="https://www.r-bloggers.com/search/regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="https://www.r-bloggers.com/search/PCA">PCA</a>, <a title="Time series" rel="nofollow" href="https://www.r-bloggers.com/search/time+series">time series</a>, <a title="finance trading" rel="nofollow" href="https://www.r-bloggers.com/search/trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/T-DGEFFFz14"></a></div>