<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Yu Fen Lin</title>
    <description>The latest articles on DEV Community by Yu Fen Lin (@yufenlin).</description>
    <link>https://dev.to/yufenlin</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F267003%2F99fe8180-81aa-4aec-b2ab-1a89923f6a37.jpeg</url>
      <title>DEV Community: Yu Fen Lin</title>
      <link>https://dev.to/yufenlin</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/yufenlin"/>
    <language>en</language>
    <item>
      <title>An Overview of "Deep Neural Networks for YouTube Recommendations"</title>
      <dc:creator>Yu Fen Lin</dc:creator>
      <pubDate>Fri, 17 Jan 2020 17:34:23 +0000</pubDate>
      <link>https://dev.to/yufenlin/an-overview-of-deep-neural-networks-for-youtube-recommendations-g77</link>
      <guid>https://dev.to/yufenlin/an-overview-of-deep-neural-networks-for-youtube-recommendations-g77</guid>
      <description>&lt;p&gt;&lt;a href="https://www.youtube.com/"&gt;Youtube&lt;/a&gt; is one of the largest and most advanced recommendation systems in the industry. &lt;/p&gt;

&lt;p&gt;Paul Covington, Jay Adams, and Emre Sargin’s 2016 paper “&lt;a href="https://research.google/pubs/pub45530/"&gt;Deep Neural Networks for YouTube Recommendations&lt;/a&gt;” discuss an important question:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;How to preset a few “best” recommendations?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I will show you a brief overview of the system and some features selection.&lt;/p&gt;




&lt;h2&gt;
  
  
  Perspectives
&lt;/h2&gt;

&lt;p&gt;There are three main perspectives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Scale: 

&lt;ul&gt;
&lt;li&gt;There is no existing recommendation algorithms proven to work well on YouTube’s massive user base and corpus.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Freshness

&lt;ul&gt;
&lt;li&gt;Videos update quickly and corpus is constantly changing. &lt;a href="https://merchdope.com/youtube-stats/"&gt;300 hours of video are uploaded to YouTube every minute.(2019)&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;The system needs to balance new and old content.&lt;/li&gt;
&lt;li&gt;Solve cold start problem.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Noise

&lt;ul&gt;
&lt;li&gt;User behavior data on Youtube is sparse with only implicit feedback.&lt;/li&gt;
&lt;li&gt;There is a lot of noise data.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Facts and Numbers about Youtube&lt;/p&gt;




&lt;h2&gt;
  
  
  System Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NVkxMoeJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5lmitptoheoptqjlqwlc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NVkxMoeJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/5lmitptoheoptqjlqwlc.png" alt="System Overview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The recommendation system has two stages:
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Stage 1: Candidate generation:
&lt;/h4&gt;

&lt;p&gt;This provides broad personalization using collaborative filtering. Retrieves a small subset. The magnitude of candidate videos ranges from millions to hundreds.The similarity between users compared by identifiers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;videos watched&lt;/li&gt;
&lt;li&gt;search query tokens&lt;/li&gt;
&lt;li&gt;demographics(geographic region, device, gender, and age)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--g8yJX2qe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/caqaxry6h25535ycummx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--g8yJX2qe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/caqaxry6h25535ycummx.png" alt="Candidate generation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The input layer is followed by several layers of fully connected Rectified Linear Units (ReLU).&lt;/p&gt;

&lt;h4&gt;
  
  
  Stage 2: Ranking
&lt;/h4&gt;

&lt;p&gt;During ranking, it is able to take advantage of many more features describing the video and the user’s relation because only a few hundred videos are being scored.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ranking is crucial for ensembling different candidate sources.&lt;/li&gt;
&lt;li&gt;Assign an independent score to each video impression using logistic regression.&lt;/li&gt;
&lt;li&gt;Final ranking objective is constantly being tuned based on live A/B testing results.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7P5ZaPrx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zrtuh3izh10jidyorj3j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7P5ZaPrx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/zrtuh3izh10jidyorj3j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h4&gt;
  
  
  Features
&lt;/h4&gt;

