-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRecipEntropyConsolidateAll.m
More file actions
90 lines (82 loc) · 2.61 KB
/
RecipEntropyConsolidateAll.m
File metadata and controls
90 lines (82 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
function [] = RecipEntropyConsolidateAll(Ningred_used,consolidate_orders,Nsubsamps)
% Consolidates maxent data for Ningred_used most common ingredients
%
% Written by: DJ Strouse
% Last updated: Aug 19, 2013 by DJ Strouse
%
% INPUTS
% Ningred_used [=] positive integer = number of ingredients to use
% consolidate_orders [=] boolean = indicates whether or not to loop over
% runs of RecipEntropyConsolidate.m first
% Nsubsamps [=] vector of non-negative integers = Nsubsamp for each order
%
% OUTPUTS
% none
% init
if ~exist('consolidate_orders','var')
consolidate_orders = true; % defaults to true
end
if ~exist('Nsubsamps','var')
Nsubsamps = [25 25 25];
end
if length(Nsubsamps)==1
Nsubsamps = Nsubsamps*ones(3,1);
end
if length(Nsubsamps)~=3
error('Nsubsamps should have 3 elements, one for each order!')
end
if consolidate_orders
orders = 0:2;
RecipEntropyConsolidate(Ningred_used,orders,Nsubsamps);
end
% load recipe data set to extract its data
load('data/recipes.mat');
Ningred = size(recipes_binary,2);
Nrec = size(recipes_binary,1);
subsamp_size = round(.8*Nrec);
[recipes_binary_subsamp,ingreds_subsamp] =...
ExtractIngred(Ningred_used,ingred_freq,recipes_binary,ingreds);
% load freqs and maxents
load(sprintf('data/standard/%iingred/order%i/large.mat',Ningred_used,0));
load(sprintf('data/standard/%iingred/order%i/small.mat',Ningred_used,0));
load(sprintf('data/standard/%iingred/order%i/large.mat',Ningred_used,1));
load(sprintf('data/standard/%iingred/order%i/small.mat',Ningred_used,1));
maxent1_small = maxent_small; clear maxent_small;
maxent1_large = maxent_large; clear maxent_large;
load(sprintf('data/standard/%iingred/order%i/large.mat',Ningred_used,2));
load(sprintf('data/standard/%iingred/order%i/small.mat',Ningred_used,2));
maxent2_small = maxent_small; clear maxent_small;
maxent2_large = maxent_large; clear maxent_large;
% check for consistency in Ningred, Nrec, Nsubsamp, and subsamp_size
% compare maxents
maxent1v2 = CompareMaxEnt12(...
maxent1_large,maxent2_large,freq_large,...
'first-order maxent','second-order maxent','raw freqs');
% save
save(...
sprintf('data/standard/%iingred/large.mat',Ningred_used),...
'maxent1_large',...
'maxent2_large',...
'freq_large',...
'maxent1v2',...
'Ningred',...
'Nrec',...
'Nsubsamps',...
'subsamp_size',...
'Ningred_used',...
'ingreds_subsamp',...
'recipes_binary_subsamp',...
'-v7.3');
save(...
sprintf('data/standard/%iingred/small.mat',Ningred_used),...
'maxent1_small',...
'maxent2_small',...
'freq_small',...
'maxent1v2',...
'Ningred',...
'Nrec',...
'Nsubsamps',...
'subsamp_size',...
'Ningred_used',...
'-v7.3');
end