Real Numeracy


Town of Barpak after Gorkha earthquake. Image from The Telegraph (UK)

by George Taniwaki

This is the final set of my notes from a machine learning class offered by edX. Part 1 of this blog entry is posted in June 2018.

Step 7: Optimize model

At the end of step 6, I discovered that none of my three models met the minimum F score (at least 0.60) needed to pass the class. Starting with the configuration shown in Figure 5, I modified my experiment by replacing the static data split with partition and sampling using 10 evenly split folds. I used a random seed of 123 to ensure reproducibility.

I added both a cross-validation step and a hyperparameter tuning step to optimize results. To improve performance, I added a Convert to indicator values module. This converts the categorical variables into dummy binary variables before running the model.

Unfortunately, the MAML ordinal regression module does not support hyperparameter tuning. So I replaced it with the one-vs-all multiclass classifier. The new configuration is shown in Figure 6 below. (Much thanks to my classmate Robert Ritz for sharing his model.)

Figure 6. Layout of MAML Studio experiment with partitioning and hyperparameter tuning steps

For an explanation of how hyperparameter tuning works, see Microsoft documentation and MSDN blog post.

Model 5 – One-vs-all multiclass model using logistic regression classifier

In the earlier experiments, the two-class logistic regression classifier gave the best results. I will use it again with the one-vs-all multiclass model. The default parameter ranges for the two-class logistic regression classifier are: Optimization tolerance = 1E-4, 1E-7, L1 regularization weight = 0 .01, 0.1, 1.0, L2 regularization weight = 0.01, 0.1, 1.0, and memory size for L-BFGS = 5, 20, 50.

Truth tableIs 1Is 2Is 3TOTAL
Predict 129615620472
Predict 2621463316516905
Predict 32184717552623
TOTAL9365636342610000
Table 12a. Truth table for one-vs-all multiclass model using logistic regression classifier
PerformanceValue
Avg Accuracy0.76
F1 Score0.64
F1 Score (test data)Not submitted
Table 12b. Performance measures for one-vs-all multiclass model using logistic regression classifier

The result is disappointing. The new model has an F1 score of 0.64, which is lower than the F1 score of the ordinal regression model using the logistic regression classifier.

Model 6 – Add geo_level_2 to model

Originally, I excluded geo_level_2 from the model even though the Chi-square test was significant because it consumed too many degrees of freedom. I rerun the experiment with the variable and keeping all other variables and parameters the same.

Truth tableIs 1Is 2Is 3TOTAL
Predict 135521827600
Predict 2564466214466672
Predict 31975619532728
TOTAL9385636342610000
Table 13a. Truth table for one-vs-all multiclass model using logistic regression classifier and including geo_level_2
PerformanceValue
Avg Accuracy0.80
F1 Score0.70
F1 Score (test data)Not submitted
Table 13b. Performance measures for one-vs-all multiclass model using logistic regression classifier and including geo_level_2

The resulting F1 score using the test dataset is 0.70, which is better than any prior experiments and meets our target of 0.70 exactly.

Model 7 – Add height/floor to the model

I will try to improve the model by adding a variable measuring height/floor. This variable is always positive, skewed toward zero and has a long tail. To normalize it, I apply the natural log transform and name the variable ln_height_per_floor. Table 14 and Figure 7 show the summary statistics.

Variable nameMinMedianMaxMeanStd dev
ln_height_per_floor-1.790.692.300.760.25
Table 14. Descriptive statistics for ln_height_per_floor
Figure 7. Histogram of ln_height_per_floor

I run the model again with no other changes.

Truth tableIs 1Is 2Is 3TOTAL
Predict 136622728621
Predict 2557464014366633
Predict 31576919622746
TOTAL9385636342610000
Table 15a. Truth table for one-vs-all multiclass model using logistic regression classifier, including geo_level_2, height/floor
PerformanceValue
Avg Accuracy0.80
F1 Score0.70
F1 Score (test data)Not submitted
Table 15b. Performance measures for one-vs-all multiclass model using logistic regression classifier, including geo_level_2, height/floor

The accuracy of predicting damage_level = 1 or 3 increases, but the accuracy of 2 decreases. Resulting in no change in average accuracy or the F1 score.

Model 8 – Go back to ordinal regression

The accuracy of the one-vs-all multiclass model was significantly improved by adding geo_level_2. Let’s see what happens if I add this variable to the ordinal regression model which produced a higher F1 score than the one-vs-all model.

Truth tableIs 1Is 2Is 3TOTAL
Predict 180591140
Predict 222715575422326
Predict 33246585834
TOTAL310186211283300
Table 16a. Truth table for ordinal regression model using logistic regression classifier, including geo_level_2, height/floor
PerformanceValue
Avg Accuracy0.78
F1 Score0.67
F1 Score (test data)Not submitted
Table 16b. Performance measures for ordinal regression model using logistic regression classifier, including geo_level_2, height/floor

Surprisingly, ordinal regression produces worse results when the geo_level_2 variable is included than without it.

Model 9 – Convert numeric to categorical

I spent a lot of effort adjusting and normalizing my numeric variables. They were mostly integer values with small range and did not appear to be correlated to damage_grade. Could the model be improved by treating them as categorical? Let’s find out.

First I perform a Chi Square test to confirm all of the variables are significant. Then run the model after converting all the values from numeric to strings, and converting all the variables from numeric to categorical.

