The versatile design of this shoe rack can fit many needs. All photos by George Taniwaki

by George Taniwaki

I’m a member of the Washington Karate Association, which has a dojo in Bellevue. Traditionally, one removes shoes before entering a Japanese home or a sacred area. The genkan or foyer of the dojo has a shoe rack for the students. The current one needed to be replaced and I offered to make one. An exploded view of my design is shown in Figure 1 below. The design ideas and the techniques I used to make this shoe rack can also be scaled up or down for your needs.

Shoe rack design

The shoe rack will get heavy use as there are up to 4 classes a day at the dojo. On rainy and snowy days, the shoes can be wet. For durability and water resistance, I decided to make the shoe rack out of 19mm (3/4″) particle board with melamine surface on both sides. I will cover any exposed edges with melamine edge banding.

Children tend to lean on or step on the shoe rack. To help resist damage, I will reinforce the shelves by adding a lip to the front.

To keep water from wet shoes from dripping on the floor, I will tip the shelf toward the front by 50mm (2″), or about 12 deg. The lip will then catch any water.

The melamine boards I used come in 2.4m (8′) lengths. Even with the reinforcement provided by the lip, I decide the shelves should be 1/3 the length of a full board or 0.8m (2′-8″) long. (I felt that a shelf 1/2 the length of a full board or 1.2m (4′) could sag or break.)

To ensure tall boots can fit on the shoe rack, I space the shelves 250mm (10″) apart.

I want every child to be able to reach every shelf, so the rack will only have 4 shelves, making it 1m (40″) tall. This also  leaves room under the shoe rack for any overflow shoes.

Finally, the rack will be heavy, so I  will include two holes, each 100mm (4″) in diameter on each side near the top to act as carrying handles.

There are many ways to attach the shelves to the sides of the shoe rack. I decided to rout out a mortise into the sides and use glue and screws to attach the shelves. The mortise should support the weight of a child without a bracket and also help resist racking.

Figure 1. Exploded view of the shoe rack

The basic design of this shoe rack is very versatile. More shelves can be added to make a taller rack for a walk-in closet. Or it can be made with fewer shelves and using furniture grade wood to fit the entryway of a Japanese-style home.

Cut the stock and prepare the shelves

The first step is to cut the sides and shelves to length using a panel saw, table saw, sliding miter saw, or handheld circular saw (Fig 2a). Use a sharp blade and push the stock (or the saw) slowly to get a clean cut.

I used a circular saw to make my cuts. Notice that I use a 50mm (2″) thick sheet of polystyrene foam insulation as a sacrificial backing board under the work piece. It’s cheap, flat, smooth, light, easy to keep clean, sturdy, and protects your blade (or router bit) from damage.

Each shelf will consist of a bottom and a front cut from a single piece (Fig 2b). The front will have a dado that the bottom will fit into. Use a table saw with a dado bit to plough a 19mm wide by 5mm deep (3/4″ x 0.2″) dado (Fig 2c) on each shelf. The dado will be on the front of the shelf and will receive the bottom. Rip the shelves to separate the bottoms from the fronts (Fig 2d). Before cutting the actual stock, make a prototype and check dry fit (Fig 2e).

Figures 2a to 2e. Cut parts to length; Design detail for the shelves; Plow dado for shelf front; Rip the shelf to separate the bottom from the front; Test dry fit of prototype

[Note: Table saw riving knife, blade guard, and dust collector removed for demonstration only. Do not operate power tools without safety features in place.]

Assemble the shelves

Dry fit the shelf bottoms and fronts, selecting the better surface to be the top. Then glue them up, clamp, and let dry overnight (Fig 3a). Notice how I clamped all four shelves at once. I laid heavy tiles on top to keep the shelf bottoms from popping up. I also put shims underneath the back of the shelf bottoms to keep the shelf bottoms parallel to the bar clamps and the shelf fronts perpendicular to the bottoms.

Unclamp the shelves and stand them front side down. The backs of the shelf bottoms will have a raw edge. Cover them with melamine edge banding (Fig 3b) and trim off the excess (fig 3c). For more details on using hot-melt adhesive banding, see this Oct 2012 blog post.

I did not bother to add banding to the raw edge on the bottom of the shelf front.