&lt;p&gt;Next I would like to discuss some features selection based on business consideration.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Our goal is to predict expected watch time given training examples that are either positive (the video impression was clicked) or negative (the impression was not clicked). Positive examples are annotated with the amount of time the user spent watching the video.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Why is expected watch time as an optimization goal rather than Click-Through Rate or Play Rate?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Watch time is more about users' real interest. The most important signals are those describing a users interaction with the video. From a business perspective, the longer watch time, the more ad revenue YouTube gets. And increasing the watch time of users is also in line with the long-term interests of video sites and user stickiness. It means the model meets YouTube business considerations.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;Recommending recently uploaded (“fresh”) content is extremely important for YouTube as a product. We consistently observe that users prefer fresh content, though not at the expense of relevance. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;How to introduce the bias of fresh content in the model?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Machine learning models are often biased toward the past data because they are trained from historical examples. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;...using the age of the training example as an input feature removes an inherent bias towards the past and allows the model to represent the time-dependent behavior of popular of videos. &lt;/p&gt;

&lt;p&gt;...we feed the age of the training example as a feature during training. At serving time, this feature is set to zero (or slightly negative) to reflect that the model is making predictions at the very end of the training window.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--y58R9Kb6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/39jvi9wdmdlne605kchv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--y58R9Kb6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/39jvi9wdmdlne605kchv.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This makes a big difference as the above graph. The green line is the actual distribution. The red line shows the predictions with age of the training example, and the blue line without it. The red line is more match the actual distribution.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;In the preprocessing of training examples, why do they extract an equal number of training samples for per user.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Another key insight that improved live metrics was to generate a fixed number of training examples per user, effectively weighting our users equally in the loss function. This prevented a small cohort of highly active users from dominating the loss.        &lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;em&gt;Why the time-sequence of the user's viewing history are completely abandoned, and the user's recent browsing history is regarded as the same?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If we think too much about the impact of timing, the users' recommendation results will be too much affected by a recently watched or searched video. They give us a example, if a user has just issued a search query for “taylor swift”. It may be not a good idea that most videos are related to “taylor swift” on next homepage recommendations.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;By discarding sequence information and representing search queries with an unordered bag of tokens, the classifier is no longer directly aware of the origin of the label.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This paper is representative of using DNN as a recommendation system. It combines business reality and user scenarios. I really recommend it.&lt;/p&gt;

&lt;p&gt;References&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kknews.cc/code/b86mpo9.html"&gt;https://kknews.cc/code/b86mpo9.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kknews.cc/code/k4qeaz8.html"&gt;https://kknews.cc/code/k4qeaz8.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://towardsdatascience.com/using-deep-neural-networks-to-make-youtube-recommendations-dfc0a1a13d1e"&gt;Using Deep Neural Networks to make YouTube Recommendations&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://merchdope.com/youtube-stats/"&gt;37 Mind Blowing YouTube Facts, Figures and Statistics – 2019!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Build a decision tree in R</title>
      <dc:creator>Yu Fen Lin</dc:creator>
      <pubDate>Fri, 20 Dec 2019 19:11:19 +0000</pubDate>
      <link>https://dev.to/yufenlin/build-a-decision-tree-in-r-5hc0</link>
      <guid>https://dev.to/yufenlin/build-a-decision-tree-in-r-5hc0</guid>
      <description>&lt;h1&gt;
  
  
  Overview &amp;amp; Purpose
&lt;/h1&gt;

&lt;p&gt;With this article, we will build a decision trees model based on the Titanic data set that predicts whether a given person survived or not.&lt;/p&gt;

&lt;h1&gt;
  
  
  Steps:
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Initial data understanding and preparation&lt;/li&gt;
&lt;li&gt;Build, train, and test the model&lt;/li&gt;
&lt;li&gt;Evaluate the performance of the model&lt;/li&gt;
&lt;/ol&gt;

&lt;h1&gt;
  
  
  1. Understanding the data set
&lt;/h1&gt;