Variable nameChi-squareDeg. of freedomP value
count_floor_pre_eq49514< 2.2E-16*
height36737< 2.2e-16*
age69060< 2.2e-16*
area738314< 2.2e-16*
count_families76141.3e-10*
count_superstructure104147.1e-16*
count_secondary_use7943.6e-16*
Table 17. Chi-square results of numerical values to damage_grade

*One or more enums have sample sizes too small to use Chi-square approximation
[ ] P value greater than 0.05 significance level

Truth tableIs 1Is 2Is 3TOTAL
Predict 183623148
Predict 222415445402308
Predict 33256585844
TOTAL310186211283300
Table 18a. Truth table for ordinal regression model using logistic regression classifier, including geo_level_2, height/floor, and converting numeric to categorical
PerformanceValue
Avg Accuracy0.78
F1 Score0.67
F1 Score (test data)Not submitted
Table 18b. Performance measures for ordinal regression model using logistic regression classifier, including geo_level_2, height/floor, and converting numeric to categorical

Changing the integer variables to categorical has almost no impact on the F1 score.

Conclusion

Table 19 below summarizes all nine models I built. Six of them achieved an F1 score of 0.60 or higher on the training data, which would probably have been sufficient to pass the class. Two of them had F1 score of 0.70 which would be a grade of 95 out of 100.

I was unable to run most of these models on the test dataset and submit the results to the data science capstone website. Thus, I do not know what my leaderboard F1 score would be. It is possible that I overfit my model to the training data and my leaderboard F1 score might be lower.

Finding the best combination of variables, models, and model hyperparameters is difficult to do manually. It took me several hours to build the nine models described in this blog post. Machine learning automation tools exist but are not yet robust, nor built into platforms like MAML Studio. (Much thanks again to Robert Ritz who pointed me to TPOT, a Python-based tool for auto ML.)

ModelVariablesAlgorithmTraining dataF1 score (test data)
1NoneNaïve guess = 2None0.56
327 from Table 5Ordinal regression with decision forest0.67 split0.64
427 from Table 5Ordinal regression with SVM0.67 split0.57 (0.5644)
227 from Table 5Ordinal regression with logistic regression0.67 split0.68 (0.5687)
527 from Table 5One-vs-all multiclass with logistic regression, hyperparameter tuning10-fold partition0.64
627 from Table 5, plus geo_level_2One-vs-all multiclass with logistic regression, hyperparameter tuning10-fold partition0.70
727 from Table 5, plus geo_level_2, height/floorOne-vs-all multiclass with logistic regression, hyperparameter tuning10-fold partition0.70
827 from Table 5, plus geo_level_2, height/floorOrdinal regression with logistic regression0.67 split0.67
927 from Table 5, plus convert numeric to categorical, geo_level_2, height/floorOrdinal regression with logistic regression0.67 split0.67
Table 19. Summary of models. Green indicates differences from base case, model 2
Damage caused by Gorkha earthquake. Image by Prakash Mathema/AFP/Getty Images

by George Taniwaki

This is a continuation of my notes for a machine learning class offered by edX. Part 1 of this blog entry is posted in June 2018.

Step 4: Multivariate analysis

Pairwise scatterplots of the numerical variables after adjusting and normalizing are shown in Figure 4 below. The dependent variable (damage_grade) does not appear to be correlated with any of the numerical independent variables. Despite the lack of correlation, I included all the numeric variables when building the model. If I have time, I will convert these numerical variables into categorical ones.

Among the independent variables, covariance is highest between count_floors_pre_eq and height highlighted in green. This makes sense, taller buildings are likely to have more floors. If I have time, I will add a new variable height_per_floor (= height / count_floors_pre_eq).

Figure 4. Pairwise scatterplots of all numerical parameters. Correlations highlighted in green

There are 11 categorical and 23 binary parameters. I used the Chi-square test to compare distributions of these to the distribution of the dependent variable damage_grade, treated as categorical. The results are shown in Table 5 below.

All are statistically significant at 0.05 level, except for the 5 highlighted in red brackets. They will be excluded from the model. Two of the geo_level variables consume too many degrees of freedom given our sample size. (Even big datasets have limitations.) They are highlighted in orange and will be excluded from the model. If I have time, I will add a new custom geo_level variable with about 1000 degrees of freedom. The remaining 27 variables will be retained for use in the model.

Variable nameChi-squareDeg. of freedomP value
geo_level_1_id274660< 2.2e-16*
geo_level_2_id65922272< 2.2e-16*
geo_level_3_id1303910342< 2.2e-16*
land_surface_condition15.940.0032
foundation_type18578< 2.2e-16*
roof_type11224< 2.2e-16
ground_floor_type13478< 2.2e-16*
other_floor_type11176< 2.2e-16
position47.361.6e-08
plan_configuration46.5168.0e-05*
legal_ownership_status80.263.2e-15
has_superstructure_adobe_mud50.321.1e-11
has_superstructure_mud_mortar_stone10532< 2.2e-16
has_superstructure_stone_flag28.626.2e-07
has_superstructure_cement_mortar_stone53.822.1e-12
has_superstructure_mud_mortar_brick37.527.3e09
has_superstructure_cement_mortar_brick6322< 2.2e-16
has_superstructure_timber64.928.0e-15
has_superstructure_bamboo55.121.1e-12
has_superstructure_rc_non_engineered2962< 2.2e-16
has_superstructure_rc_engineered6032< 2.2e-16*
has_superstructure_other9.820.0072
has_secondary_use76.22< 2.2e-16
has_secondary_use_agriculture25.023.8e-06
has_secondary_use_hotel90.92< 2.2e-16
has_secondary_use_rental49.421.9e-11
has_secondary_use_institution10.820.0046*
has_secondary_use_school32.121.1e-07*
has_secondary_use_industry2.32[ 0.31 ]*
has_secondary_use_health_post1.52[ 0.46 ]*
has_secondary_use_gov_office4.22[ 0.12 ]*
has_secondary_use_use_police0.82[ 0.68 ]*
has_secondary_use_other15.320.00049*
has_missing_age3.12[ 0.21 ]*
Table 5. Chi-square results of categorical and Boolean values to damage_grade