Figures 3a to 3c. Glue up the shelves; Apply melamine edge banding to the back of the shelf bottoms; Trim the banding

Mortise the sides

To cut a clean mortise, you must use a template. See this Jun 2019 blog post on how to make a perfect mortising template for a shape that consists of right angle corners.

Using a pencil and straight edge, lay out the position of the shelves every 250mm (10″) on the left and right sides with the 50mm (2″) slope. Lay the left and right mortising templates onto the sides and ensure they align to the pencil marks.

Remove the templates and drill two 4mm (5/32″) holes in the sides for each shelf (Fig 4a). There may be a small amount of tear out. Flip the side over and countersink the screw holes by 3mm (1/8″)  (Fig 4b).

Flip the sides over again, align the templates to the pencil marks, and rout out 5mm (0.2″) deep mortises using a plunge router (Fig 4c). If you do not own a plunge router, first use a Forstner bit to create 5mm (0.2″) deep holes for the router bit. This will prevent kickback that could gouge the sides or the templates.

Figure 4a to 4c. Drill the pilot holes; Countersink the pilot holes; Use the jig and cut the mortises

Add handholds and banding

The shoe rack will weight about 25kg (55 lb). To make it easier to move, cut handholds at the top of each side. The most important consideration is to avoid tear out. Mark the location of the center of the hand hold and drill a pilot hole through the side (Fig 5a). Using a drill with a 100mm (4″) hole cutting bit to cut through one surface of the melamine (Fig 5b). Make sure the drill is up to speed before making contact with the melamine surface to reduce tear out. Press down on the surface lightly so that the speed stays high. Cut about half way through the side.

Flip the side over and repeat on the other side (Fig 5c) until the hand hold is complete. Cutting from both sides rather than one side reduces chance of tear out.

Cut the melamine edge banding to length (Fig 5d) and apply it (Fig 5e). Note that you probably cannot get a hot iron to follow the concave surface of the handhold and get hot-melt banding to adhere to the surface. Instead I used self-adhesive banding. The adhesive is not as strong as hot-melt adhesive.

Figure 5a to 5e. Drill a pilot hole for handholds through the side; Use hole cutting bit and drill through one surface of the melamine; Turn over a drill through the other surface; Cut and lay out the self-adhesive melamine banding; Apply the banding

Final assembly

Before final assembly, remove any adhesive residue from the shelves and sides using mineral oil (dissolves most sticky adhesives) followed by warm soapy water (Fig 6a).

Label the four shelves to indicate which mortise it will fit into, selecting the best shelf for the top, which is the most visible. Use a chisel to clean the corners of the mortises and to make any adjustments to ensure the shelf fits (Fig 6b).

