fBayes 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. data/.DS_Store +0 -0
  2. data/README.rdoc +6 -3
  3. data/VERSION +1 -1
  4. data/fBayes.gemspec +17 -2
  5. data/lib/.DS_Store +0 -0
  6. data/lib/data/.DS_Store +0 -0
  7. data/lib/data/internalTurnk/.DS_Store +0 -0
  8. data/lib/data/internalTurnk/classifier.rb +55 -0
  9. data/lib/data/internalTurnk/csv_to_data.rb +10 -0
  10. data/lib/data/internalTurnk/data/Beverages +366 -0
  11. data/lib/data/internalTurnk/data/Cereal +46 -0
  12. data/lib/data/internalTurnk/data/Dairy +69 -0
  13. data/lib/data/internalTurnk/data/Fast-foods +29 -0
  14. data/lib/data/internalTurnk/data/Fat, +53 -0
  15. data/lib/data/internalTurnk/data/Fruits +47 -0
  16. data/lib/data/internalTurnk/data/Grains +85 -0
  17. data/lib/data/internalTurnk/data/Meat +132 -0
  18. data/lib/data/internalTurnk/data/Unknown +127 -0
  19. data/lib/data/internalTurnk/data/Vegetables +310 -0
  20. data/lib/data/internalTurnk/results.csv +1703 -0
  21. data/lib/data/sr24/.DS_Store +0 -0
  22. data/lib/data/sr24/classifier.rb +35 -15
  23. data/lib/data/sr24/csv_to_muchidata.rb +8 -0
  24. data/lib/data/sr24/data/baby-foods +192 -192
  25. data/lib/data/sr24/data/baked-products +350 -350
  26. data/lib/data/sr24/data/beef-products +137 -131
  27. data/lib/data/sr24/data/beverages +182 -177
  28. data/lib/data/sr24/data/breakfast-cereals +304 -304
  29. data/lib/data/sr24/data/cereal-grains-and-pasta +101 -101
  30. data/lib/data/sr24/data/dairy-and-egg-products +178 -178
  31. data/lib/data/sr24/data/ethnic-foods +97 -97
  32. data/lib/data/sr24/data/fast-foods +208 -190
  33. data/lib/data/sr24/data/fats-and-oils +146 -146
  34. data/lib/data/sr24/data/finfish-and-shellfish-products +123 -123
  35. data/lib/data/sr24/data/fruits-and-fruit-juices +198 -198
  36. data/lib/data/sr24/data/lamb +73 -73
  37. data/lib/data/sr24/data/legumes-and-legume-products +231 -231
  38. data/lib/data/sr24/data/meals +48 -48
  39. data/lib/data/sr24/data/nut-and-seed-products +104 -104
  40. data/lib/data/sr24/data/pork-products +37 -37
  41. data/lib/data/sr24/data/poultry-products +134 -134
  42. data/lib/data/sr24/data/restaurant-foods +45 -45
  43. data/lib/data/sr24/data/sausages-and-luncheon-meats +140 -140
  44. data/lib/data/sr24/data/snacks +108 -108
  45. data/lib/data/sr24/data/soups +420 -420
  46. data/lib/data/sr24/data/spices-and-herbs +29 -29
  47. data/lib/data/sr24/data/sweets +225 -225
  48. data/lib/data/sr24/data/vegetables-and-vegetable-products +331 -321
  49. data/lib/fBayes.rb +6 -2
  50. data/lib/global_classifier.rb +2 -0
  51. data/spec/accuracy_spec.rb +141 -0
  52. metadata +18 -3
data/.DS_Store CHANGED
Binary file
data/README.rdoc CHANGED
@@ -5,12 +5,15 @@ A Naive Bayes Approach to telling what category certain ingredients belong.
5
5
 
6
6
  == Usage:
7
7
 
8
- require 'global_classifier'
8
+ require 'fBayes'
9
9
 