*One or more enums have sample sizes too small to use Chi-square approximation
[ ] P value greater than 0.05 significance level

Step 5: Building the model

The dependent variable can take on the value 1, 2, or 3. I could use a classification method like multi-class logistic regression to create our model. However, there is a better way. I will use the ordinal regression algorithm available from Microsoft Azure Machine Learning (MAML).

Ordinal regression requires a binary classifier method. For this project, I will try three classifiers available in MAML, two-class logistic regression, two-class decision forest, and two-class support vector machine (SVM). I will use the default parameters for each classifier and submit all three models as entries in the contest. (This is sort of a cheat to improve the F1 score and my grade. In practice, you should only submit the results using the best model based on the training data.)

A simple model configuration using a static data split and without either a cross-validation step or a hyperparameter tuning step to optimize results is shown in Figure 5 below. I will add these steps later if the simple model does not meet the performance goals.

Figure 5. Layout of a simple MAML Studio experiment

I used a data split of 0.67, meaning 6,700 records were used to train the model and the remaining 3,300 were used to score and evaluate it. I used a random number seed of 123 to ensure every run of my experiment used the same split and produced replicable results.

Step 6: Measuring performance and testing results

A generic truth table for an experiment with 3 outcomes is shown in Table 6a below. Using data from the truth table, four performance metrics can be calculated, average accuracy, micro-average precision , micro-average recall, and geometric average F1 score. The calculation of the performance metrics is shown in Table 6b. Note that since all combinations are measured, recall, precision, and F1 score are all equal. Perhaps the contest should have used the macro-average recall and precision to calculate the F1 score.

Truth tableIs 1Is 2Is 3TOTAL
Predict 1TP1|TN2|TN3FP1|FN2|TN3FP1|TN2|FN3TP1+FP1
Predict 2FN1|FP2|TN3TN1|TP2|TN3TN1|FP2|FN3TP2+FP2
Predict 3FN1|TN2|FP3TN1|FN2|FP3TN1|TN2|TP3TP3+FP3
TOTALTP1+FN1TP2+FN2TP3+FN3Pop
Table 6a. Generic truth table for case with 3 outcomes
PerformanceCalculation
Avg Accuracy∑((TP + TN) / Pop) / 3
Avg Precision (micro)P = ∑TP / ∑(TP + FP)) = ∑TP / Pop
Avg Recall (micro)R = ∑TP / ∑(TP + FN)) = ∑TP / Pop
F1 Score(2 * P * R) / (P + R) = ∑TP / Pop
Table 6b. Performance measures for case with 3 outcomes

Grading for the course is based on the F1 score for a hidden subset of the test dataset as shown in Table 7 below. F1 scores between these points will receive linearly proportional grades. For instance,  an F1 score of 0.65 would earn a grade of 75.

F1 ScoreGrade
< 0.601 out of 100
0.6060/100
0.6470/100
0.6680/100
0.7095/100
Table 7. Grading of project based on F1 score (test data)

Below are the results of my models.

Model 1 – Naïve guessing

The most common value for damage_grade is 2. Any prediction model should perform better than the naïve guess of predicting the damage is 2 for all buildings.

Truth tableIs 1Is 2Is 3TOTAL
Predict 10000
Predict 2310186211283300
Predict 30000
TOTAL310186211283300
Table 8a. Truth table for naive guess of damage_grade = 2
PerformanceValue
Avg Accuracy0.71
F1 Score0.56
F1 Score (test data)Not submitted
Table 8b. Performance measures for naive guess of damage_grade = 2

Model 2 – Ordinal regression model using 2-class logistic regression classifier

The default parameters for the 2-class logistic regression classifier are: Optimization tolerance = 1E-07, L1 regularization weight = 1, L2 regularization weight = 1. Notice in Table 9b the large gap between the F1 score using the training data and the test data. This indicates the model is overfitted.

Truth tableIs 1Is 2Is 3TOTAL
Predict 184521137
Predict 222315675362326
Predict 33243591837
TOTAL310186211283300
Table 9a. Truth table for ordinal regression model using 2-class logistic regression classifier
PerformanceValue
Avg Accuracy0.79
F1 Score0.68
F1 Score (test data)0.5687
Table 9b. Performance measures for ordinal regression model using 2-class logistic regression classifier

Model 3 – Ordinal regression model using 2-class decision forest classifier

The default parameter settings are: Resampling method = Bagging, Trainer mode = Single parameter, Number of decision trees = 8, Maximum depth of trees = 32, Number of random splits per need = 128, minimum number of samples per node = 1.