Dry fit the shelves into the sides and drill two 2mm (5/64″) pilot holes in each shelf (Fig 6c). Glue up the shelves to one of the sides and drive two 4mmx40mm (#7 x 1-5/8″) screws into each shelf (Fig 6d). Flip over and repeat on the other side. The screws will hold the shelves in place so there is no need to use clamps.

After the glue has dried, fill the screw holes and any gaps in the joints with white caulk.

Figure 6a to 6d. Clean the finished shelves and sides; Use a chisel to clean the corners of the mortises; Drill pilot holes; Glue up, add screws, flip over a repeat

* * * *

[Update: There was a flaw in my design of the shoe rack. The 10″ depth for the shelves works fine for children’s shoes, but not for adults. The solution was to turn the rack around. A picture is shown below. I think it looks fine this way.]

Figure 7. The shoe rack flipped around so that adult shoes will fit

Spring is in the air, get planting! All photos and drawings by George Taniwaki

by George Taniwaki

My wife, Sue, bought three plastic planters shaped like oak wine barrels and three shepherd hooks to put in them (two shown above). Before putting the planters in the garden, I noticed several problems with them.

  1. There are no drainage holes on the bottom. Real oak barrels have gaps between the staves which will allow excess water to drain out. A plastic barrel will fill with water and may allow the plant roots to rot.
  2. There are no feet to elevate the bottom. If I add drain holes to the bottom of the planters, they will eventually get plugged if the bottom is in contact with the ground.
  3. The shepherd hooks are heavy and will tilt over if not supported.
  4. Once filled with dirt, the planters will be too heavy to easily move and may break if lifted.

Naturally, I could not just ignore these problems. So I spent a weekend fixing them before transferring the plants into the new planters. My solutions to these problems are listed below and illustrated in the pencil sketch (Fig 1).

  1. Add three drainage holes to the bottom of each planter.
  2. Add four rot-resistant feet to the bottom of each planter.
  3. Add a pillow filled with lightweight and rot-resistant foam peanuts to the bottom of each planter to reduce the amount of soil needed to fill it. It should also help keep the drain holes from getting clogged.
  4. Add a vertical sleeve made of copper plumbing pipe in the center of each planter to hold the shepherd hook.
Figure 1. Pencil sketch of the planter

Make the feet and attach them

Using a 5mm (3/16”) diameter bit, drill seven holes through the base of each planter.  Six holes  are equally spaced on the rim (a hexagonal pattern) and the seventh goes in the center (Fig 2a). Three holes on the rim and the center hole will hold the feet. The other three holes will be for drainage.

Using 100mm (4”) diameter hole cutting bit, cut out four feet for each planter from a scrap piece of 125x20mm (5×3/4”) plastic decking (Fig 2b). If needed, use a Forstner bit to countersink the bottom of each foot to accept a fender washer (Fig 2c).

Using 5x60mm (#8 x 2-1/2”) bolts with fender washers and nuts, attach four feet to each planter (Fig 2d, 2e). Actually, only the center bolt needs to be long so that it can hold the copper pipe. The other bolts can be shorter, but I didn’t want to take the time to buy and sort different length bolts.

Figures 2a to 2f. Drill seven holes in planter base; Cut out the feet; Countersink feet to accept fender washers; Bolt, washers, foot, and nut; Attach feet to the planter; Inside of planter showing bolts

Make the sleeves and attach them

Start with a 1m (3’) piece of 13mm (1/2”) copper pipe and cut it into three 330mm (12”) long pieces. Drill a 3mm ( 1/8”) diameter hole, 50mm (2”) from one end (Fig 3a).  The hole will allow water to drain out of the sleeve.

Mix up a batch of epoxy putty (also called wood filler or Bondo). Find the end of the copper sleeve with the drain hole and fill 25mm (1”) of the end of the sleeve (Fig 3b). Push the sleeve onto the center bolt and add putty around the base of the sleeve to securely attach it (Fig 3d).

Figures 3a, 3b, 3c. Cut the copper sleeve and drill drain hole; Mix up epoxy putty; Attach the sleeve to the bottom of the planter

Make the donut-shaped pillow

Lay out a roll of nonwoven polypropylene ground fabric. Trace out two instances of the top of the barrel (Fig 4a). Cut out the fabric, outside the lines you have drawn, making a donut shape. Sew the two halves together, leaving a 100mm (4”) opening to allow filling. Pour about 0.02m3 (0.5 cu.ft.) of foam peanuts (Fig 4b) into the pillow and finish sewing the seam (Fig 4c). Place the finished pillow over the copper sleeve and lay it at the bottom of the planter (Fig 4d).

Figures 4a, 4b, 4c, 4d. Cut out the fabric; Example of polystyrene foam peanuts (with cat); Sew the two halves together and fill with foam peanuts; Place the pillow in the bottom of the planter

Finish and admire

Clean off any excess rust from the shepherd hook (Fig 5a). Place the planter in the desired spot in the garden, fill it with dirt, being careful not to detach the sleeve or get dirt in it. Transfer any plants. Slide in the shepherd hook (Fig 5b). Water the plants. Admire your work.

This project took a weekend and only cost a few dollars since I had almost all the materials already on-hand. (I guess I keep a lot of junk around in my tool shed.)

Figures 5a, 5b. Clean the shepherd hooks; Detail of copper sleeve with shepherd hook

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.

Example of a half-page flyer. Courtesy of Sandra Driscoll

by George Taniwaki

Once you and your kidney matchmaker have mailed letters to all of your friends, relatives, and others on your mailing list, consider broadcasting your message to an expanding circle to include coworkers, church members, neighbors, and others in your social network who you don’t know as well. One or more of them may be willing to begin the donor evaluation process. But until you tell them, they are unlikely to know of your need for a kidney donor. And if they don’t know, they won’t get tested.

One of the best way to reach these folks is a flyer (see example above) posted on a message board where they can see it.

Design a flyer

A flyer can be almost any size from business card (2” x 3-1/2”) to poster (24” x 36” or more). For convenience, I recommend making it 8-1/2” x 11” (or A4 size in Europe) with vertical (portrait) orientation. A good flyer is like an advertisement. It must catch a person’s attention and make them want to stop and read it. Like an advertisement it should have the contain the following elements:

  1. Headline
  2. Photograph or illustration
  3. Message to potential donors
  4. Your contact information
  5. Logo (optional)
  6. QR code (optional)
  7. Tear-off tabs (optional)
  8. Calling card holder (optional)

Tips for creating a flyer are available at the Living Kidney Donor Search (LKDS) website

Items 1 through 5 (Headline to Logo)

Advice for creating a headline, photograph or illustration, message to potential donors, your contact information, and logo are provided in a separate Nov 2013 blog post.

The advice in that blog post was specifically targeted toward the design of a calling card, which is generally much smaller than a flyer. Just because a flyer has more space available doesn’t mean you need to fill it all with text. Having abundant white space makes the flyer attractive and can guide the eye to the important information. Use the extra space to make the headline bigger, make the picture bigger, and add more white space around your message to potential donors. Resist the temptation to add more text and make your story more detailed. Instead keep it the same as your calling card. Or, if you do add more text, do it to make your story more persuasive in order to drive people to your website or take other action.

Add a QR code to your flyer

A QR code is a 2-dimensional bar code (Fig 2). Anyone who owns a smartphone with a built-in camera and a bar code reading app can scan the bar code and be directed to a website with more information.

If you have a personal website or Facebook page with information about your need for a kidney donor, you should add a QR code to your flyer. You can do this by going to http://delivr.com/. This free service will create a bar code for you. Further, every time someone scans your bar code, it will track it and provide you with statistics about the users.

For instance, I created an account on delivr.com. I created a new campaign and entered the address for my patient guide, https://realnumeracy.wordpress.com/kidney-patient-guide/. The delivr.com service creates a custom link for me delivr.com/2tpt6 and generates the QR code that I can include anywhere (Fig 2).

Figure 2. QR code that directs readers to delivr.com/2tpt6 and redirects to realnumeracy.wordpress.com/kidney-patient-guide

An example of a flyer with a QR code is shown below (Fig 3). One suggestion to improve this flyer. I would include the web address in the flyer. That way, people without a smartphone can still visit the website by writing down the address and visiting it once they get home.

Figure 3. Example of a flyer with QR code. Image from Shining Strong for Tarra

Add tear-off tabs to your flyer

To engage people who don’t have a smartphone, you can add tear-off tabs to the bottom of your flyer. The tear-off tab should include your phone number and website address (Fig 4). A little trick to make people more likely to tear off one of the tabs is to tear the first one off yourself before posting the flyer.

Also remember to include all the contact information in the body of the flyer so that people can copy it down in case all the tabs are taken.

Figure 4. Example of a flyer with tear-off tabs. Image from KidneyQuest.com

Add a calling card holder to your flyer

Even better than tear-off tabs is folding the bottom of the flyer to create a pocket to hold your calling cards (Fig 5). Encourage people to take one. Again, remember to include all the contact information in the body of the flyer so that people can copy it down in case all the calling cards are taken.

Figure 5. Example of a flyer with calling card holder

Printing and distributing your flyers

The least expensive way to print your flyers is to use a home inkjet printer. If you don’t have one, you may be able to have your matchmaker or another friend print them for you. Otherwise, you can have them printed at a local print shop. For great tips on choosing paper and printing flyers check out the LKDS website.

Places that often have a bulletin board where you can post your flyer include:

  1. The print shop where you bought your flyer
  2. Grocery stores
  3. Your workplace or union hall and those of all your friends and family members
  4. Local shopping malls/strip malls
  5. Churches

Remember to get permission from the owner of the bulletin board before posting your flyer.

To make it easy for your friends and family to print their own flyers, make sure a copy of it is posted on your website.

For more ideas on finding a donor, see my Kidney patient guide.

Example of a Kidney Kampaign calling card. This is the card used by Harvey Mysel, the founder of Living Kidney Donors Network when he discovered he needed a transplant in 2012

by George Taniwaki

If you are a kidney patient seeking a living donor, you need to start what Harvey Mysel of the Living Kidney Donors Network (LKDN) calls a Kidney Kampaign. A search for a donor is all about numbers. You want as many people as possible to know about your need for a kidney transplant. Whenever you meet someone, tell them about your condition and your story. Then, at the end of any conversation, remember to give them calling cards printed with pertinent information (Fig 1).

Giving people your calling card serves two purposes. First, it will remind them later of who you are and how to contact the transplant center. Second, even if the people who you give the card to do not personally decide to get tested, they may remember your story and speak to 3, 4, or maybe even 20 other people about their meeting with you. One of these people may step up and get tested. This is how social networking can help you reach a vast audience and can help you find a living donor.

Give away your calling cards

You and your matchmaker (topic of a future blog post) should give away your calling cards freely. Hand them out to all your friends, family, and acquaintances, even to strangers. And don’t just give them one card. Offer several and ask the recipients to help spread your story and to give away the cards to others.

Calling cards are useful beyond face-to-face encounters. When you and your matchmaker send cards and letters (see Nov 2011 blog post), remember to include several calling cards in the envelope.

When you post a notice on a message board (topic of a future blog post), remember to include a pocket to hold a stack of calling cards.

When you and your matchmaker host an event (topic of a future blog post), remember to hand out calling cards to all the participants.

Design a calling card

A calling card is different from a business card. A business card just presents the facts, your name, company, and contact information. A Kidney Kampaign calling card provides contact information, but it must also provide a compelling story to get the person receiving it to take some action.

There are three very good sets of instructions on creating a calling cards to find a kidney donor. The first is by the Living Kidney Donors Network. The other two resources are provided by Living Kidney Donor Search and the Living Kidney Donor Search tools and tips. You should read the excellent advice given on all three websites.

A basic business card is 2” x 3-1/2”, printed one-side, horizontal (landscape) orientation, in black and white (Fig 2). But to make your card stand out, consider the following options:

  1. Vertical (portrait) orientation
  2. Four-color printing, especially good for photographs
  3. Printed two-sides, also called duplex printing, almost required to fit all the information needed
  4. Reverse type, that is, white lettering on a dark background (should be limited to large bold text, like the headline)
  5. Picture or graphic that runs off the edge of the card, also called a bleed
  6. Folded card, shaped like a tent, helpful if you have a longer story to tell and will also make you card stand out from other cards
Figure 2. Examples of the options described above

A kidney donor calling card is quite different from a business card. A business card is passive and just provides basic information for the recipient of the card to contact you. Your calling card is more like an advertisement. Like an advertisement, it should contain the following five items:

  1. Headline
  2. Photograph or illustration
  3. Message to potential donors
  4. Your contact information
  5. Logo (optional)

Each of these items is described in detail below. When designing your business card, start with pencil and paper and rough out the design before going to the computer to create the final design that will be printed.

Headline

The first two things a person will see on your calling card are the headline and the photograph. If you don’t have a photograph on your card, then you will definitely need a headline. The headline should be direct and no more than one sentence long. Some ideas are:

  1. Help me fight chronic kidney disease
  2. Help me find a kidney donor
  3. Become a living kidney donor
  4. You can give the gift of life
  5. Save a life, start with a simple test

Photograph or illustration

A large photograph or illustration is optional, but it is highly recommended that you include one. A picture will draw the attention of any person who looks at your calling card for the first time. To be effective at creating a positive connection, the photograph must be of high quality. Don’t skimp. Don’t try to take the picture yourself. Ask your matchmaker or a camera-savvy friend for help.

To make the best first impression, the picture should be of high technical quality. You often cannot fix a bad picture using a photo editing tool like Photoshop. Instead, start with a good shot. This means the picture should be:

  1. In focus (to avoid fuzzy image)
  2. Taken with a tripod or steady hand (to avoid shaky or blurred image)
  3. Well lit (to avoid grainy background or red-eye)
  4. Taken in daylight (to avoid blue fluorescent cast or orange tungsten cast)
  5. Taken with the background chosen with care and cropped to eliminate extraneous items in the background

Some recommended subjects that will make the photograph compelling are listed below.

  1. A close up of you smiling (a natural smile, not a forced one)
  2. You with other members of your family who cannot be donors (you will need to explain why they cannot be donors in the text of the calling card)
  3. You with pets
  4. You with props that show you participating in a favorite hobby or family activity

Message to potential donors

Your message to potential donors should include an appeal that explains why you want them to donate. It should also include instructions on how to get started as a donor. The message has to be short. You can only fit about 100 words on the front and back of a standard business card.

An oversized card can have more words, but I actually recommend having fewer words on the card and instead include a link to your website for people who want more details. Some ideas on what to include are:

  1. A short biography and explanation of why you need a kidney transplant
  2. How your family is affected by your condition
  3. Medical benefits to you of living donor transplant (compared to lifestyle when undergoing dialysis therapy)
  4. Who can donate, must be between XX to XX in age (ask transplant center for its range), no uncontrolled hypertension, diabetes, or kidney disease, overall good health
  5. How to learn more about the costs and risks of becoming a living donor (link to website for details)
  6. Call for volunteers to get a simple blood test to start the process
  7. Contact info for the living donor transplant coordinator, or the independent living donor advocate, depending on the process at your transplant hospital
  8. Encourage them to spread the word about your need to others

with you the latest Be sure to inform the transplant coordinator and independent living donor advocate of your plans to publicize your donor search.

An example of a biography is shown below:

Hello, my name is John Smith. I have kidney disease and I’m in need of a kidney transplant. The wait for a deceased donor kidney can be more than 5 years. To avoid this wait, I am actively pursuing a living kidney transplant. A kidney from a living donor lasts about twice as long as one from a deceased donor.

Kidney donors need to be healthy, no high blood pressure or diabetic. A blood test will determine whether additional tests will be done to see if you are a suitable donor. To schedule a test contact Janet Jones, my transplant coordinator at the New York Transplant Hospital: jjones@nyth.com or 212-456-7890.

To learn more about the living donation process you can contact me (jsmith@gmail.com or 212-123-4567), visit the LKDN website (www.lkdn.org), or contact my transplant coordinator.

Your contact information

The following information should be included on the front of your calling card:

  1. Name
  2. Phone number (optional, but recommended)
  3. Email address
  4. Web address of your donor search website or Facebook page

Logo

If you are promoting organ donation in general. you may want to include the Donate Life America logo. Similarly, if you are promoting the Living Kidney Donors Network program, you may want to include the LKDN logo.

Where to buy calling cards

There are hundreds of choices for getting your calling cards printed. Any small print shop should be capable of showing you paper, ink, and other options for a professional looking card. If you prefer buying on the web, LKDN has created a portfolio of calling cards on the FedEx Office website (formerly Kinko’s).  To use the portfolio and purchase cards from FedEx Office:

  1. In a web browser, navigate to http://www.fedex.com/us/office/designprint/index.html
  2. Click My Account (on left)
  3. Type E-mail = info@LKDN.org and Password = businesscard and click Sign In
  4. Click View My Portfolio (in Design Center box)

A box of 250 business cards in color, printed two-sided will cost about $50 plus tax and shipping. If you need help, call FedEx Office customer service 1-888-889-7121.

If you want to design your cards from scratch and save money too, Living Kidney Donor Search (LKDS) recommends using Zazzle. The site guides you through the design steps. A pack of 100 cards printed 2-sided will cost about $25. To save even more, LKDS says discount codes for Zazzle are often available on RetailMeNot.

Another popular source for business cards is CafePress. They have a large number of designs available. However, they don’t support 2-sided printing or custom color printing.

More examples

Three more examples of kidney donor search calling cards are shown below. The first one is double-sided, the other 2 are tent-fold

Figures 3a, 3b, 4, and 5. 2-sided Kidney Kampaign calling card for Amando Melgar, III from LKDN portfolio on FedEx Office website; Tent-fold card based on a t-shirt design sold by Zazzle; Tent-fold design based on a poster sold by CafePress

Thanks to Harvey Mysel of Living Kidney Donors Network for providing me with example cards that I use in my patient counseling. Additional thanks to Suzanne Kloss of Living Kidney Donor Search for providing additional tips on designing and using calling cards.

For more ideas on finding a donor, see my Kidney patient guide.