Algorithm 1.
Generating Intakes
| Input: | |
| X = [x1, x2 . . ., xm], an array of vectors of features where xi = [f1, f2 . . ., famtFeat], a vector of features | |
| F = [f1, f2 . . ., fm], an array of food categories associated with a corresponding instance of X | |
| N, the minimum amount of intakes for each category | |
| R, the number of iterations before regenerating a new Random Forest | |
| Output: | |
| Xnew: X concatenated with newly generated intake features | |
| Fnew: F concatenated with newly generated intake categories | |
| The length of each distinct type of Fnew is greater than or equal to N | |
| 1: | count = 0 |
| 2: | while ∃f(f ∈ F, ||f|| < N) do |
| 3: | d ∈ F < N |
| 4: | xd = x ∈ X | F = d |
| 5: | for i = 1 to amtFeat do |
| 6: | |
| 7: | if count mod R = 0 then |
| 8: | Ftrain = [f : f ∈ F, ||f|| < N] |
| 9: | Xtrain = x ∈ X | F ∈ Ftrain |
| 10: | rf = Random Forest (Xtrain, Ftrain) |
| 11: | else |
| 12: | Use previous rf |
| 13: | if rf.predict(Inew) = d then |
| 14: | X.append(Inew) |
| 15: | F.append(d) |
| 16: | count+ = 1 |
| 17: | return X,F |