Truth tableIs 1Is 2Is 3TOTAL
Predict 185551144
Predict 221813354321985
Predict 374726921171
TOTAL310186211283300
Table 10a. Truth table for ordinal regression model using decision forest classifier
PerformanceValue
Avg Accuracy0.76
F1 Score0.64
F1 Score (test data)Not submitted
Table 10b. Performance measures for ordinal regression model using decision forest classifier

Model 4 – Ordinal regression model using 2-class support vector machine (SVM) classifier

The default parameter settings are: Number of iterations = 1, Lambda = 0.001.

Truth tableIs 1Is 2Is 3TOTAL
Predict 13121355
Predict 227316679322872
Predict 36174193373
TOTAL310186211283300
Table 11a. Truth table for ordinal regression model using SVM classifier
PerformanceValue
Avg Accuracy0.72
F1 Score0.57
F1 Score (test data)0.5644
Table 11b. Performance measures for ordinal regression model using SVM classifier

Summary of models in step 6

Unfortunately, none of my initial models performed well. The F1 score never meets the target of 0.70. In fact, in some cases my model don’t do much better than just guessing. (Note: You can see my scores on the contest leaderboard.) In the next section, we will add a cross-validation step and a hyperparameter tuning step to optimize the models and and see if that improves them.

This completes steps 4 to 6 of building a machine learning model. The remaining optimization step and the results are posted at How to create a machine learning model – Part 3.

Damaged buildings resulting from Gorkha earthquake. Image from The Guardian

by George Taniwaki

At the beginning of each quarter edX and Microsoft offer a one-month long course called DAT 102x, Data Science Capstone. The class consists of a single machine learning project using real-world data. The class this past April used data collected by the Nepal government after the Gorkha earthquake in 2015. The earthquake killed nearly 9,000 people and left over 100,000 homeless.

The assignment was to predict damage level for individual buildings based on building characteristics such as age, height, location, construction materials, and use type. Below are the steps I used to solve this problem. The solution is general enough to apply to any machine learning problem. My description is a bit lengthy but shows the iterative nature of tuning a machine learning model.

About machine learning contests

The class project is operated as a contest. Students download training and test datasets, create a model using the training dataset, use the model to make predictions for the test dataset, submit their predictions, and see their scored results on a leaderboard.

As is common for machine learning contests, the training data consists of two files. The first file includes a large number of records (for the earthquake project, there were 10,000). Each record consists of an index and the independent variables (38 building parameters). A separate label file contains only two columns, the index and and their associated dependent variable(s) (in the earthquake project, there is only one, called damage_grade). The two files must be joined before creating a model.

The test file (10,000 more records of building indexes and parameters) has the same format as the training file. You use your model to create an output file consisting of the index and the predicted values of the dependent variable(s). You submit the file to a web service which then scores your results.

You can submit multiple predictions to be scored, adjusting your model after each submission in an attempt to improve your score. Your final score is based on the highest score achieved. To reduce the chance that competitors (students) overfit their model to the test data, the score is based on an undisclosed subset of records in the test file.

Approach to model building

The general approach to building a machine learning model is to first examine the dependent variables using univariate methods (step 1). Repeat for the independent variables (step 2). Normalize the variables (step 3). Examine correlations using multivariate methods (step 4).  Select the relevant variables, choose a model, and build it (step 5). Evaluate and test the model (step 6) and tune the parameters (step 7) to get the best fit without overfitting. Some iteration may be required.

Step 1: Univariate statistics for the dependent variable

There is one dependent variable, damage_grade, labeled with an integer from 1 to 3. Higher values mean worse damage. However, the intervals between each class are not constant, so the scale is ordinal not interval. Descriptive statistics are shown in Table 1 and Figure 1 below.

Variable nameMinMedianMaxMeanStd dev
damage_grade1232.250.61
Table 1. Descriptive statistics for dependent variable
Figure 1. Histogram of dependent variable

Step 2: Univariate statistics for the independent variables

As mentioned above, there are 38 building parameters. Details of the variables are given at Data Science Capstone. The 38 independent variables can be divided into 4 classes, binary, interval integer, float, and categorical as shown in Table 2 below. Notice that the parameter count_families is defined as a float even though it only takes on integer values.

Variable typeQuantityExamples
Binary (Boolean)22has_superstructure_XXXX, has_secondary_use, has_secondary_use_XXXX
Integer, interval4count_floors_pre_eq, height, age, area
Float1count_families
Categorical11geo_level_1_id, geo_level_2_id, geo_level_3_id, land_surface_condition, foundation type, roof_type, ground_floor_type, other_floor_type, position, plan_configuration, legal_ownership_status
Table 2. Summary of independent variables

The binary variables fall into three groups. First is has_superstructure_XXXX, where XXXX can be 11 possible materials used to produce the building superstructure such as adobe mud, timber, bamboo, etc. The second is has_secondary_use_XXXX, where XXXX can be 10 possible secondary uses for the building such as agriculture, hotel, school, etc. Finally, has_secondary_use indicates if any has_secondary_use_XXXX variables is true.

Whenever I have groups of binary variables, I like to create new interval integer variables based on them. In this case, they are named count_superstructure and count_secondary_use which are a count of the number of true values for each. count_superstructure can vary from 0 to 11 while count_secondary_use can vary from 0 to 10.

For the 7 numerical parameters, their minimum, median, maximum, mean, standard deviation, and histogram are shown in Table 3 and Figure 2 below. Possible outliers, which occur in all 7 numerical variables, are highlighted in red.