&lt;p&gt;We will use &lt;a href="https://www.rdocumentation.org/packages/titanic/versions/0.1.0" rel="noopener noreferrer"&gt;Titanic Passenger Survival Data Set&lt;/a&gt;. This data set provides information on the fate of passengers on the fatal maiden voyage of the ocean liner "Titanic", summarized according to economic status (class), sex, age and survival. Below is a brief description of the 12 variables in the data set :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PassengerId:&lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt; Serial Number&lt;/li&gt;
&lt;li&gt;Survived:&lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt; Contains binary Values of 0 and 1

&lt;ul&gt;
&lt;li&gt;0: Passenger did not survive &lt;/li&gt;
&lt;li&gt;1: Passenger Survived&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Pclass: &lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt; Ticket Class - 1st Class, 2nd Class or 3rd Class Ticket&lt;/li&gt;

&lt;li&gt;Name: &lt;code&gt;&amp;lt;chr&amp;gt;&lt;/code&gt; Name of the passenger&lt;/li&gt;

&lt;li&gt;Sex: &lt;code&gt;&amp;lt;chr&amp;gt;&lt;/code&gt; Male or Female&lt;/li&gt;

&lt;li&gt;Age: &lt;code&gt;&amp;lt;dbl&amp;gt;&lt;/code&gt; Age in years &lt;/li&gt;

&lt;li&gt;SibSp: &lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt; No. of Siblings / Spouses — brothers, sisters and/or husband/wife&lt;/li&gt;

&lt;li&gt;Parch: &lt;code&gt;&amp;lt;int&amp;gt;&lt;/code&gt; No. of parents/children — mother/father and/or daughter, son&lt;/li&gt;

&lt;li&gt;Ticket: &lt;code&gt;&amp;lt;chr&amp;gt;&lt;/code&gt; Serial Number&lt;/li&gt;

&lt;li&gt;Fare: &lt;code&gt;&amp;lt;dbl&amp;gt;&lt;/code&gt; Passenger fare&lt;/li&gt;

&lt;li&gt;Cabin: &lt;code&gt;&amp;lt;chr&amp;gt;&lt;/code&gt; Cabin Number&lt;/li&gt;

&lt;li&gt;Embarked: &lt;code&gt;&amp;lt;chr&amp;gt;&lt;/code&gt; Port of Embarkment 

&lt;ul&gt;
&lt;li&gt;C: Cherbourg &lt;/li&gt;
&lt;li&gt;Q: Queenstown &lt;/li&gt;
&lt;li&gt;S: Southhampton&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;h3&gt;
  
  
  Load necessary data
&lt;/h3&gt;

&lt;p&gt;Remove all objects in the Global Environment and load titanic data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rm(list = ls())

# install necessary packages
library(tidyverse) 
install.packages("titanic") 
# load necessary packages
library(titanic)
# load necessary data 
titanic &amp;lt;-
  titanic_train
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Take a look.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;titanic %&amp;gt;%
  View(title = "Titanic")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Produce the summaries of data.&lt;br&gt;
Summary() is one important functions that help in summarising each attribute in the dataset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; summary(titanic)
  PassengerId       Survived          Pclass          Name          
 Min.   :  1.0   Min.   :0.0000   Min.   :1.000   Length:891        
 1st Qu.:223.5   1st Qu.:0.0000   1st Qu.:2.000   Class :character  
 Median :446.0   Median :0.0000   Median :3.000   Mode  :character  
 Mean   :446.0   Mean   :0.3838   Mean   :2.309                     
 3rd Qu.:668.5   3rd Qu.:1.0000   3rd Qu.:3.000                     
 Max.   :891.0   Max.   :1.0000   Max.   :3.000                     

     Sex                 Age            SibSp           Parch       
 Length:891         Min.   : 0.42   Min.   :0.000   Min.   :0.0000  
 Class :character   1st Qu.:20.12   1st Qu.:0.000   1st Qu.:0.0000  
 Mode  :character   Median :28.00   Median :0.000   Median :0.0000  
                    Mean   :29.70   Mean   :0.523   Mean   :0.3816  
                    3rd Qu.:38.00   3rd Qu.:1.000   3rd Qu.:0.0000  
                    Max.   :80.00   Max.   :8.000   Max.   :6.0000  
                    NA's   :177                                     
    Ticket               Fare           Cabin             Embarked        
 Length:891         Min.   :  0.00   Length:891         Length:891        
 Class :character   1st Qu.:  7.91   Class :character   Class :character  
 Mode  :character   Median : 14.45   Mode  :character   Mode  :character  
                    Mean   : 32.20                                        
                    3rd Qu.: 31.00                                        
                    Max.   :512.33   
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is two "" in Embarked. Drop them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; titanic$Embarked[grepl("^\\s*$", titanic$Embarked)] 
[1] "" ""
&amp;gt; titanic &amp;lt;- droplevels(titanic[!grepl("^\\s*$", titanic$Embarked),,drop=FALSE])
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is also 177 NA's in Age. Use mean of age to fill NA's&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; summary(titanic$Age) 
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
   0.42   20.00   28.00   29.64   38.00   80.00     177 