10
+ @sr24_classifier.classify("cucumber")
11
+ => "Vegetables-and-vegetable-products"
12
+
13
+ @sr24_classifier.classify("steak")
14
+ => "Beef-products"
10
15
 
11
- @sr24_classifier.classify 'wiskey'
12
16
 
13
- Enjoy!
14
17
 
15
18
 
16
19
  == Contributing to fBayes
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
data/fBayes.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "fBayes"
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Ivan Acosta-Rubio"]
12
- s.date = "2012-09-10"
12
+ s.date = "2012-11-14"
13
13
  s.description = "Naitve Bayes for Food Category classification"
14
14
  s.email = "ivan@bakedweb.net"
15
15
  s.extra_rdoc_files = [
@@ -45,6 +45,20 @@ Gem::Specification.new do |s|
45
45
  "lib/data/cdc/data/protein_foods",
46
46
  "lib/data/cdc/data/water",
47
47
  "lib/data/cdc/ruby_parser.rb",
48
+ "lib/data/internalTurnk/.DS_Store",
49
+ "lib/data/internalTurnk/classifier.rb",
50
+ "lib/data/internalTurnk/csv_to_data.rb",
51
+ "lib/data/internalTurnk/data/Beverages",
52
+ "lib/data/internalTurnk/data/Cereal",
53
+ "lib/data/internalTurnk/data/Dairy",
54
+ "lib/data/internalTurnk/data/Fast-foods",
55
+ "lib/data/internalTurnk/data/Fat,",
56
+ "lib/data/internalTurnk/data/Fruits",
57
+ "lib/data/internalTurnk/data/Grains",
58
+ "lib/data/internalTurnk/data/Meat",
59
+ "lib/data/internalTurnk/data/Unknown",
60
+ "lib/data/internalTurnk/data/Vegetables",
61
+ "lib/data/internalTurnk/results.csv",
48
62
  "lib/data/sr24/.DS_Store",
49
63
  "lib/data/sr24/FD_GROUP.csv",
50
64
  "lib/data/sr24/FD_GROUP.txt",
@@ -84,6 +98,7 @@ Gem::Specification.new do |s|
84
98
  "lib/data/sr24/rawData/sr24_doc.pdf",
85
99
  "lib/fBayes.rb",
86
100
  "lib/global_classifier.rb",
101
+ "spec/accuracy_spec.rb",
87
102
  "spec/clasificador_spec.rb",
88
103
  "spec/fBayes_spec.rb",
89
104
  "spec/spec_helper.rb"
data/lib/.DS_Store CHANGED
Binary file
data/lib/data/.DS_Store CHANGED
Binary file
Binary file
@@ -0,0 +1,55 @@
1
+ require 'classifier'
2
+
3
+ puts "*" * 100
4
+ puts "InternalTurnk CLASSIFIER:"
5
+ puts "*" * 100
6
+
7
+
8
+
9
+ class InternalTurnk
10
+ attr_accessor :classifier
11
+
12
+ def initialize
13
+ @classifier = Classifier::Bayes.new
14
+ @home_dir = FBayesDir.internal_turnk_data
15
+ add_categories
16
+ train
17
+ puts @home_dir.inspect
18
+ end
19
+
20
+
21
+ def add_categories
22
+ categories_path = Dir[ @home_dir + "*"]
23
+ @categories = categories_path.map{|path| path.gsub(@home_dir, "")}
24
+
25
+ @categories.each do |c|
26
+ @classifier.add_category c
27
+ end
28
+
29
+ puts @categories.inspect
30
+ end
31
+
32
+ def train
33
+ total_size = 0
34
+
35
+ @categories.each do |category|
36
+ method = "train_" + category.downcase
37
+ data = File.read( @home_dir + category.to_s)
38
+ puts category +": " + data.size.to_s
39
+ @classifier.send(method, data)
40
+ total_size += data.size.to_i
41
+ end
42
+
43
+ puts "TOTAL SIZE: #{total_size}"
44
+ end
45
+
46
+ def c(word)
47
+ @classifier.classify(word)
48
+ end
49
+
50
+ def d(word)
51
+ @classifier.classifications(word)
52
+ end
53
+ end
54
+
55
+ @it_classifier = InternalTurnk.new
@@ -0,0 +1,10 @@
1
+ require 'csv'
2
+
3
+ CSV.read("./results.csv").each do |row|
4
+ puts row[6]
5
+
6
+ if row[6] == "Yes"
7
+ `echo #{row[1]} >> ./data/#{row[3]}`
8
+ end
9
+
10
+ end
@@ -0,0 +1,366 @@
1
+ coffee
2
+ green tea
3
+ water
4
+ coffee
5
+ coffee
6
+ coffee
7
+ milk
8
+ coffee
9
+ beer
10
+ water
11
+ water
12
+ red wine
13
+ beer
14
+ coffee
15
+ green tea
16
+ 1 can of Red Bull 12 oz.
17
+ red wine
18
+ wine
19
+ coffee
20
+ water
21
+ orange juice
22
+ coffee
23
+ wine
24
+ protein shake
25
+ coffee
26
+ protein water
27
+ juice with carrot and orange
28
+ water
29
+ sprite
30
+ michelada
31
+ coffee
32
+ coffee
33
+ coffee
34
+ coffee
35
+ coffee
36
+ beer
37
+ chocolate milk
38
+ coffee
39
+ orange juice
40
+ coffee
41
+ water
42
+ water
43
+ coffee
44
+ coffee
45
+ orange juice
46
+ Starbucks passion tea lemonade shaken
47
+ coffee
48
+ water
49
+ coffee
50
+ coffee
51
+ coffee
52
+ water
53
+ coffee
54
+ water
55
+ protein shake
56
+ cappuccino
57
+ coffee
58
+ coffee
59
+ coffee
60
+ vodka
61
+ coffee
62
+ coffee
63
+ water
64
+ almond milk
65
+ coffee
66
+ protein shake
67
+ pink lemonade
68
+ water
69
+ ensure
70
+ coconut water
71
+ Coffee
72
+ water
73
+ watermelon juice
74
+ coffee
75
+ coffee
76
+ water
77
+ water
78
+ coffee
79
+ Arizona iced tea
80
+ carrot juice
81
+ coffee
82
+ coffee
83
+ soda
84
+ coffee
85
+ red wine
86
+ coffee
87
+ michelada sol
88
+ green tea
89
+ water
90
+ coffee
91
+ water
92
+ coffee
93
+ coffee
94
+ coffee
95
+ coffee
96
+ vodka
97
+ coffee
98
+ coffee
99
+ orange juice
100
+ beer
101
+ lemonade
102
+ coffee
103
+ coffee
104
+ water
105
+ cerveza Minerva
106
+ coffee
107
+ Arizona tea
108
+ champagne
109
+ juice
110
+ soy milk
111
+ coffee
112
+ soy milk
113
+ water
114
+ sprite
115
+ water
116
+ beer
117
+ water
118
+ protein shake
119
+ carrot juice
120
+ coffee
121
+ cup of soy milk
122
+ beer
123
+ vitamin water xxx flavor
124
+ coffee
125
+ coffee
126
+ coffee
127
+ carrot and orange juice
128
+ beer
129
+ water
130
+ coffee
131
+ coffee
132
+ coffee
133
+ water
134
+ seven up
135
+ coke
136
+ coffee
137
+ coffee
138
+ beer
139
+ coffee
140
+ coffee
141
+ coke
142
+ sprite
143
+ orange juice
144
+ coke cola
145
+ beer
146
+ water
147
+ Soya milk
148
+ protein fruit smoothie
149
+ coffee
150
+ red wine
151
+ coke
152
+ water
153
+ coke
154
+ coffee
155
+ water
156
+ beer
157
+ beer
158
+ coffee
159
+ coffee
160
+ coffee coffe
161
+ coffee
162
+ beer
163
+ coffee
164
+ beer
165
+ Heineken
166
+ water
167
+ coffee
168
+ green tea
169
+ sprite
170
+ water
171
+ coffee
172
+ cafe with one tea spoon of sugar
173
+ water
174
+ coffee
175
+ water
176
+ beer
177
+ agua de jamaica
178
+ beer
179
+ coffee
180
+ coffee
181
+ water
182
+ water
183
+ coffee
184
+ coffee
185
+ beer
186
+ water
187
+ coffee
188
+ coffee
189
+ beer
190
+ micheladas
191
+ coffee
192
+ Arizona tea
193
+ beer
194
+ water
195
+ water
196
+ coffee
197
+ coffee
198
+ coffee
199
+ water
200
+ water
201
+ water
202
+ soya vanilla milk
203
+ sprite
204
+ coffee
205
+ coffee
206
+ coffee
207
+ coffee
208
+ sprite
209
+ protein shake
210
+ coffee
211
+ coffee
212
+ coffee
213
+ beer
214
+ Cafe 12 oz
215
+ coffee
216
+ water
217
+ cafe 12 oz
218
+ water
219
+ coffee
220
+ coffee
221
+ sprite
222
+ water
223
+ coffee
224
+ water
225
+ coffee
226
+ coffee
227
+ coffee
228
+ coke
229
+ coffee
230
+ coffee
231
+ coffee
232
+ coffee
233
+ coffee
234
+ coffee
235
+ coke
236
+ coffee
237
+ coffee
238
+ coffee
239
+ coffee
240
+ wine
241
+ coffee
242
+ coffee
243
+ coffee
244
+ coffee
245
+ coffee
246
+ coffee
247
+ Tea
248
+ coke
249
+ coffee
250
+ water
251
+ coffee
252
+ water
253
+ beer
254
+ coffee
255
+ Heineken
256
+ coffee
257
+ coffee
258
+ coffee
259
+ beer
260
+ coffee
261
+ coffee
262
+ coffee
263
+ coffee
264
+ water
265
+ protein shake
266
+ tea
267
+ coffee
268
+ coffee
269
+ coffee
270
+ coke
271
+ coffee
272
+ coffee
273
+ coffee
274
+ coffee
275
+ sprite
276
+ Arizona iced tea
277
+ coffee
278
+ coffee
279
+ Heineken
280
+ coffee
281
+ coffee
282
+ coffee
283
+ coffee
284
+ Jamaica water
285
+ coffee
286
+ water
287
+ coffee
288
+ water
289
+ coffee
290
+ beer
291
+ coke
292
+ Cafe 12 oz.
293
+ coffee
294
+ coffee
295
+ water
296
+ cafe
297
+ coffee
298
+ red wine
299
+ green tea
300
+ orange water
301
+ coffee
302
+ beer
303
+ lemonade
304
+ half coke
305
+ Heineken
306
+ coffee
307
+ coffee
308
+ coffee
309
+ coffee
310
+ Arizona tea
311
+ coffee
312
+ beer
313
+ Heineken
314
+ orange juice
315
+ michelada
316
+ water
317
+ coffee
318
+ coffee
319
+ coffee
320
+ tequila
321
+ michelada
322
+ water
323
+ green tea
324
+ coffee
325
+ tea
326
+ Jamaica water
327
+ coffee
328
+ coffee
329
+ Heineken
330
+ coffee
331
+ coffee
332
+ coffee
333
+ coffee
334
+ agua ardiente
335
+ coffee
336
+ coffee
337
+ coffee
338
+ coffee
339
+ cinamon dolce latte
340
+ coffee
341
+ michelada
342
+ 7 cans of Red Bull 8.4 oz
343
+ lemonade
344
+ coffee
345
+ Heineken
346
+ coffee
347
+ coffee
348
+ agua de Jamaica
349
+ coffee
350
+ coffee
351
+ coffee
352
+ carrot orange juice
353
+ white coffee
354
+ Heineken
355
+ red wine
356
+ coffee
357
+ tea
358
+ coffee con leche
359
+ coffee
360
+ agua 5 oz
361
+ water
362
+ lemonade
363
+ almond milk
364
+ coffee
365
+ michelada
366
+ micheladas
@@ -0,0 +1,46 @@
1
+ lasagna Grains and Pasta
2
+ oatmeal Grains and Pasta
3
+ puffins chocolate and peanut butter cereal Grains and Pasta
4
+ couscous Grains and Pasta
5
+ pasta with red sauce Grains and Pasta
6
+ pasta Grains and Pasta
7
+ Irish oatmeal Grains and Pasta
8
+ spaghetti verde Grains and Pasta
9
+ cheerios Grains and Pasta
10
+ Cereal Grains and Pasta
11
+ noodles Grains and Pasta
12
+ pasta Grains and Pasta
13
+ cereal Grains and Pasta
14
+ pasta with olive oil and vegetables Grains and Pasta
15
+ cereal Grains and Pasta
16
+ pasta soup Grains and Pasta
17
+ spaguetti with tomato sauce and mozzarella Grains and Pasta
18
+ lasagna Grains and Pasta
19
+ mini fruits Weetabix Grains and Pasta
20
+ cheese ravioli Grains and Pasta
21
+ spaghetti with tomato sauce and mozzarella Grains and Pasta
22
+ spaghetti verde with spinach and cream Grains and Pasta
23
+ tortolini Grains and Pasta
24
+ spinaci spaghetti mountain with parmesano cheese Grains and Pasta
25
+ pasta Grains and Pasta
26
+ ramen noodles chicken mixed vegetable Grains and Pasta
27
+ ramen Grains and Pasta
28
+ spaguetti Grains and Pasta
29
+ oatmeal cereal Grains and Pasta
30
+ spaghetti with tomato sauce and mozzarella Grains and Pasta
31
+ oatmeal Grains and Pasta
32
+ spaghetti Grains and Pasta
33
+ spaguetti Grains and Pasta
34
+ pasta Grains and Pasta
35
+ raviolis 4 quesos Grains and Pasta
36
+ corn flakes with milk Grains and Pasta
37
+ whole wheat spaghetti Grains and Pasta
38
+ muesli Grains and Pasta
39
+ cereal blueberry toast marmalade Grains and Pasta
40
+ pasta with mushroom sauce Grains and Pasta
41
+ raviolis 4 quesos Grains and Pasta
42
+ dried vercelli Grains and Pasta
43
+ Cous Cous Grains and Pasta
44
+ spaghetti with tomato soup and parmesano cheese Grains and Pasta
45
+ tomatoe and pasta soup Grains and Pasta
46
+ spaghetti with mozzarella cheese Grains and Pasta
@@ -0,0 +1,69 @@
1
+ Milk
2
+ melted cheese
3
+ cheese
4
+ blue cheese
5
+ panela cheese
6
+ melted cheese
7
+ panela cheese
8
+ yogurt ice cream
9
+ yoghurt
10
+ cheese
11
+ milk
12
+ cheese
13
+ yoghurt
14
+ yogurt
15
+ queso
16
+ yoghurt
17
+ mozzarella
18
+ mozzarella
19
+ Panela cheese
20
+ cream cheese
21
+ cheese
22
+ cheese
23
+ cheese
24
+ milk
25
+ cream cheese
26
+ cheese and red tomato sauce
27
+ cherry yoghurt
28
+ cheese
29
+ cachapa and cheese
30
+ cream cheese
31
+ yoghurt
32
+ Philadelphia cheese
33
+ sour cream
34
+ milk
35
+ arepa with cheese
36
+ panela cheese
37
+ melted cheese
38
+ manchego
39
+ manchego cheese
40
+ cheese and bread
41
+ cheese
42
+ milk
43
+ mozzarella
44
+ butter
45
+ cream cheese
46
+ cream cheese
47
+ yoghurt
48
+ cream cheese and Munster cheese
49
+ yogurt
50
+ half cachapa with cheese
51
+ yogurt
52
+ cheese
53
+ Oaxaca cheese
54
+ white cheese
55
+ Oaxaca cheese
56
+ cheese
57
+ cheese
58
+ yogurt
59
+ milk
60
+ mozzarella cheese
61
+ Oaxaca cheese
62
+ yogurt and mint
63
+ goat cheese
64
+ feta cheese
65
+ ice cream
66
+ Oaxaca cheese
67
+ labne and tacos
68
+ cheese
69
+ manchego cheese
@@ -0,0 +1,29 @@
1
+ sabritas fries natural
2
+ mc Donald burger fris soda sauce
3
+ pizza extra cheese sausage pepperoni
4
+ pizza: cheese
5
+ French fries
6
+ croissant sausage and egg mcmuffin
7
+ pizza-sandwich with tomatoe
8
+ French fries
9
+ nachos with cheese and pico de gallo
10
+ French fries
11
+ burger king veggie burger meal
12
+ guacamole and chips
13
+ avocado and tacos
14
+ Sabritas natural potato chips
15
+ margarita pizza
16
+ guacamole and tortilla chips
17
+ margarita pizza with mushrooms and corn
18
+ onion rings
19
+ margarita pizza with onions
20
+ French fries
21
+ fries
22
+ pizza
23
+ cheese and mushroom pizza
24
+ cheese pizza
25
+ French fries
26
+ tacos with lentil burgers
27
+ tomato and guacamole with chips
28
+ French fries and guacamole with chips
29
+ French fries
@@ -0,0 +1,53 @@
1
+ Sugar Oil and Sweets
2
+ olive oil Oil and Sweets
3
+ magnum classic chocolate Oil and Sweets
4
+ honey Oil and Sweets
5
+ chocolate Oil and Sweets
6
+ sugar Oil and Sweets
7
+ substitute sugar Oil and Sweets
8
+ crumb cake Oil and Sweets
9
+ cookies Oil and Sweets
10
+ Coffee-Mate Oil and Sweets
11
+ sugar Oil and Sweets
12
+ light mayonnaise Oil and Sweets
13
+ sugar Oil and Sweets
14
+ olive oil Oil and Sweets
15
+ light ranch dressing Oil and Sweets
16
+ piece of cake Oil and Sweets
17
+ sugar Oil and Sweets
18
+ mini chocolate chips Oil and Sweets
19
+ whole grain cookies Oil and Sweets
20
+ Greek dressing Oil and Sweets
21
+ tiramisu Oil and Sweets
22
+ cupcake Oil and Sweets
23
+ chocolate Oil and Sweets
24
+ ice cream Oil and Sweets
25
+ light ranch dressing Oil and Sweets
26
+ brown sugar Oil and Sweets
27
+ cheese cake Oil and Sweets
28
+ cupcakes Oil and Sweets
29
+ chocolate small piece of cake Oil and Sweets
30
+ crumb cake Oil and Sweets
31
+ olives Oil and Sweets
32
+ balsamic vinegar etre Oil and Sweets
33
+ lemon cookie Oil and Sweets
34
+ brownie Oil and Sweets
35
+ tiramisu Oil and Sweets
36
+ oil Oil and Sweets
37
+ brown sugar Oil and Sweets
38
+ popcorn butter salt Oil and Sweets
39
+ half cheese cake Oil and Sweets
40
+ balsamic vinegar etre Oil and Sweets
41
+ brownie Oil and Sweets
42
+ cheese cake Oil and Sweets
43
+ mayonnaise Oil and Sweets
44
+ nutella Oil and Sweets
45
+ panacotta Oil and Sweets
46
+ panacota Oil and Sweets
47
+ Oreo cookies Oil and Sweets
48
+ brownie Oil and Sweets
49
+ cinnamon bun Oil and Sweets
50
+ creme brulee Oil and Sweets
51
+ cake Oil and Sweets
52
+ panacota Oil and Sweets
53
+ sesame cookie Oil and Sweets