Variable nameMinMedianMaxMeanStd dev
count_floors_pre_eq1292.150.74
height15304.651.79
age01599525.3964.48
area63442538.4421.27
count_families0170.980.42
count_superstructure1181.450.78
count_secondary_use0020.110.32
Table 3. Descriptive statistics for the 7 numerical variables. Red indicates possible outliers
Figure 2. Histograms for the 7 numerical variables. Red indicates possible outliers

Upon inspection of the dataset, none of the numerical variables have missing values. However, it appears that for 40 records, age has an outlier values of 995. The next highest value is 200. Further, the lowest age value is zero, which does not work well with the log transform. To clean the data, I created a new binary variable named has_missing_age, with value = 1 if age = 995, else = 0 otherwise. I also created a new numerical variable named adjust_age, with value = 1 if age = 0, else = 15 (the median) if age = 995, else = age otherwise.

The variable area has a wide range, but does not appear to contain any outliers.

The variables count_families, count_superstructure, and count_secondary_use do not seem to have any outliers. They also do not need to be normalized.

For the 11 categorical variables, the number of categories (enums), and the names of the enums with the largest and smallest counts are shown in Table 4 below.

Variable nameCount enumsMax label / countMin label / countComments
geo_level_1_id310 / 90330 / 7hierarchical
geo_level_2_id11370 / 157tie / 1hierarchical
geo_level_3_id51727 / 24tie / 1hierarchical
land_surface_condition3d502 / 83112f15 / 347
foundation type5337f / 8489bb5f / 48
roof_type37g76 / 700767f9 / 579
ground_floor_type5b1b4 / 8118bb5f / 10
other_floor_type4f962 / 641267f9 / 415correlated with ground_floor_type
position43356 / 7792bcab / 477
plan_configuration9a779 / 9603cb88 / 1lumpy distribution
legal_ownership_status4c8e1 / 9627bb5f / 61lumpy distribution
Table 4. Descriptive statistics for the 11 categorical variables. Red indicates one or more enums has fewer than 10 recorded instances

None of the categorical or binary variables have missing values. None of the enums are empty, though some of the enums (highlighted in red in Table 4 above) have fewer than 10 recorded instance, so may bias the model. Unfortunately, we do not have any information about the meaning of the enum labels, so do not have a good way to group the sparse enums into larger categories. If this were a real-world problem I would take time to investigate this issue.

Step 3: Normalize the numerical variables

As can be seen in Figure 2 above, some of the independent numerical variables are skewed toward low values and have long tails. I normalized the distributions by creating new variables using the log transform function. The resulting variables have names prefixed with ln_. The descriptive statistics of the normalized variables are shown in Table 5 and Figure 3 below.

Variable nameMinMedianMaxMeanStd dev
ln_count_floors_pre_eq00.692.190.700.36
ln_height01.613.401.460.40
ln_adjust_age02.715.302.611.12
ln_area1.793.536.053.540.46
Table 5. Descriptive statistics for adjusted and normalized numerical parameters
Figure 3. Histograms of adjusted and normalized numerical parameters

This completes the first 3 steps of building a machine learning model. Steps 4 to 6 to solve this contest problem are posted at How to create a machine learning model – Part 2. The final optimization step 7 is posted at Part 3.

Oh light, you really turn me on! Photo by George Taniwaki

[This entry was posted on 17 Sep 2019 and is backdated to keep it in chronological order.]

by George Taniwaki

In the breakfast area of the TownePlace Suite hotel in Mukilteo, Washington, there is a mural painted on the wall of a Boeing 787 soaring above a silhouette of some local attractions. That’s not unusual, Boeing has a large factory in nearby Everett where the 787 is made.

But the mural is so small. It doesn’t cover the whole wall. So someone put a white wood frame around it to make it look like a painting instead of a mural. There, that fixed it.

But the airplane doesn’t pop out. So they added a light fixture above it to highlight it. There is a switch to control it. There, that fixed it.

But the light switch is covered by the faux frame. So they cut a hole in the frame. There, that fixed it.

Luckily the switch cover is white, so this botched attempt at art enhancement isn’t very noticeable. It took me a while staring at the wall while eating my breakfast to figure out what I was looking at.

Much thanks to my wife Susan for doing her best Vanna White impression.

* * * *

Sometimes it isn’t just a frame that ruins the art. Sometimes, the art itself gets ruined by well-meaning but incompetent workers. For some prominent examples of “botched” art restoration, see what happened to Ecce Homo (BBC Sep 2012), King Tutankhamen funerary mask (artnet Jan 2015), Virgin Mary in Ranadoiro (All World Report Sep 2018), and St. George in Navarra (Smithsonian Jun 2019).

* * * *

As a side note, the breakfast the TownePlace Suite includes Chinese (congee), Japanese (misoshiru and rice), and American (sausage, eggs, cereal with milk) options. Pretty odd selection for a suburban hotel until you realize the number of vendors and customers that must stay here while visiting the Boeing plant.

Image from Microsoft and edX

by George Taniwaki

While working toward my Microsoft Data Science Certificate (see Jul 2017 blog post), I also completed the Microsoft Excel for the Data Analyst XSeries Program sponsored by Microsoft and edX.

There are 3 classes in the program, two of which were also courses for the Microsoft Data Science Certificate.

DAT205x – Introduction to Data Analysis using Excel

This basic course on data analysis using Excel covers pivot tables, using SUMIF() and SUMIFS() functions to create dashboards and year-over-year comparison tables (something that is not possible using pivot tables alone), creating reports with hierarchal data, using Power Pivot, and creating multi-table reports using the data model and the More tables… feature.