&amp;gt; titanic$Age[is.na(titanic$Age)] &amp;lt;- 
  round(mean(titanic$Age, na.rm = TRUE))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Set categorical variables. Variables can be classified as categorical or quantitative. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Categorical variables take on values that are names or labels. ex. Embarked in our dataset.&lt;/li&gt;
&lt;li&gt;Quantitative variables are numerical. They represent a measurable quantity. ex. Age in our dataset.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;titanic$Survived = as.factor(titanic$Survived)
titanic$Pclass = as.factor(titanic$Pclass)
titanic$Embarked = as.factor(titanic$Embarked)
titanic$Sex_num = if_else(titanic$Sex == "male",
                          1,
                          0)
titanic$Sex_num = as.factor(titanic$Sex_num)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay, we get the data ready to use.&lt;/p&gt;

&lt;h1&gt;
  
  
  2. Build, train, and test the model
&lt;/h1&gt;

&lt;p&gt;Choose the variables we would like to discuss. We choose Survived, Pclass, Age, SibSp, Parch, Fare, Sex_num, and Embarked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;df &amp;lt;- 
  titanic %&amp;gt;% 
  select(Survived, Pclass, Age, SibSp, Parch, Fare, Sex_num, Embarked)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the target variable, Survived.Good, it is not a huge class imbalance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; df %&amp;gt;%count(Survived)
# A tibble: 2 x 2
  Survived     n
  &amp;lt;fct&amp;gt;    &amp;lt;int&amp;gt;
1 0          549
2 1          340
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check the distribution and correlation between variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;library(psych)
pairs.panels(df[,],
             ellipses=FALSE,
             pch = 19, 
             hist.col="blue")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdv98kgo9c6qsl0epfdd2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fdv98kgo9c6qsl0epfdd2.png" alt="Distribution and correlation between variables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Split train and test data. Set 75% is train data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;library(caret) 
set.seed(2019)
trainIndex &amp;lt;- createDataPartition(df$Survived, p=0.75, list = FALSE)
train &amp;lt;- df[trainIndex,]
test &amp;lt;- df[-trainIndex,]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Build decision tree model&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;tree &amp;lt;- rpart(Survived ~., data=train, method='class')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does the decision tree look like?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;library(rpart)
prp(tree,         
    faclen=0,           
    fallen.leaves=TRUE, 
    shadow.col="gray",
    ) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fen1d218c3oby4xejh6ae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fen1d218c3oby4xejh6ae.png" alt="Decision Tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another fancier way to take a look a decision tree.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;library(rpart.plot)
rpart.plot(tree)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffd0yoa07dagyqzf3ml6d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffd0yoa07dagyqzf3ml6d.png" alt="rpart"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  3. Evaluate the performance of the model
&lt;/h1&gt;

&lt;p&gt;Use test data to evaluate the performance of the model.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;X_test &amp;lt;-
  test %&amp;gt;%
  select(Pclass, Age, SibSp, Parch, Fare, Sex_num, Embarked)
