View this post on RPubs: rpubs.com/JiawenQi/GridSearchIris View this post on Github: github.com/JiawenQi98/KeepLearningR/blob/master/Grid%20Search%20of%20Iris%20Dataset.Rmd IntroductionOn Dec 10th, Simon Jackson blogged a new article about Grid Search in the tidyverse: https://drsimonj.svbtle.com/grid-search-in-the-tidyverse As a beginner in this field, Grid Search is a new term for me.
Decision Tree Example of IrisIris dataset is very famous and predictable. Let’s predict the Species by other four features
Let’s do a decision tree.
Split Training and Testing80% training, and 20% testing.
Create the GridDefine hyperparameter combinations: (you can try different value for minsplit and maxdepth)
Create a Model FunctionCreate a function to go through our grid search hyperparameter combinations and modeling easily.
Fit the ModelsIterate down the values and fit our models.
Obtain Accuracy Create a function to get accuracy easily:
Arrange ResultsSort results by high-accuracy, more-minsplit and less-maxdepth:
Take Away
0 Comments
It's the season of holidays. The gift from Tableau Public is a bunch of free and interesting datasets. Merry Vizmas! Follow These Tableau-Themed Advent Calendars: https://public.tableau.com/en-us/s/blog/2016/12/merry-vizmas-follow-these-tableau-themed-advent-calendars The dataset for Dec 1st is Global Heights. The heights in this dataset is the mean height at age 18 for a country by sex.
1. Import Data Into TableauThe format of the data is xlsx with size of 2.2 MB. Click Excel in the Connect Panel, locate to Global Heights data, and Open. 2. Quick View with R
R can give us a quick summary of each field. 2.1 How many countries are included?200 countries are included in this dataset. 2.2 The range of Year of birthThe mean height are come from the people born from 1896 to 1996. So the year of collecting the data is from 1914 to 2014, 101 years. 2.3 Highest Man & WomanThe highest mean height of men is 182.5673 cm from Netherlands born in 1985. For women, it's 169.7979 cm from Latvia. 2.4 Shortest Man & WomanMen from Lao PDR born in 1896 has the lowest mean height, 152.8846 cm. Women from Guatemala born in 1986 are 140.29 cm. 3. Basic Visualizations3.1 Statistics on Maps
Generally speaking, height of people in Greenland grows faster than others. Men in China and nearby countries has the height more than average of the world 100 years later. However, people in Africa Area seems left behind. 3.2 Trend Lines
From 1896 to around 1970, there is an obvious increasement of height for the whole world. However, after 1980, there is even a decreasement.
Interesting results and also the questions to consider. 3.3 Make A DashboardTo make dashboards, the thing to consider is what people would like to see with the dashboard. Several points in my mind:
https://public.tableau.com/profile/jiawen.qi#!/vizhome/Book1_15239/GlobalHeight 4. Do a simple linear regressionThe overall MES is 2.53. The range of height is 140~183. The prediction is not bad.
|
Archive
February 2017
Category |