Year-over-year comparison tables can also be created using the Excel data model and time intelligence functions. These are covered in the third course, DAT 206x.

Time: Since I am already an experienced Excel user, I skipped the videos and just did the homework. I covered the 8 modules in about 6 hours

Score: I missed 1 quiz question and no lab questions for a combined score of 99%

DAT222x – Essential Statistics for Data Analysis using Excel

[I took DAT222x in order to earn the Microsoft Data Science Certificate. This section is copied from this  Jul 2017 blog post.]

This class is comprehensive and covers all the standard statistics and probability topics including descriptive statistics, Bayes rule, random variables, central limit theorem, sampling and confidence interval, and hypothesis testing. Most analysis is conducted using the Data analysis pack add-in for Excel.

Time: I used to work in market research, so I know my statistics. However, there are 36 homework assignments and it took me over 20 hours to complete the 5 modules.

Score: I missed 9 questions on the quizzes (88%) and six in the final exam (81%) for a combined score of 86%. (Despite the time it takes to complete, homework counts very little toward the final grade)

DAT206x – Analyzing and Visualizing Data with Excel

Topics include importing data and using queries with Excel, the Excel data model, using the M query language and DAX query language, creating dashboards and visualizations, and using Excel with Power BI.

Within the M language, topics include using the functions in the ribbon, including filtering rows, Table.Unpivot function.

Within the DAX language, topics include using the X functions like SUMX() and the CALCULATE() function, using Calendar table and time intelligence, and customize pivot tables and pivot charts using the CUBE functions from multidimensional expressions (MDX) language. The CUBE functions can also generate a table that can be used to create chart types that Excel does not support directly from a pivot table (for instance the new treemap, sunburst, and histogram charts).

Time: I am an experienced Excel user, but some of the advanced DAX functions were new to me. 6 hours for 8 modules

Score: I got a bit sloppy. I missed 2 lab questions and 1quiz question for a combined score of 95%

Final Certificates

Below is my certificate of completion for the Microsoft Excel for the Data Analyst XSeries Program.

ExcelXSeries Certificate

Below is my certificate of completion for the Professional Certificate for Data Analysis: Essential Skills. This was awarded to me because I had previously taken DAT201x – Querying with Transact-SQL.

Painted Hills Unit of John Day Fossil Beds, photo from American Southwest

[This entry was posted on 22 Aug 2019 and is backdated to keep it in chronological order.]

by George Taniwaki

While traveling to eastern Oregon to see the total solar eclipse (Real Numeracy, Aug 2017), Sue and I also checked out some science under our feet, learning about the Cenozoic era. That’s the current geologic era, the past 65 million years since the dinosaurs became extinct and mammals and birds became plentiful.

Our solar system is over 4,800 million years old, so the Cenozoic era covers less than 1.5% of the total geologic history of the earth. The Cenozoic era is divided into 3 periods which are divided into 7 epochs.

In this blog post I’ll cover the landmarks we visited in geologic timeline order. They are not in the order we visited them, and we did not visit all of these sites during a single trip.

Geologic map of Washington State, Image from USGS

Paleocene—Volcanic ash at John Day

Driving south from the Columbia River along the John Day River, you will see well-defined stripes of gray, red, and yellow sandstones. The oldest of these sediments were laid down during the Paleocene epoch (not to be confused with the larger Paleogene period) 65 to 55 million years ago. The latest were laid down during the Miocene epoch 23 to 5 million years ago.

Large and small mammals, most now extinct, roamed the plains here. At different times, they included 3-toed horses, camels, elephants, sloths, oreodonts, and saber-toothed cats. You can see some great artist drawings here.

This was also a time of significant volcanic activity. Magma rising from the mantle circulated to the crust creating inclusions and volcanoes in a volcanic arc.

If you look closely at the layers of rocks along the John Day River, you will see interspersed are thin layers of harder volcanic ash and lava. By measuring the ratio of isotopes in the ash layer, one can date the eruption and thus the age of the fossils found in the layer. By comparing fossils in different layers, one can build a family tree of the species.

When the hard volcanic ash and lava erodes away, it exposes the softer sandstones below. Once exposed, wind and water carved the steep canyons you see, called badlands. To learn more about the fossils, volcanoes, and current wildlife of the region, stop at the Thomas Condon Paleontology and Visitor Center  at the Sheep Rock Unit of John Day Fossil Beds National Monument.

The Thomas Condon Visitor Center and a working lab, Photos from National Park Service

Eocene—Coal seams near Seattle

When plants, especially trees, fall into anoxic water, they are less likely to decay. If they remain undisturbed and are then covered by sediment, they will remain preserved even when the water recedes. Continued sedimentation creates high temperatures and pressures, slowly converting the plant material into peat, lignite, and finally to coal. There are two types of coal, bituminous, which is soft and tar-like, and anthracite, which is hard and shiny. Fossils and amber can often be found in all of these deposits.

In the Eocene epoch, about 55 to 35 million years ago, the earth was warmer than it is now. The area around what is now Seattle was above sea level and covered with forests, though the ground was swampy and muddy. These are the perfect conditions for creating coal seams. (For more, see Wenachee Valley College, Lecture 8.)