pred &amp;lt;- predict(tree, newdata=X_test, type=c("class"))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Calculate confusion matrix and plot it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;confus.matrix &amp;lt;- table(real=test$Survived, predict=pred)
fourfoldplot(confus.matrix, color = c("#CC6666", "#99CC99"),
             conf.level = 0, margin = 1, main = "Confusion Matrix")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1rxwxsk0i22mbx19v6ks.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fthepracticaldev.s3.amazonaws.com%2Fi%2F1rxwxsk0i22mbx19v6ks.png" alt="confus matrix"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The accuracy of the model&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; sum(diag(confus.matrix))/sum(confus.matrix)
[1] 0.8333333
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Hope you found this article helpful. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is TensorFlow?</title>
      <dc:creator>Yu Fen Lin</dc:creator>
      <pubDate>Mon, 02 Dec 2019 15:48:00 +0000</pubDate>
      <link>https://dev.to/yufenlin/what-is-tensorflow-9h7</link>
      <guid>https://dev.to/yufenlin/what-is-tensorflow-9h7</guid>
      <description>&lt;p&gt;In this post, we are going to see what is TensorFlow, why TensorFlow, and how does it work?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://camo.githubusercontent.com/0905c7d634421f8aa4ab3ddf19a582572df568e1/68747470733a2f2f7777772e74656e736f72666c6f772e6f72672f696d616765732f74665f6c6f676f5f736f6369616c2e706e67" class="article-body-image-wrapper"&gt;&lt;img src="https://camo.githubusercontent.com/0905c7d634421f8aa4ab3ddf19a582572df568e1/68747470733a2f2f7777772e74656e736f72666c6f772e6f72672f696d616765732f74665f6c6f676f5f736f6369616c2e706e67" alt="TensorFlow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  What is TensorFlow?
&lt;/h1&gt;