Commercial quantities of bituminous coal were first discovered east of Lake Washington in the 1860s (HistoryLink Jan 2003). Prospectors created both open pit and shaft mines throughout the region and used horse-drawn wagons and barges to cross the lake and haul the coal to the port in Seattle. Most of the coal was then carried by steamship to San Francisco. In 1870, a rail line was built from Newcastle going south around the lake to Seattle. This significantly reduced transport costs and coal production boomed. One hundred years later, the industry was in decline. The last mine closed by 1975.

The main road through the town of Newcastle, which is named after the coal mining town in England, is Coal Creek Pkwy. Coal Creek itself runs through Cougar Mountain Regional Park. And near the northwest edge of the park there is the Ford Slope coal mine exhibit. It’s worth a stop and only a few miles from my house.

There are more coal mines at Flaming Geyser State Park near the town of Black Diamond (which is another coal reference). Unfortunately, the park’s name is a lot more exciting than the park itself. There are no flames and no geysers. The name flaming geyser refers to vents in the mines to release water and methane (natural gas). The gas was flared off to prevent explosions. Today the vents are capped with concrete and there is not much to see here except an interpretive display.

Miners at Cougar Mountain, photo from Museum of History and Industry; A nonflaming nongeyser, photo from Washington State Parks

Pleistocene—Cone shaped volcanoes

Nearly all the cone shaped volcanoes in the North Cascades were formed during the Pleistocene epoch, 2.5 million to 125,000 years ago. This includes the two most famous volcanoes in the range, both near the Washington-Oregon border.

At 4392m (14,410 ft), Mt. Rainier is the tallest mountain in Washington and is visible from Seattle. Mt. Rainier National Park is big, but there are only two main roads, so can get congested in the summer.

The other, Mt. St. Helens, erupted on May 18, 1980. I remember watching the TV news in Denver that day. The north face of the mountain collapsed, creating a pyroclastic landslide that instantly killed thousands of trees along with lots of wildlife and 57 people. The landslide flooded Spirit Lake which caused a tsunami that overflowed onto the Toutle River.

The eruption ejected about 4 km3 of rock, dust, and ash into the air. The fallout caused heavy damage as up to 1m (3’) of abrasive dirt clogged streets, houses, cars, and farms in downwind communities. I also remember about 3 days later a layer of fine dust coating all the cars and windows in Denver, which is about 2,000km (1,200 miles) downwind from Mt. St. Helens.

Today the Mt. St. Helens National Volcanic Monument is a natural laboratory showing how an area changes after a volcanic eruption.

Iconic view of conical Mt. Rainier from Green Lake Seattle, photo from Brian Overland; A conical Mt. St. Helens before the eruption, photo from USFS.

Pleistocene—Glacial moraine in my backyard

The Pleistocene epoch is also known as the ice age. Over the past 2.5 million years, the fluctuations of the earth’s temperature in the mid-latitudes were in a range nearer the freezing point of water, sometimes above and sometimes below. This caused the polar ice caps to repeatedly advance and recede. The ground in many parts of Washington and Oregon has been scoured and eroded by multiple passes of glaciers. (For more see Wenatchee Valley College, Lecture 2).

Glaciers are like very slow moving rivers. As they flow, they scour the soil and rocks and sometimes carry them downstream. The rocks become rounded, like river rocks and the soil is finely ground into rock flour. Deposits of this material are called moraines.

The current epoch, known as Holocene, is an interglacial period where the climate is slightly above the freezing point of water and the glaciers have mostly disappeared. There are only few glaciers left in Washington or Oregon, all high in the mountains. The North Cascade Glacier Climate Project has been collecting data on these glaciers since 2005.

However, evidence of past glaciation is all around. Just digging a simple hole in my backyard is a herculean task because the ground is so hard and rocky. However, the ground is not made of clay (phyllosilicates), instead it is rock flour made mostly of ground quartz.

Rainier glacier, photo from NCGCP; Rocks and soil in my backyard

Holocene—Lava tubes at Mt. St. Helens

Sometimes the lava on the outside of a flow cools and hardens while the lava in the interior remains hot and continues to flow. This leaves a cavity called a lava tube. The most famous lava tubes are on the island of Hawai’i. But they can occur with any volcano, even on the Moon, Venus, or Mars.

In Washington, there is a lava tube, called Ape Cave, south of Mt. St. Helens. It was formed during our current epoch, called the Holocene, which started 12,000 years ago. The cave was probably created about 2000 years ago and is about 4 km (2.5 mile) long.

Going bananas in Ape Cave, photo from Daily Nathan on Reddit

Holocene—Ice caves at Mt. Rainier

Glacier caves are formed when water flows through a glacier. The heat melts the ice, forming a cavity. The air acts as an insulator, keeping the cavity warmer than the surrounding ice. Eventually, the cavities merge, forming a system of caves. The caves are unstable and can quickly be created or destroyed as the glacier moves or collapses.

The Paradise Ice Caves at the base of Mt. Rainier were once a popular stop for tourists. They were first discovered in 1908. They disappeared in the 1940s and again in the 1990s due to glacial recession. Because of global warming, it is believed that the caves are unlikely to return again until the next cooling trend.

A lone ranger in Paradise Cave circa 1958, photo from National Park Service

Holocene—Nike Missile Site

Back at the top of Cougar Mountain (about 2 miles east of the Ford Slope coal mine) are the remains of a control site and launch silo that were part of the Nike anti-aircraft missile program, built in the 1950s during the cold war. It is one of several launch sites in and around Seattle. It was dismantled in the 1970s and there isn’t much left to see.

This is obviously not a geological landmark. But it is still worth a visit to contemplate that humans have the ability to cause the end of life on Earth as we know it.

Sign post to the end of days, Photo from Beautiful Washington

For more geology field trips, see Science field trip–Northern plains (Oct 2018) and Science field trip—Bay of Fundy (Jun 2012).

Image from Microsoft and edX

by George Taniwaki

Big data and machine learning are all the rage now. Articles in the popular press inform us that anyone who can master the skills needed to turn giant piles of previously unexplored data into golden nuggets of business insight can write their own ticket to a fun and remunerative career (efinancialcareers May 2017).

Conversely, the press also tells us that if we don’t learn these skills a computer will take our job (USA Today Mar 2014). I will have a lot more to say about changes in employment and income during the industrial revolution in future blog posts.

But how do you learn to become a data scientist. And which software stack should one specialize in? There are many tools to choose from. Since I live in the Seattle area and do a lot of work for Microsoft, I decided to do take an online class developed and sponsored by Microsoft and edX. Completion of the course leads to a Microsoft Data Science Certificate.

The program consists of 10 courses with some choices, like conducting analysis using either Excel or Power BI, and programming using either R or Python. Other parts of the Microsoft stack you will learn include SQL Server for queries and Microsoft Azure Machine Learning (MAML) for analysis and visualization of results. The courses are priced about $99 each. You can audit them for free if you don’t care about the certificates.

I started the program in February and am about half way done. In case any clients or potential employers are interested in my credentials, my progress is shown below.

DAT101x – Data Science Orientation

If you haven’t been in college in a while or have never taken an online class, this is a good introduction to online learning. The homework consists of some simple statistics and visualization problems.

Time: 3 hours for 3 modules

Score: 100% on 3 assignments

DAT201x – Querying with Transact-SQL

I took a t-SQL class online at Bellevue College two years ago. Taking a class with a real teacher, even one you never meet, was a significantly better experience than a self-paced mooc. This course starts with the basics like select, subqueries, and variables. It also covers intermediate topics like programming, expressions, stored procedures, and error handling. I did my homework using both a local instance of SQL Server and on an Azure SQL database.

Time: 20 hours for 11 modules

Score: I missed one question in the homework and two in the final exam for a combined score of 94%

DAT207x – Analyzing and Visualizing Data with Power BI

I already have experience creating reports using Power BI. I also use Power Query (now called get and transform data) and M language and Power Pivot and DAX language, so this was an easy class.

The course covers data transforms, modeling, visualization, Power BI web service, organization packs, security and groups. It also touches on the developer API and building mobile apps.

Time: 12 hours for 9 modules

Score: I missed one lab question for a combined score of 98%

DAT222x – Essential Statistics for Data Analysis using Excel

This class is comprehensive and covers all the standard statistics and probability topics including descriptive statistics, Bayes rule, random variables, central limit theorem, sampling and confidence interval, and hypothesis testing. Most analysis is conducted using the Data analysis pack add-in for Excel.

Time: I used to work in market research, so I know my statistics. However, there are 36 homework assignments and it took me over 20 hours to complete the 5 modules.

Score: I missed 9 questions on the quizzes (88%) and six in the final exam (81%) for a combined score of 86%. (Despite the time it takes to complete, homework counts very little toward the final grade)

DAT204x – Introduction to R for Data Science

Now we are getting into the meat of the program. R is a functional language. In many ways it is similar to the M language used in Power Query. I was able to quickly learn the syntax and grasp the core concepts.

The course covers vectors, matrices, factors, lists, data frames, and simple graphics.

The lab assignments use DataCamp which has a script window where you write code and a console window that displays results. That makes it easy to debug programs as you write them.

The final exam used an unexpected format. It was timed and consisted of about 50 questions, mostly fill-in-the-blank responses that include code snippets. You are given 4 minutes per question. If you don’t answer within the time limit, it goes to the next question. I completed the test in about 70 minutes, but I ran out of time on several questions, and was exhausted at the end. I’m not convinced that a timed test is the best way to measure subject mastery by a beginning programmer. But maybe that is just rationalization on my part.

Time: 15 hours for 7 modules

Score: I got all the exercises (ungraded) and labs right and missed two questions in the quizzes. I only got 74% on the final, for a combined score of 88%

DAT203.1x Data Science Essentials

The first three modules in this course covered statistics and was mostly a repeat of the material introduced in DAT222x. But the rest of the course provides an excellent introduction to machine learning. You learn how to create a MAML instance, import a SQL query, manipulate it using R or Python, create a model, score it, publish it as a web service, and use the web service to append predictions as a column in Excel. I really like MAML. I will post a review of my experience in a future blog post.

The course was a little too cookbook-like for my taste. It consisted mostly of following directions to drag-drop boxes onto the canvas UI and copy-paste code snippets into the panels. However, if you want a quick introduction to machine learning without having to dig into the details of SQL, R, or Python, this is a great course.

Time: 10 hours for 6 modules

Score: 100% on the 6 labs and the final

Next steps

I have now completed six out of the ten courses required for a certificate. I expect to finish the remaining 4 needed for a certificate by the end of the year. I will also probably take some of the other elective courses simply to learn more about Microsoft’s other machine learning and cloud services.

For my results in the remaining classes, see Microsoft Data Science Certificate-Part 2

* * * *

[Update: Modified the description of the final exam for DAT204x.]

« Previous Page — Next Page »