&lt;p&gt;&lt;em&gt;“An end-to-end open source machine learning platform.”&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Deep learning is a subfield of machine learning. There are many deep learning frameworks out there. This is a brief overview of the most popular and widely used frameworks.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UrFtNlqx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://analyticsindiamag.com/wp-content/uploads/2018/04/all_libraries.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UrFtNlqx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://analyticsindiamag.com/wp-content/uploads/2018/04/all_libraries.png" alt="Deep Learning Frameworks"&gt;&lt;/a&gt;&lt;br&gt;
Deep Learning Frameworks(Image &lt;a href="https://analyticsindiamag.com/evaluation-of-major-deep-learning-frameworks/"&gt;Source&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;TensorFlow is the most famous deep learning library in the world and a Python-friendly open source library. TensorFlow is a powerful data flow oriented library developed by the Google Brain Team. It is designed to be easy to use and widely applicable to both numeric and neural network oriented problems. It was released under the Apache License 2.0 on November 9, 2015. Google product uses machine learning in all of its products to improve the search engine, translation, image captioning or recommendations. Latest TensorFlow 2.0 was released in October 2019. &lt;/p&gt;

&lt;p&gt;Many popular companies such as NVIDIA, Twitter, Snapchat, Uber and more are using TensorFlow for all their major operations and research areas.&lt;br&gt;
TensorFlow is being used in over 70 K+ open source repositories and 780 K+ commits thus far on GitHub.&lt;/p&gt;

&lt;h1&gt;
  
  
  How TensorFlow works?
&lt;/h1&gt;

&lt;p&gt;TensorFlow is cross-platform. It was built to run on multiple CPUs or GPUs and even mobile operating systems, and it has several wrappers in several languages like Python, C++ or Java.&lt;br&gt;
Given below is an ecosystem of Tensorflow:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UUeIeB_N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://d2h0cx97tjks2p.cloudfront.net/blogs/wp-content/uploads/sites/2/2018/04/main-qimg-b7eeb73f04896b36b3baaf6b447426c4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UUeIeB_N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://d2h0cx97tjks2p.cloudfront.net/blogs/wp-content/uploads/sites/2/2018/04/main-qimg-b7eeb73f04896b36b3baaf6b447426c4.png" alt="an ecosystem of Tensorflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;TensorFlow utilizes dataflow graph for calculations. It describes how data moves through a graph, or a series of processing nodes.&lt;br&gt;
Nodes in the graph represent math operations, and the edges represent multidimensional data arrays (tensors) communicated between them.&lt;br&gt;
The name “TensorFlow” is derived from the operations which neural networks perform on multidimensional data arrays or tensors! It’s literally a flow of tensors. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_ZJYJTUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.tensorflow.org/images/tensors_flowing.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_ZJYJTUo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.tensorflow.org/images/tensors_flowing.gif" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  TensorBoard: TensorFlow's visualization toolkit
&lt;/h2&gt;

&lt;p&gt;TensorBoard provides the visualization and tooling needed for machine learning experimentation. It lets us visualize the graphs, plot quantitative metrics about the graph with additional data like images to pass through it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gibHFKU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.tensorflow.org/tensorboard/images/tensorboard.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gibHFKU1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://www.tensorflow.org/tensorboard/images/tensorboard.gif" alt="TensorBoard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A Japanese farmer turned programmer used it to detect the best quality cucumber, which only his father and mother can do even with their years of experience.&lt;br&gt;
That's the power of Machine Learning, which is now available to everyone because of TensorFlow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Install TensorFlow 2
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;# Current stable release for CPU-only&lt;/code&gt;&lt;br&gt;
&lt;code&gt;pip install tensorflow&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the &lt;a href="https://github.com/tensorflow"&gt;TensorFlow GitHub org&lt;/a&gt;, you can find not only TensorFlow itself, but a useful ecosystem of other repos, including models, serving, TensorBoard, Project Magenta, and many more.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reference:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.tensorflow.org/"&gt;TensorFlow Website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://data-flair.training/blogs/tensorflow-tutorials-home/"&gt;A Complete Guide to TensorFlow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://data-flair.training/blogs/tensorflow-tutorial/"&gt;Tensorflow Tutorial – Tensorflow Ecosystem0&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/TensorFlow"&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Why Data Science</title>
      <dc:creator>Yu Fen Lin</dc:creator>
      <pubDate>Fri, 08 Nov 2019 11:52:16 +0000</pubDate>
      <link>https://dev.to/yufenlin/data-science-the-key-to-the-answer-2ada</link>
      <guid>https://dev.to/yufenlin/data-science-the-key-to-the-answer-2ada</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Finding what people really want is one important thing I care about.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I have been a software and mechanical engineer. As an engineer, I tried to make sure the products meet the needs of my users as much as possible. When interviewing users and analyzing their requirements, I got the problem. It seems difficult for people to clearly say what they need and what they really want. There is a big gap between what people said and what they really want. Data science is a powerful tool to discover the real needs of people. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Asking, “Why?” is the key to everything.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Data science is the study of data. Data analysis is a process with the goal of discovering useful information, informing conclusions and supporting decision-making. Effective analysis requires obtaining relevant facts to answer questions and support a conclusion or opinion. These insights help people to make powerful data driven decisions.&lt;br&gt;
Here is a list of data science deliverables: Prediction, Classification, Recommendations, Pattern detection and grouping, Anomaly detection, Recognition, Actionable insights, Automated processes and decision-making, Optimization, Forecasts.&lt;br&gt;
Whatever questions you may have, data science could provide an objective opinion.&lt;/p&gt;

&lt;p&gt;Data science is becoming pervasive across so many industries. Data science can be applied to many different domains. It is widely used in e-commerce industries, banking, health-care, even film industry.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;In the future&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I would like to apply data science to the mechanical engineering field such as machine monitor, production forecast, failure prevention, improve reliability, and warranty analysis.In automated production, collecting and monitoring data allows us to replace components and maintenance machinery at the proper timing to optimize our productivity.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@tchompalov?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Vlad Tchompalov&lt;/a&gt; on &lt;a href="https://unsplash.com/"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>TEst Title</title>
      <dc:creator>Yu Fen Lin</dc:creator>
      <pubDate>Thu, 07 Nov 2019 14:53:29 +0000</pubDate>
      <link>https://dev.to/yufenlin/test-title-5hmo</link>
      <guid>https://dev.to/yufenlin/test-title-5hmo</guid>
      <description>&lt;p&gt;kjda;lkfjlajs;dkfjsal;jf;jas&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
