CedM commited on
Commit
b008a5a
·
verified ·
1 Parent(s): 8972476

Déploiement automatique depuis GitLab CI

Browse files
2_Data_transformed/crop_yield_2_train_set_simplified.csv ADDED
@@ -0,0 +1,589 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Area;Item;Year;hg/ha_yield;average_rain_fall_mm_per_year;pesticides_tonnes;avg_temp
2
+ Albania;Maize;1990;36613.0;1485.0;4.804021044733257;16.37
3
+ Albania;Potatoes;1990;66667.0;1485.0;4.804021044733257;16.37
4
+ Albania;Rice, paddy;1990;23333.0;1485.0;4.804021044733257;16.37
5
+ Albania;Sorghum;1990;12500.0;1485.0;4.804021044733257;16.37
6
+ Albania;Soybeans;1990;7000.0;1485.0;4.804021044733257;16.37
7
+ Albania;Wheat;1990;30197.0;1485.0;4.804021044733257;16.37
8
+ Algeria;Maize;1990;16500.0;89.0;7.512027529032907;17.48
9
+ Algeria;Potatoes;1990;78936.0;89.0;7.512027529032907;17.48
10
+ Algeria;Rice, paddy;1990;28000.0;89.0;7.512027529032907;17.48
11
+ Algeria;Sorghum;1990;16571.0;89.0;7.512027529032907;17.48
12
+ Algeria;Wheat;1990;6315.0;89.0;7.512027529032907;17.48
13
+ Angola;Cassava;1990;41177.0;1010.0;4.174387269895637;24.12
14
+ Angola;Maize;1990;2736.0;1010.0;4.174387269895637;24.12
15
+ Angola;Potatoes;1990;40000.0;1010.0;4.174387269895637;24.12
16
+ Angola;Rice, paddy;1990;9512.0;1010.0;4.174387269895637;24.12
17
+ Angola;Sweet potatoes;1990;89342.0;1010.0;4.174387269895637;24.12
18
+ Angola;Wheat;1990;7995.0;1010.0;4.174387269895637;24.12
19
+ Angola;Sorghum;2000;3333.0;1010.0;3.713572066704308;24.41
20
+ Angola;Soybeans;2000;2333.0;1010.0;3.713572066704308;24.41
21
+ Argentina;Cassava;1990;100000.0;591.0;10.171872120095925;17.57
22
+ Argentina;Maize;1990;34608.0;591.0;10.171872120095925;17.57
23
+ Argentina;Potatoes;1990;202747.0;591.0;10.171872120095925;17.57
24
+ Argentina;Rice, paddy;1990;36709.0;591.0;10.171872120095925;17.57
25
+ Argentina;Sorghum;1990;28116.0;591.0;10.171872120095925;17.57
26
+ Argentina;Soybeans;1990;21566.0;591.0;10.171872120095925;17.57
27
+ Argentina;Sweet potatoes;1990;131864.0;591.0;10.171872120095925;17.57
28
+ Argentina;Wheat;1990;18947.0;591.0;10.171872120095925;17.57
29
+ Armenia;Maize;1992;32344.0;562.0;2.1972245773362196;7.44
30
+ Armenia;Potatoes;1992;111301.0;562.0;2.1972245773362196;7.44
31
+ Armenia;Wheat;1992;21600.0;562.0;2.1972245773362196;7.44
32
+ Australia;Maize;1990;41821.0;534.0;9.790710714933168;16.44
33
+ Australia;Potatoes;1990;289832.0;534.0;9.790710714933168;16.44
34
+ Australia;Rice, paddy;1990;88000.0;534.0;9.790710714933168;16.44
35
+ Australia;Sorghum;1990;24883.0;534.0;9.790710714933168;16.44
36
+ Australia;Soybeans;1990;15718.0;534.0;9.790710714933168;16.44
37
+ Australia;Sweet potatoes;1990;137140.0;534.0;9.790710714933168;16.44
38
+ Australia;Wheat;1990;16344.0;534.0;9.790710714933168;16.44
39
+ Austria;Maize;1990;81800.0;1110.0;8.353968130313271;9.23
40
+ Austria;Potatoes;1990;249854.0;1110.0;8.353968130313271;9.23
41
+ Austria;Soybeans;1990;19046.0;1110.0;8.353968130313271;9.23
42
+ Austria;Wheat;1990;50479.0;1110.0;8.353968130313271;9.23
43
+ Azerbaijan;Maize;1992;18740.0;447.0;5.0084996819658345;10.93
44
+ Azerbaijan;Potatoes;1992;82701.0;447.0;5.0084996819658345;10.93
45
+ Azerbaijan;Rice, paddy;1992;7292.0;447.0;5.0084996819658345;10.93
46
+ Azerbaijan;Sorghum;1992;578.0;447.0;5.0084996819658345;10.93
47
+ Azerbaijan;Soybeans;1992;1141.0;447.0;5.0084996819658345;10.93
48
+ Azerbaijan;Wheat;1992;21705.0;447.0;5.0084996819658345;10.93
49
+ Bahamas;Cassava;1992;95859.0;1292.0;6.185364646452523;25.1
50
+ Bahamas;Maize;1992;16667.0;1292.0;6.185364646452523;25.1
51
+ Bahamas;Sweet potatoes;1992;31586.0;1292.0;6.185364646452523;25.1
52
+ Bahrain;Potatoes;1990;186667.0;83.0;2.711377991194885;26.26
53
+ Bahrain;Sweet potatoes;1990;116667.0;83.0;2.711377991194885;26.26
54
+ Bangladesh;Maize;1990;10015.0;2666.0;7.144407180321139;25.98
55
+ Bangladesh;Potatoes;1990;91410.0;2666.0;7.144407180321139;25.98
56
+ Bangladesh;Rice, paddy;1990;25661.0;2666.0;7.144407180321139;25.98
57
+ Bangladesh;Sorghum;1990;8103.0;2666.0;7.144407180321139;25.98
58
+ Bangladesh;Sweet potatoes;1990;98316.0;2666.0;7.144407180321139;25.98
59
+ Bangladesh;Wheat;1990;15034.0;2666.0;7.144407180321139;25.98
60
+ Bangladesh;Soybeans;2005;14148.0;2666.0;8.936694003238852;26.19
61
+ Belarus;Maize;1992;30000.0;618.0;9.024891129067417;6.74
62
+ Belarus;Potatoes;1992;115326.0;618.0;9.024891129067417;6.74
63
+ Belarus;Wheat;1992;27983.0;618.0;9.024891129067417;6.74
64
+ Belgium;Maize;2000;111006.0;847.0;9.165498851641477;11.37
65
+ Belgium;Potatoes;2000;444058.0;847.0;9.165498851641477;11.37
66
+ Belgium;Wheat;2000;79198.0;847.0;9.165498851641477;11.37
67
+ Botswana;Maize;1990;2899.0;416.0;2.8903717578961645;19.54
68
+ Botswana;Sorghum;1990;2500.0;416.0;2.8903717578961645;19.54
69
+ Botswana;Wheat;1990;26178.0;416.0;2.8903717578961645;19.54
70
+ Brazil;Cassava;1990;125529.0;1761.0;10.813679725948413;22.44
71
+ Brazil;Maize;1990;18735.0;1761.0;10.813679725948413;22.44
72
+ Brazil;Potatoes;1990;141084.0;1761.0;10.813679725948413;22.44
73
+ Brazil;Rice, paddy;1990;18803.0;1761.0;10.813679725948413;22.44
74
+ Brazil;Sorghum;1990;17150.0;1761.0;10.813679725948413;22.44
75
+ Brazil;Soybeans;1990;17322.0;1761.0;10.813679725948413;22.44
76
+ Brazil;Sweet potatoes;1990;101661.0;1761.0;10.813679725948413;22.44
77
+ Brazil;Wheat;1990;11540.0;1761.0;10.813679725948413;22.44
78
+ Brazil;Yams;1990;91489.0;1761.0;10.813679725948413;22.44
79
+ Bulgaria;Maize;1990;28771.0;608.0;8.27052509505507;9.51
80
+ Bulgaria;Potatoes;1990;104986.0;608.0;8.27052509505507;9.51
81
+ Bulgaria;Rice, paddy;1990;23785.0;608.0;8.27052509505507;9.51
82
+ Bulgaria;Sorghum;1990;17778.0;608.0;8.27052509505507;9.51
83
+ Bulgaria;Soybeans;1990;8830.0;608.0;8.27052509505507;9.51
84
+ Bulgaria;Wheat;1990;45514.0;608.0;8.27052509505507;9.51
85
+ Burkina Faso;Cassava;1990;29600.0;748.0;3.40452517175483;28.77
86
+ Burkina Faso;Maize;1990;14612.0;748.0;3.40452517175483;28.77
87
+ Burkina Faso;Potatoes;1990;61985.0;748.0;3.40452517175483;28.77
88
+ Burkina Faso;Rice, paddy;1990;20783.0;748.0;3.40452517175483;28.77
89
+ Burkina Faso;Sorghum;1990;5827.0;748.0;3.40452517175483;28.77
90
+ Burkina Faso;Soybeans;1990;4667.0;748.0;3.40452517175483;28.77
91
+ Burkina Faso;Sweet potatoes;1990;67598.0;748.0;3.40452517175483;28.77
92
+ Burkina Faso;Yams;1990;66250.0;748.0;3.40452517175483;28.77
93
+ Burundi;Cassava;1990;88969.0;1274.0;4.533459338434091;21.15
94
+ Burundi;Maize;1990;13540.0;1274.0;4.533459338434091;21.15
95
+ Burundi;Potatoes;1990;34836.0;1274.0;4.533459338434091;21.15
96
+ Burundi;Rice, paddy;1990;33333.0;1274.0;4.533459338434091;21.15
97
+ Burundi;Sorghum;1990;10983.0;1274.0;4.533459338434091;21.15
98
+ Burundi;Soybeans;1990;10000.0;1274.0;4.533459338434091;21.15
99
+ Burundi;Sweet potatoes;1990;64427.0;1274.0;4.533459338434091;21.15
100
+ Burundi;Wheat;1990;7478.0;1274.0;4.533459338434091;21.15
101
+ Burundi;Yams;1990;57576.0;1274.0;4.533459338434091;21.15
102
+ Cameroon;Cassava;1990;164386.0;1604.0;6.111489512205864;25.08
103
+ Cameroon;Maize;1990;18543.0;1604.0;6.111489512205864;25.08
104
+ Cameroon;Plantains and others;1990;51150.0;1604.0;6.111489512205864;25.08
105
+ Cameroon;Potatoes;1990;16142.0;1604.0;6.111489512205864;25.08
106
+ Cameroon;Rice, paddy;1990;49999.0;1604.0;6.111489512205864;25.08
107
+ Cameroon;Sorghum;1990;8489.0;1604.0;6.111489512205864;25.08
108
+ Cameroon;Soybeans;1990;6000.0;1604.0;6.111489512205864;25.08
109
+ Cameroon;Sweet potatoes;1990;78150.0;1604.0;6.111489512205864;25.08
110
+ Cameroon;Wheat;1990;15000.0;1604.0;6.111489512205864;25.08
111
+ Cameroon;Yams;1990;39310.0;1604.0;6.111489512205864;25.08
112
+ Canada;Maize;1990;68602.0;537.0;10.294481794215836;7.42
113
+ Canada;Potatoes;1990;250994.0;537.0;10.294481794215836;7.42
114
+ Canada;Soybeans;1990;26096.0;537.0;10.294481794215836;7.42
115
+ Canada;Wheat;1990;22769.0;537.0;10.294481794215836;7.42
116
+ Central African Republic;Cassava;1990;28432.0;1342.0;0.039220713153281295;25.42
117
+ Central African Republic;Maize;1990;7324.0;1342.0;0.039220713153281295;25.42
118
+ Central African Republic;Plantains and others;1990;26154.0;1342.0;0.039220713153281295;25.42
119
+ Central African Republic;Potatoes;1990;24509.0;1342.0;0.039220713153281295;25.42
120
+ Central African Republic;Rice, paddy;1990;16729.0;1342.0;0.039220713153281295;25.42
121
+ Central African Republic;Sorghum;1990;7772.0;1342.0;0.039220713153281295;25.42
122
+ Central African Republic;Yams;1990;65714.0;1342.0;0.039220713153281295;25.42
123
+ Chile;Maize;1990;81395.0;1522.0;9.640433049909078;9.5
124
+ Chile;Potatoes;1990;150300.0;1522.0;9.640433049909078;9.5
125
+ Chile;Rice, paddy;1990;41734.0;1522.0;9.640433049909078;9.5
126
+ Chile;Sweet potatoes;1990;74784.0;1522.0;9.640433049909078;9.5
127
+ Chile;Wheat;1990;29481.0;1522.0;9.640433049909078;9.5
128
+ Colombia;Cassava;1990;93532.0;3240.0;9.801415512798407;24.81
129
+ Colombia;Maize;1990;14498.0;3240.0;9.801415512798407;24.81
130
+ Colombia;Plantains and others;1990;71514.0;3240.0;9.801415512798407;24.81
131
+ Colombia;Potatoes;1990;152736.0;3240.0;9.801415512798407;24.81
132
+ Colombia;Rice, paddy;1990;40618.0;3240.0;9.801415512798407;24.81
133
+ Colombia;Sorghum;1990;28476.0;3240.0;9.801415512798407;24.81
134
+ Colombia;Soybeans;1990;19986.0;3240.0;9.801415512798407;24.81
135
+ Colombia;Wheat;1990;18483.0;3240.0;9.801415512798407;24.81
136
+ Colombia;Yams;1990;62287.0;3240.0;9.801415512798407;24.81
137
+ Croatia;Maize;1992;41535.0;1113.0;7.742835955430749;10.78
138
+ Croatia;Potatoes;1992;79015.0;1113.0;7.742835955430749;10.78
139
+ Croatia;Sorghum;1992;45214.0;1113.0;7.742835955430749;10.78
140
+ Croatia;Soybeans;1992;17593.0;1113.0;7.742835955430749;10.78
141
+ Croatia;Wheat;1992;38967.0;1113.0;7.742835955430749;10.78
142
+ Denmark;Potatoes;1990;374583.0;703.0;8.639587799629844;9.83
143
+ Denmark;Wheat;1990;74180.0;703.0;8.639587799629844;9.83
144
+ Dominican Republic;Cassava;1990;64479.0;1410.0;8.511577452630602;26.64
145
+ Dominican Republic;Maize;1990;16479.0;1410.0;8.511577452630602;26.64
146
+ Dominican Republic;Plantains and others;1990;98884.0;1410.0;8.511577452630602;26.64
147
+ Dominican Republic;Potatoes;1990;118759.0;1410.0;8.511577452630602;26.64
148
+ Dominican Republic;Rice, paddy;1990;47851.0;1410.0;8.511577452630602;26.64
149
+ Dominican Republic;Sorghum;1990;24008.0;1410.0;8.511577452630602;26.64
150
+ Dominican Republic;Sweet potatoes;1990;60677.0;1410.0;8.511577452630602;26.64
151
+ Dominican Republic;Yams;1990;51705.0;1410.0;8.511577452630602;26.64
152
+ Ecuador;Cassava;1990;54593.0;2274.0;7.839131648274333;20.51
153
+ Ecuador;Maize;1990;10602.0;2274.0;7.839131648274333;20.51
154
+ Ecuador;Plantains and others;1990;118358.0;2274.0;7.839131648274333;20.51
155
+ Ecuador;Potatoes;1990;71727.0;2274.0;7.839131648274333;20.51
156
+ Ecuador;Rice, paddy;1990;31218.0;2274.0;7.839131648274333;20.51
157
+ Ecuador;Sorghum;1990;28273.0;2274.0;7.839131648274333;20.51
158
+ Ecuador;Soybeans;1990;19873.0;2274.0;7.839131648274333;20.51
159
+ Ecuador;Sweet potatoes;1990;59520.0;2274.0;7.839131648274333;20.51
160
+ Ecuador;Wheat;1990;7967.0;2274.0;7.839131648274333;20.51
161
+ Egypt;Maize;1990;57803.0;51.0;9.48910782703839;21.16
162
+ Egypt;Potatoes;1990;205592.0;51.0;9.48910782703839;21.16
163
+ Egypt;Rice, paddy;1990;72663.0;51.0;9.48910782703839;21.16
164
+ Egypt;Sorghum;1990;46920.0;51.0;9.48910782703839;21.16
165
+ Egypt;Soybeans;1990;25773.0;51.0;9.48910782703839;21.16
166
+ Egypt;Sweet potatoes;1990;257930.0;51.0;9.48910782703839;21.16
167
+ Egypt;Wheat;1990;51967.0;51.0;9.48910782703839;21.16
168
+ El Salvador;Cassava;1990;158889.0;1784.0;7.83399634170946;26.06
169
+ El Salvador;Maize;1990;21383.0;1784.0;7.83399634170946;26.06
170
+ El Salvador;Plantains and others;1990;111714.0;1784.0;7.83399634170946;26.06
171
+ El Salvador;Potatoes;1990;140000.0;1784.0;7.83399634170946;26.06
172
+ El Salvador;Rice, paddy;1990;43271.0;1784.0;7.83399634170946;26.06
173
+ El Salvador;Sorghum;1990;12423.0;1784.0;7.83399634170946;26.06
174
+ El Salvador;Soybeans;1990;20000.0;1784.0;7.83399634170946;26.06
175
+ El Salvador;Sweet potatoes;1990;64286.0;1784.0;7.83399634170946;26.06
176
+ Eritrea;Maize;1993;2308.0;383.0;1.6937790608678513;24.09
177
+ Eritrea;Potatoes;1993;82000.0;383.0;1.6937790608678513;24.09
178
+ Eritrea;Sorghum;1993;3197.0;383.0;1.6937790608678513;24.09
179
+ Eritrea;Wheat;1993;2038.0;383.0;1.6937790608678513;24.09
180
+ Estonia;Potatoes;1992;144514.0;626.0;6.152732694704104;6.51
181
+ Estonia;Wheat;1992;20562.0;626.0;6.152732694704104;6.51
182
+ Finland;Potatoes;1990;214976.0;536.0;7.601901959875166;6.07
183
+ Finland;Wheat;1990;34847.0;536.0;7.601901959875166;6.07
184
+ France;Maize;1990;60186.0;867.0;11.489677308650418;11.96
185
+ France;Potatoes;1990;290790.0;867.0;11.489677308650418;11.96
186
+ France;Rice, paddy;1990;59461.0;867.0;11.489677308650418;11.96
187
+ France;Sorghum;1990;41296.0;867.0;11.489677308650418;11.96
188
+ France;Soybeans;1990;20940.0;867.0;11.489677308650418;11.96
189
+ France;Wheat;1990;64787.0;867.0;11.489677308650418;11.96
190
+ Germany;Maize;1990;67762.0;700.0;10.351053836662928;8.9
191
+ Germany;Potatoes;1990;257764.0;700.0;10.351053836662928;8.9
192
+ Germany;Soybeans;1990;19792.0;700.0;10.351053836662928;8.9
193
+ Germany;Wheat;1990;62734.0;700.0;10.351053836662928;8.9
194
+ Ghana;Cassava;1990;84170.0;1187.0;4.2017030805426;26.73
195
+ Ghana;Maize;1990;11889.0;1187.0;4.2017030805426;26.73
196
+ Ghana;Plantains and others;1990;61890.0;1187.0;4.2017030805426;26.73
197
+ Ghana;Rice, paddy;1990;16510.0;1187.0;4.2017030805426;26.73
198
+ Ghana;Sorghum;1990;6310.0;1187.0;4.2017030805426;26.73
199
+ Ghana;Yams;1990;73451.0;1187.0;4.2017030805426;26.73
200
+ Ghana;Sweet potatoes;1996;13596.0;1187.0;7.362962478985115;26.61
201
+ Greece;Maize;1990;96965.0;652.0;8.912069097970134;18.05
202
+ Greece;Potatoes;1990;189470.0;652.0;8.912069097970134;18.05
203
+ Greece;Rice, paddy;1990;60000.0;652.0;8.912069097970134;18.05
204
+ Greece;Sorghum;1990;20000.0;652.0;8.912069097970134;18.05
205
+ Greece;Soybeans;1990;30000.0;652.0;8.912069097970134;18.05
206
+ Greece;Sweet potatoes;1990;168333.0;652.0;8.912069097970134;18.05
207
+ Greece;Wheat;1990;19332.0;652.0;8.912069097970134;18.05
208
+ Guatemala;Cassava;1990;31400.0;1996.0;9.393105996823989;19.64
209
+ Guatemala;Maize;1990;20052.0;1996.0;9.393105996823989;19.64
210
+ Guatemala;Plantains and others;1990;394286.0;1996.0;9.393105996823989;19.64
211
+ Guatemala;Potatoes;1990;210685.0;1996.0;9.393105996823989;19.64
212
+ Guatemala;Rice, paddy;1990;31111.0;1996.0;9.393105996823989;19.64
213
+ Guatemala;Sorghum;1990;16237.0;1996.0;9.393105996823989;19.64
214
+ Guatemala;Soybeans;1990;26288.0;1996.0;9.393105996823989;19.64
215
+ Guatemala;Wheat;1990;19983.0;1996.0;9.393105996823989;19.64
216
+ Guatemala;Sweet potatoes;1993;62500.0;1996.0;9.393105996823989;19.85
217
+ Guinea;Cassava;1990;72011.0;1651.0;4.394449154672439;27.08
218
+ Guinea;Maize;1990;10179.0;1651.0;4.394449154672439;27.08
219
+ Guinea;Plantains and others;1990;51333.0;1651.0;4.394449154672439;27.08
220
+ Guinea;Rice, paddy;1990;17106.0;1651.0;4.394449154672439;27.08
221
+ Guinea;Sorghum;1990;16420.0;1651.0;4.394449154672439;27.08
222
+ Guinea;Sweet potatoes;1990;49493.0;1651.0;4.394449154672439;27.08
223
+ Guinea;Yams;1990;100000.0;1651.0;4.394449154672439;27.08
224
+ Guinea;Potatoes;2004;61356.0;1651.0;5.794506396061012;27.56
225
+ Guyana;Cassava;1990;109000.0;2387.0;5.672979565501156;27.07
226
+ Guyana;Maize;1990;15666.0;2387.0;5.672979565501156;27.07
227
+ Guyana;Plantains and others;1990;32500.0;2387.0;5.672979565501156;27.07
228
+ Guyana;Rice, paddy;1990;30331.0;2387.0;5.672979565501156;27.07
229
+ Guyana;Sweet potatoes;1997;16667.0;2387.0;5.672979565501156;27.25
230
+ Guyana;Yams;1997;96154.0;2387.0;5.672979565501156;27.25
231
+ Haiti;Cassava;1990;40244.0;1440.0;2.8981194446869907;27.11
232
+ Haiti;Maize;1990;7951.0;1440.0;2.8981194446869907;27.11
233
+ Haiti;Plantains and others;1990;70238.0;1440.0;2.8981194446869907;27.11
234
+ Haiti;Potatoes;1990;109308.0;1440.0;2.8981194446869907;27.11
235
+ Haiti;Rice, paddy;1990;21122.0;1440.0;2.8981194446869907;27.11
236
+ Haiti;Sorghum;1990;8000.0;1440.0;2.8981194446869907;27.11
237
+ Haiti;Sweet potatoes;1990;34921.0;1440.0;2.8981194446869907;27.11
238
+ Haiti;Yams;1990;50000.0;1440.0;2.8981194446869907;27.11
239
+ Honduras;Cassava;1990;79680.0;1976.0;9.198376084473077;24.53
240
+ Honduras;Maize;1990;15188.0;1976.0;9.198376084473077;24.53
241
+ Honduras;Plantains and others;1990;149570.0;1976.0;9.198376084473077;24.53
242
+ Honduras;Potatoes;1990;113100.0;1976.0;9.198376084473077;24.53
243
+ Honduras;Rice, paddy;1990;25026.0;1976.0;9.198376084473077;24.53
244
+ Honduras;Sorghum;1990;10182.0;1976.0;9.198376084473077;24.53
245
+ Honduras;Sweet potatoes;1990;64286.0;1976.0;9.198376084473077;24.53
246
+ Honduras;Wheat;1990;5769.0;1976.0;9.198376084473077;24.53
247
+ Honduras;Soybeans;1993;19227.0;1976.0;8.820108644508608;24.58
248
+ Hungary;Maize;1990;41577.0;589.0;9.45383541953829;10.96
249
+ Hungary;Potatoes;1990;170773.0;589.0;9.45383541953829;10.96
250
+ Hungary;Rice, paddy;1990;33520.0;589.0;9.45383541953829;10.96
251
+ Hungary;Sorghum;1990;21466.0;589.0;9.45383541953829;10.96
252
+ Hungary;Soybeans;1990;12853.0;589.0;9.45383541953829;10.96
253
+ Hungary;Wheat;1990;50771.0;589.0;9.45383541953829;10.96
254
+ India;Cassava;1990;205381.0;1083.0;11.225256725762893;25.6
255
+ India;Maize;1990;15178.0;1083.0;11.225256725762893;25.6
256
+ India;Potatoes;1990;157136.0;1083.0;11.225256725762893;25.6
257
+ India;Rice, paddy;1990;26125.0;1083.0;11.225256725762893;25.6
258
+ India;Sorghum;1990;8136.0;1083.0;11.225256725762893;25.6
259
+ India;Soybeans;1990;10145.0;1083.0;11.225256725762893;25.6
260
+ India;Sweet potatoes;1990;79663.0;1083.0;11.225256725762893;25.6
261
+ India;Wheat;1990;21211.0;1083.0;11.225256725762893;25.6
262
+ Indonesia;Cassava;1990;120691.0;2702.0;7.796880342783522;26.83
263
+ Indonesia;Maize;1990;21323.0;2702.0;7.796880342783522;26.83
264
+ Indonesia;Potatoes;1990;141637.0;2702.0;7.796880342783522;26.83
265
+ Indonesia;Rice, paddy;1990;43018.0;2702.0;7.796880342783522;26.83
266
+ Indonesia;Soybeans;1990;11149.0;2702.0;7.796880342783522;26.83
267
+ Indonesia;Sweet potatoes;1990;94450.0;2702.0;7.796880342783522;26.83
268
+ Iraq;Maize;1990;24814.0;216.0;6.541029999189903;21.58
269
+ Iraq;Potatoes;1990;166681.0;216.0;6.541029999189903;21.58
270
+ Iraq;Rice, paddy;1990;28889.0;216.0;6.541029999189903;21.58
271
+ Iraq;Sorghum;1990;7273.0;216.0;6.541029999189903;21.58
272
+ Iraq;Soybeans;1990;14615.0;216.0;6.541029999189903;21.58
273
+ Iraq;Wheat;1990;10129.0;216.0;6.541029999189903;21.58
274
+ Ireland;Potatoes;1990;248971.0;1118.0;7.608374474380783;9.59
275
+ Ireland;Wheat;1990;85307.0;1118.0;7.608374474380783;9.59
276
+ Italy;Maize;1990;76375.0;832.0;11.518881691383372;10.4
277
+ Italy;Potatoes;1990;191624.0;832.0;11.518881691383372;10.4
278
+ Italy;Rice, paddy;1990;60278.0;832.0;11.518881691383372;10.4
279
+ Italy;Sorghum;1990;48234.0;832.0;11.518881691383372;10.4
280
+ Italy;Soybeans;1990;33588.0;832.0;11.518881691383372;10.4
281
+ Italy;Sweet potatoes;1990;214829.0;832.0;11.518881691383372;10.4
282
+ Italy;Wheat;1990;29243.0;832.0;11.518881691383372;10.4
283
+ Jamaica;Cassava;1990;119102.0;2051.0;7.256050208475266;27.28
284
+ Jamaica;Maize;1990;10588.0;2051.0;7.256050208475266;27.28
285
+ Jamaica;Plantains and others;1990;138727.0;2051.0;7.256050208475266;27.28
286
+ Jamaica;Potatoes;1990;122818.0;2051.0;7.256050208475266;27.28
287
+ Jamaica;Rice, paddy;1990;23656.0;2051.0;7.256050208475266;27.28
288
+ Jamaica;Sweet potatoes;1990;112543.0;2051.0;7.256050208475266;27.28
289
+ Jamaica;Yams;1990;130749.0;2051.0;7.256050208475266;27.28
290
+ Japan;Maize;1990;25457.0;1668.0;11.287556689680539;15.57
291
+ Japan;Potatoes;1990;306736.0;1668.0;11.287556689680539;15.57
292
+ Japan;Rice, paddy;1990;63279.0;1668.0;11.287556689680539;15.57
293
+ Japan;Soybeans;1990;15106.0;1668.0;11.287556689680539;15.57
294
+ Japan;Sweet potatoes;1990;231353.0;1668.0;11.287556689680539;15.57
295
+ Japan;Wheat;1990;36540.0;1668.0;11.287556689680539;15.57
296
+ Japan;Yams;1990;210808.0;1668.0;11.287556689680539;15.57
297
+ Kazakhstan;Maize;1992;31214.0;250.0;9.751675801946746;4.49
298
+ Kazakhstan;Potatoes;1992;105923.0;250.0;9.751675801946746;4.49
299
+ Kazakhstan;Rice, paddy;1992;39915.0;250.0;9.751675801946746;4.49
300
+ Kazakhstan;Sorghum;1992;11765.0;250.0;9.751675801946746;4.49
301
+ Kazakhstan;Soybeans;1992;11919.0;250.0;9.751675801946746;4.49
302
+ Kazakhstan;Wheat;1992;13324.0;250.0;9.751675801946746;4.49
303
+ Kenya;Cassava;1990;108498.0;630.0;8.151909872940905;15.94
304
+ Kenya;Maize;1990;16591.0;630.0;8.151909872940905;15.94
305
+ Kenya;Plantains and others;1990;125000.0;630.0;8.151909872940905;15.94
306
+ Kenya;Potatoes;1990;88655.0;630.0;8.151909872940905;15.94
307
+ Kenya;Rice, paddy;1990;30984.0;630.0;8.151909872940905;15.94
308
+ Kenya;Sorghum;1990;8473.0;630.0;8.151909872940905;15.94
309
+ Kenya;Soybeans;1990;8000.0;630.0;8.151909872940905;15.94
310
+ Kenya;Sweet potatoes;1990;99153.0;630.0;8.151909872940905;15.94
311
+ Kenya;Wheat;1990;16551.0;630.0;8.151909872940905;15.94
312
+ Kenya;Yams;1990;88356.0;630.0;8.151909872940905;15.94
313
+ Latvia;Potatoes;1992;120475.0;641.0;6.913737350659685;6.89
314
+ Latvia;Wheat;1992;25848.0;641.0;6.913737350659685;6.89
315
+ Lebanon;Maize;1990;16910.0;661.0;7.108244139731541;19.4
316
+ Lebanon;Potatoes;1990;180927.0;661.0;7.108244139731541;19.4
317
+ Lebanon;Sorghum;1990;12500.0;661.0;7.108244139731541;19.4
318
+ Lebanon;Wheat;1990;19704.0;661.0;7.108244139731541;19.4
319
+ Lesotho;Maize;1990;11000.0;788.0;0.26236426446749106;14.48
320
+ Lesotho;Potatoes;1990;176905.0;788.0;0.26236426446749106;14.48
321
+ Lesotho;Sorghum;1990;10112.0;788.0;0.26236426446749106;14.48
322
+ Lesotho;Wheat;1990;8118.0;788.0;0.26236426446749106;14.48
323
+ Libya;Maize;1990;10000.0;56.0;4.477336814478207;20.07
324
+ Libya;Potatoes;1990;80556.0;56.0;4.477336814478207;20.07
325
+ Libya;Wheat;1990;12317.0;56.0;4.477336814478207;20.07
326
+ Lithuania;Maize;1992;13710.0;656.0;7.2305631534092925;7.04
327
+ Lithuania;Potatoes;1992;94916.0;656.0;7.2305631534092925;7.04
328
+ Lithuania;Wheat;1992;29411.0;656.0;7.2305631534092925;7.04
329
+ Madagascar;Cassava;1990;66512.0;1513.0;4.862985658833579;19.62
330
+ Madagascar;Maize;1990;9848.0;1513.0;4.862985658833579;19.62
331
+ Madagascar;Potatoes;1990;69744.0;1513.0;4.862985658833579;19.62
332
+ Madagascar;Rice, paddy;1990;20773.0;1513.0;4.862985658833579;19.62
333
+ Madagascar;Sorghum;1990;5969.0;1513.0;4.862985658833579;19.62
334
+ Madagascar;Soybeans;1990;10417.0;1513.0;4.862985658833579;19.62
335
+ Madagascar;Sweet potatoes;1990;53407.0;1513.0;4.862985658833579;19.62
336
+ Madagascar;Wheat;1990;20000.0;1513.0;4.862985658833579;19.62
337
+ Malawi;Cassava;1990;23536.0;1181.0;5.160146657489371;20.86
338
+ Malawi;Maize;1990;9993.0;1181.0;5.160146657489371;20.86
339
+ Malawi;Plantains and others;1990;40179.0;1181.0;5.160146657489371;20.86
340
+ Malawi;Potatoes;1990;102044.0;1181.0;5.160146657489371;20.86
341
+ Malawi;Rice, paddy;1990;14903.0;1181.0;5.160146657489371;20.86
342
+ Malawi;Sorghum;1990;5015.0;1181.0;5.160146657489371;20.86
343
+ Malawi;Wheat;1990;7735.0;1181.0;5.160146657489371;20.86
344
+ Malawi;Soybeans;2004;6447.0;1181.0;3.8975183192252643;20.44
345
+ Malaysia;Cassava;1990;97297.0;2875.0;10.581710924982964;27.21
346
+ Malaysia;Maize;1990;17500.0;2875.0;10.581710924982964;27.21
347
+ Malaysia;Rice, paddy;1990;27694.0;2875.0;10.581710924982964;27.21
348
+ Malaysia;Soybeans;1990;3333.0;2875.0;10.581710924982964;27.21
349
+ Malaysia;Sweet potatoes;1990;110000.0;2875.0;10.581710924982964;27.21
350
+ Mali;Cassava;1990;72500.0;282.0;4.571613402459248;27.61
351
+ Mali;Maize;1990;11566.0;282.0;4.571613402459248;27.61
352
+ Mali;Potatoes;1990;180000.0;282.0;4.571613402459248;27.61
353
+ Mali;Rice, paddy;1990;14360.0;282.0;4.571613402459248;27.61
354
+ Mali;Sorghum;1990;6571.0;282.0;4.571613402459248;27.61
355
+ Mali;Soybeans;1990;16667.0;282.0;4.571613402459248;27.61
356
+ Mali;Sweet potatoes;1990;48316.0;282.0;4.571613402459248;27.61
357
+ Mali;Wheat;1990;11991.0;282.0;4.571613402459248;27.61
358
+ Mali;Yams;1990;45091.0;282.0;4.571613402459248;27.61
359
+ Mauritania;Maize;1990;6789.0;92.0;3.6911269266544156;27.67
360
+ Mauritania;Potatoes;1990;54628.0;92.0;3.6911269266544156;27.67
361
+ Mauritania;Rice, paddy;1990;33307.0;92.0;3.6911269266544156;27.67
362
+ Mauritania;Sorghum;1990;5153.0;92.0;3.6911269266544156;27.67
363
+ Mauritania;Sweet potatoes;1990;8799.0;92.0;3.6911269266544156;27.67
364
+ Mauritania;Wheat;1990;10769.0;92.0;3.6911269266544156;27.67
365
+ Mauritania;Yams;1990;63927.0;92.0;3.6911269266544156;27.67
366
+ Mauritius;Cassava;1990;135714.0;2041.0;6.7912214627261855;23.84
367
+ Mauritius;Maize;1990;41790.0;2041.0;6.7912214627261855;23.84
368
+ Mauritius;Potatoes;1990;181098.0;2041.0;6.7912214627261855;23.84
369
+ Mauritius;Rice, paddy;1990;63333.0;2041.0;6.7912214627261855;23.84
370
+ Mauritius;Sweet potatoes;1990;75581.0;2041.0;6.7912214627261855;23.84
371
+ Mexico;Cassava;1990;75504.0;758.0;10.44784262875747;20.24
372
+ Mexico;Maize;1990;19942.0;758.0;10.44784262875747;20.24
373
+ Mexico;Potatoes;1990;158256.0;758.0;10.44784262875747;20.24
374
+ Mexico;Rice, paddy;1990;37418.0;758.0;10.44784262875747;20.24
375
+ Mexico;Sorghum;1990;32888.0;758.0;10.44784262875747;20.24
376
+ Mexico;Soybeans;1990;20145.0;758.0;10.44784262875747;20.24
377
+ Mexico;Sweet potatoes;1990;167541.0;758.0;10.44784262875747;20.24
378
+ Mexico;Wheat;1990;42143.0;758.0;10.44784262875747;20.24
379
+ Montenegro;Maize;2006;32588.0;241.0;0.4382549309311553;10.56
380
+ Montenegro;Potatoes;2006;130448.0;241.0;0.4382549309311553;10.56
381
+ Montenegro;Wheat;2006;30903.0;241.0;0.4382549309311553;10.56
382
+ Morocco;Maize;1990;11598.0;346.0;9.144734614878189;18.23
383
+ Morocco;Potatoes;1990;171851.0;346.0;9.144734614878189;18.23
384
+ Morocco;Rice, paddy;1990;41750.0;346.0;9.144734614878189;18.23
385
+ Morocco;Sorghum;1990;5496.0;346.0;9.144734614878189;18.23
386
+ Morocco;Soybeans;1990;16181.0;346.0;9.144734614878189;18.23
387
+ Morocco;Sweet potatoes;1990;155421.0;346.0;9.144734614878189;18.23
388
+ Morocco;Wheat;1990;13290.0;346.0;9.144734614878189;18.23
389
+ Mozambique;Cassava;1990;48612.0;1032.0;4.637250079451503;21.51
390
+ Mozambique;Maize;1990;4480.0;1032.0;4.637250079451503;21.51
391
+ Mozambique;Potatoes;1990;120710.0;1032.0;4.637250079451503;21.51
392
+ Mozambique;Rice, paddy;1990;8747.0;1032.0;4.637250079451503;21.51
393
+ Mozambique;Sorghum;1990;4329.0;1032.0;4.637250079451503;21.51
394
+ Mozambique;Sweet potatoes;1990;58544.0;1032.0;4.637250079451503;21.51
395
+ Mozambique;Wheat;1990;18001.0;1032.0;4.637250079451503;21.51
396
+ Namibia;Maize;1990;14871.0;285.0;3.7612001156935624;20.4
397
+ Namibia;Sorghum;1990;2052.0;285.0;3.7612001156935624;20.4
398
+ Namibia;Wheat;1990;44250.0;285.0;3.7612001156935624;20.4
399
+ Namibia;Potatoes;2000;125000.0;285.0;4.04305126783455;20.26
400
+ Nepal;Maize;1990;16246.0;1500.0;4.1126755189068245;15.11
401
+ Nepal;Potatoes;1990;80601.0;1500.0;4.1126755189068245;15.11
402
+ Nepal;Rice, paddy;1990;24067.0;1500.0;4.1126755189068245;15.11
403
+ Nepal;Soybeans;1990;6215.0;1500.0;4.1126755189068245;15.11
404
+ Nepal;Wheat;1990;14149.0;1500.0;4.1126755189068245;15.11
405
+ Netherlands;Maize;1990;90909.0;778.0;9.18296917518005;10.63
406
+ Netherlands;Potatoes;1990;401380.0;778.0;9.18296917518005;10.63
407
+ Netherlands;Wheat;1990;76528.0;778.0;9.18296917518005;10.63
408
+ New Zealand;Maize;1990;92077.0;1732.0;8.157943507105037;13.64
409
+ New Zealand;Potatoes;1990;325000.0;1732.0;8.157943507105037;13.64
410
+ New Zealand;Sweet potatoes;1990;159383.0;1732.0;8.157943507105037;13.64
411
+ New Zealand;Wheat;1990;48842.0;1732.0;8.157943507105037;13.64
412
+ Nicaragua;Cassava;1990;110417.0;2280.0;6.3561076606958915;27.03
413
+ Nicaragua;Maize;1990;12825.0;2280.0;6.3561076606958915;27.03
414
+ Nicaragua;Plantains and others;1990;100000.0;2280.0;6.3561076606958915;27.03
415
+ Nicaragua;Potatoes;1990;143750.0;2280.0;6.3561076606958915;27.03
416
+ Nicaragua;Rice, paddy;1990;26326.0;2280.0;6.3561076606958915;27.03
417
+ Nicaragua;Sorghum;1990;16210.0;2280.0;6.3561076606958915;27.03
418
+ Nicaragua;Soybeans;1990;16429.0;2280.0;6.3561076606958915;27.03
419
+ Nicaragua;Yams;1991;132736.0;2280.0;6.3561076606958915;27.04
420
+ Niger;Cassava;1990;88688.0;151.0;4.143134726391533;29.71
421
+ Niger;Maize;1990;3139.0;151.0;4.143134726391533;29.71
422
+ Niger;Potatoes;1990;100000.0;151.0;4.143134726391533;29.71
423
+ Niger;Rice, paddy;1990;31432.0;151.0;4.143134726391533;29.71
424
+ Niger;Sorghum;1990;1257.0;151.0;4.143134726391533;29.71
425
+ Niger;Sweet potatoes;1990;87500.0;151.0;4.143134726391533;29.71
426
+ Niger;Wheat;1990;28889.0;151.0;4.143134726391533;29.71
427
+ Norway;Potatoes;1990;257507.0;1414.0;7.076653815443951;4.55
428
+ Norway;Wheat;1990;46634.0;1414.0;7.076653815443951;4.55
429
+ Pakistan;Maize;1990;14014.0;494.0;8.575462099540212;24.22
430
+ Pakistan;Potatoes;1990;104002.0;494.0;8.575462099540212;24.22
431
+ Pakistan;Rice, paddy;1990;23151.0;494.0;8.575462099540212;24.22
432
+ Pakistan;Sorghum;1990;5736.0;494.0;8.575462099540212;24.22
433
+ Pakistan;Soybeans;1990;5679.0;494.0;8.575462099540212;24.22
434
+ Pakistan;Sweet potatoes;1990;92141.0;494.0;8.575462099540212;24.22
435
+ Pakistan;Wheat;1990;18249.0;494.0;8.575462099540212;24.22
436
+ Papua New Guinea;Cassava;1990;105566.0;3142.0;4.804021044733257;25.27
437
+ Papua New Guinea;Maize;1990;25000.0;3142.0;4.804021044733257;25.27
438
+ Papua New Guinea;Potatoes;1990;45000.0;3142.0;4.804021044733257;25.27
439
+ Papua New Guinea;Rice, paddy;1990;18235.0;3142.0;4.804021044733257;25.27
440
+ Papua New Guinea;Sorghum;1990;41152.0;3142.0;4.804021044733257;25.27
441
+ Papua New Guinea;Sweet potatoes;1990;42115.0;3142.0;4.804021044733257;25.27
442
+ Papua New Guinea;Yams;1990;173554.0;3142.0;4.804021044733257;25.27
443
+ Peru;Cassava;1990;93413.0;1738.0;8.050384453067021;16.84
444
+ Peru;Maize;1990;19532.0;1738.0;8.050384453067021;16.84
445
+ Peru;Plantains and others;1990;121397.0;1738.0;8.050384453067021;16.84
446
+ Peru;Potatoes;1990;78805.0;1738.0;8.050384453067021;16.84
447
+ Peru;Rice, paddy;1990;52290.0;1738.0;8.050384453067021;16.84
448
+ Peru;Sorghum;1990;27036.0;1738.0;8.050384453067021;16.84
449
+ Peru;Soybeans;1990;20998.0;1738.0;8.050384453067021;16.84
450
+ Peru;Sweet potatoes;1990;159470.0;1738.0;8.050384453067021;16.84
451
+ Peru;Wheat;1990;10847.0;1738.0;8.050384453067021;16.84
452
+ Poland;Maize;1990;49126.0;600.0;8.59840444684106;9.2
453
+ Poland;Potatoes;1990;197853.0;600.0;8.59840444684106;9.2
454
+ Poland;Wheat;1990;39575.0;600.0;8.59840444684106;9.2
455
+ Poland;Soybeans;2004;16007.0;600.0;9.074176947163311;8.33
456
+ Portugal;Maize;1990;30334.0;854.0;9.143986871426161;16.55
457
+ Portugal;Potatoes;1990;111599.0;854.0;9.143986871426161;16.55
458
+ Portugal;Rice, paddy;1990;46142.0;854.0;9.143986871426161;16.55
459
+ Portugal;Sweet potatoes;1990;81250.0;854.0;9.143986871426161;16.55
460
+ Portugal;Wheat;1990;14269.0;854.0;9.143986871426161;16.55
461
+ Portugal;Yams;1990;104819.0;854.0;9.143986871426161;16.55
462
+ Qatar;Maize;1990;135000.0;74.0;1.3862943611198906;27.38
463
+ Qatar;Potatoes;1990;96667.0;74.0;1.3862943611198906;27.38
464
+ Qatar;Wheat;1990;22996.0;74.0;1.3862943611198906;27.38
465
+ Romania;Maize;1990;27606.0;637.0;10.136819030237827;12.26
466
+ Romania;Potatoes;1990;109996.0;637.0;10.136819030237827;12.26
467
+ Romania;Rice, paddy;1990;16667.0;637.0;10.136819030237827;12.26
468
+ Romania;Sorghum;1990;6731.0;637.0;10.136819030237827;12.26
469
+ Romania;Soybeans;1990;7421.0;637.0;10.136819030237827;12.26
470
+ Romania;Wheat;1990;32351.0;637.0;10.136819030237827;12.26
471
+ Rwanda;Cassava;1990;20126.0;1212.0;5.062595033026967;19.39
472
+ Rwanda;Maize;1990;10252.0;1212.0;5.062595033026967;19.39
473
+ Rwanda;Potatoes;1990;67453.0;1212.0;5.062595033026967;19.39
474
+ Rwanda;Rice, paddy;1990;13652.0;1212.0;5.062595033026967;19.39
475
+ Rwanda;Sorghum;1990;10688.0;1212.0;5.062595033026967;19.39
476
+ Rwanda;Soybeans;1990;6735.0;1212.0;5.062595033026967;19.39
477
+ Rwanda;Sweet potatoes;1990;46491.0;1212.0;5.062595033026967;19.39
478
+ Rwanda;Wheat;1990;11811.0;1212.0;5.062595033026967;19.39
479
+ Rwanda;Yams;1990;40000.0;1212.0;5.062595033026967;19.39
480
+ Saudi Arabia;Maize;1990;17992.0;59.0;6.902742737158593;25.78
481
+ Saudi Arabia;Potatoes;1990;198311.0;59.0;6.902742737158593;25.78
482
+ Saudi Arabia;Sorghum;1990;12369.0;59.0;6.902742737158593;25.78
483
+ Saudi Arabia;Wheat;1990;46461.0;59.0;6.902742737158593;25.78
484
+ Senegal;Cassava;1990;35159.0;686.0;5.953243334287785;25.13
485
+ Senegal;Maize;1990;11411.0;686.0;5.953243334287785;25.13
486
+ Senegal;Potatoes;1990;145518.0;686.0;5.953243334287785;25.13
487
+ Senegal;Rice, paddy;1990;24825.0;686.0;5.953243334287785;25.13
488
+ Senegal;Sorghum;1990;9101.0;686.0;5.953243334287785;25.13
489
+ Senegal;Sweet potatoes;1990;57380.0;686.0;5.953243334287785;25.13
490
+ Slovenia;Maize;1992;28150.0;1162.0;7.177782416195197;10.78
491
+ Slovenia;Potatoes;1992;121000.0;1162.0;7.177782416195197;10.78
492
+ Slovenia;Soybeans;1992;20000.0;1162.0;7.177782416195197;10.78
493
+ Slovenia;Wheat;1992;41937.0;1162.0;7.177782416195197;10.78
494
+ South Africa;Maize;1990;22051.0;495.0;9.716133353214099;17.65
495
+ South Africa;Potatoes;1990;200263.0;495.0;9.716133353214099;17.65
496
+ South Africa;Rice, paddy;1990;18976.0;495.0;9.716133353214099;17.65
497
+ South Africa;Sorghum;1990;17398.0;495.0;9.716133353214099;17.65
498
+ South Africa;Soybeans;1990;19377.0;495.0;9.716133353214099;17.65
499
+ South Africa;Sweet potatoes;1990;35872.0;495.0;9.716133353214099;17.65
500
+ South Africa;Wheat;1990;10934.0;495.0;9.716133353214099;17.65
501
+ Spain;Maize;1990;64256.0;636.0;10.585649617037317;15.78
502
+ Spain;Potatoes;1990;196487.0;636.0;10.585649617037317;15.78
503
+ Spain;Rice, paddy;1990;63209.0;636.0;10.585649617037317;15.78
504
+ Spain;Sorghum;1990;53234.0;636.0;10.585649617037317;15.78
505
+ Spain;Soybeans;1990;24253.0;636.0;10.585649617037317;15.78
506
+ Spain;Sweet potatoes;1990;170608.0;636.0;10.585649617037317;15.78
507
+ Spain;Wheat;1990;23789.0;636.0;10.585649617037317;15.78
508
+ Sri Lanka;Cassava;1990;87717.0;1712.0;7.360313874622385;26.53
509
+ Sri Lanka;Maize;1990;11227.0;1712.0;7.360313874622385;26.53
510
+ Sri Lanka;Plantains and others;1990;140381.0;1712.0;7.360313874622385;26.53
511
+ Sri Lanka;Potatoes;1990;110520.0;1712.0;7.360313874622385;26.53
512
+ Sri Lanka;Rice, paddy;1990;30643.0;1712.0;7.360313874622385;26.53
513
+ Sri Lanka;Sorghum;1990;7143.0;1712.0;7.360313874622385;26.53
514
+ Sri Lanka;Soybeans;1990;8040.0;1712.0;7.360313874622385;26.53
515
+ Sri Lanka;Sweet potatoes;1990;64750.0;1712.0;7.360313874622385;26.53
516
+ Suriname;Cassava;1990;125641.0;2331.0;5.384495062789089;26.87
517
+ Suriname;Maize;1990;21575.0;2331.0;5.384495062789089;26.87
518
+ Suriname;Plantains and others;1990;206853.0;2331.0;5.384495062789089;26.87
519
+ Suriname;Rice, paddy;1990;37691.0;2331.0;5.384495062789089;26.87
520
+ Suriname;Soybeans;1990;5323.0;2331.0;5.384495062789089;26.87
521
+ Suriname;Sweet potatoes;1990;90667.0;2331.0;5.384495062789089;26.87
522
+ Sweden;Potatoes;1990;348034.0;624.0;7.745435610274381;8.43
523
+ Sweden;Wheat;1990;64494.0;624.0;7.745435610274381;8.43
524
+ Switzerland;Maize;1990;85102.0;1537.0;7.733245646529795;8.19
525
+ Switzerland;Potatoes;1990;379017.0;1537.0;7.733245646529795;8.19
526
+ Switzerland;Soybeans;1990;24266.0;1537.0;7.733245646529795;8.19
527
+ Switzerland;Wheat;1990;56376.0;1537.0;7.733245646529795;8.19
528
+ Tajikistan;Maize;1992;29613.0;691.0;7.732369222284388;7.9
529
+ Tajikistan;Potatoes;1992;128769.0;691.0;7.732369222284388;7.9
530
+ Tajikistan;Rice, paddy;1992;20184.0;691.0;7.732369222284388;7.9
531
+ Tajikistan;Sorghum;1992;11720.0;691.0;7.732369222284388;7.9
532
+ Tajikistan;Soybeans;1992;50.0;691.0;7.732369222284388;7.9
533
+ Tajikistan;Wheat;1992;9073.0;691.0;7.732369222284388;7.9
534
+ Thailand;Cassava;1990;139159.0;1622.0;9.844268192876157;27.96
535
+ Thailand;Maize;1990;24090.0;1622.0;9.844268192876157;27.96
536
+ Thailand;Potatoes;1990;90000.0;1622.0;9.844268192876157;27.96
537
+ Thailand;Rice, paddy;1990;19556.0;1622.0;9.844268192876157;27.96
538
+ Thailand;Sorghum;1990;12590.0;1622.0;9.844268192876157;27.96
539
+ Thailand;Soybeans;1990;12998.0;1622.0;9.844268192876157;27.96
540
+ Thailand;Wheat;1990;6107.0;1622.0;9.844268192876157;27.96
541
+ Tunisia;Potatoes;1990;136478.0;207.0;6.813444599510896;19.34
542
+ Tunisia;Sorghum;1990;4286.0;207.0;6.813444599510896;19.34
543
+ Tunisia;Wheat;1990;12721.0;207.0;6.813444599510896;19.34
544
+ Turkey;Maize;1990;40803.0;593.0;10.306249009069978;14.72
545
+ Turkey;Potatoes;1990;224367.0;593.0;10.306249009069978;14.72
546
+ Turkey;Rice, paddy;1990;49625.0;593.0;10.306249009069978;14.72
547
+ Turkey;Soybeans;1990;21892.0;593.0;10.306249009069978;14.72
548
+ Turkey;Wheat;1990;21227.0;593.0;10.306249009069978;14.72
549
+ Turkey;Sorghum;2004;23333.0;593.0;10.269241160408065;14.99
550
+ Uganda;Cassava;1990;83010.0;1180.0;4.290459441148391;23.36
551
+ Uganda;Maize;1990;15012.0;1180.0;4.290459441148391;23.36
552
+ Uganda;Plantains and others;1990;56499.0;1180.0;4.290459441148391;23.36
553
+ Uganda;Potatoes;1990;70000.0;1180.0;4.290459441148391;23.36
554
+ Uganda;Rice, paddy;1990;13846.0;1180.0;4.290459441148391;23.36
555
+ Uganda;Sorghum;1990;15000.0;1180.0;4.290459441148391;23.36
556
+ Uganda;Soybeans;1990;9927.0;1180.0;4.290459441148391;23.36
557
+ Uganda;Sweet potatoes;1990;41009.0;1180.0;4.290459441148391;23.36
558
+ Uganda;Wheat;1990;20000.0;1180.0;4.290459441148391;23.36
559
+ Ukraine;Maize;1992;25072.0;565.0;11.109054086200521;8.07
560
+ Ukraine;Potatoes;1992;118906.0;565.0;11.109054086200521;8.07
561
+ Ukraine;Rice, paddy;1992;37722.0;565.0;11.109054086200521;8.07
562
+ Ukraine;Sorghum;1992;8571.0;565.0;11.109054086200521;8.07
563
+ Ukraine;Soybeans;1992;7836.0;565.0;11.109054086200521;8.07
564
+ Ukraine;Wheat;1992;30926.0;565.0;11.109054086200521;8.07
565
+ United Kingdom;Potatoes;1990;365161.0;1220.0;10.292755525741722;10.0
566
+ United Kingdom;Wheat;1990;69712.0;1220.0;10.292755525741722;10.0
567
+ Uruguay;Maize;1990;18510.0;1300.0;7.474777854531529;16.91
568
+ Uruguay;Potatoes;1990;95000.0;1300.0;7.474777854531529;16.91
569
+ Uruguay;Rice, paddy;1990;44474.0;1300.0;7.474777854531529;16.91
570
+ Uruguay;Sorghum;1990;22680.0;1300.0;7.474777854531529;16.91
571
+ Uruguay;Soybeans;1990;12982.0;1300.0;7.474777854531529;16.91
572
+ Uruguay;Sweet potatoes;1990;57857.0;1300.0;7.474777854531529;16.91
573
+ Uruguay;Wheat;1990;18510.0;1300.0;7.474777854531529;16.91
574
+ Zambia;Cassava;1990;62040.0;1020.0;6.985641817639208;21.43
575
+ Zambia;Maize;1990;14316.0;1020.0;6.985641817639208;21.43
576
+ Zambia;Potatoes;1990;90000.0;1020.0;6.985641817639208;21.43
577
+ Zambia;Rice, paddy;1990;9664.0;1020.0;6.985641817639208;21.43
578
+ Zambia;Sorghum;1990;4042.0;1020.0;6.985641817639208;21.43
579
+ Zambia;Soybeans;1990;8986.0;1020.0;6.985641817639208;21.43
580
+ Zambia;Sweet potatoes;1990;54000.0;1020.0;6.985641817639208;21.43
581
+ Zambia;Wheat;1990;43938.0;1020.0;6.985641817639208;21.43
582
+ Zimbabwe;Cassava;1990;39916.0;657.0;8.653121708640482;21.19
583
+ Zimbabwe;Maize;1990;17206.0;657.0;8.653121708640482;21.19
584
+ Zimbabwe;Potatoes;1990;158974.0;657.0;8.653121708640482;21.19
585
+ Zimbabwe;Rice, paddy;1990;23400.0;657.0;8.653121708640482;21.19
586
+ Zimbabwe;Sorghum;1990;6836.0;657.0;8.653121708640482;21.19
587
+ Zimbabwe;Soybeans;1990;20689.0;657.0;8.653121708640482;21.19
588
+ Zimbabwe;Sweet potatoes;1990;21538.0;657.0;8.653121708640482;21.19
589
+ Zimbabwe;Wheat;1990;58211.0;657.0;8.653121708640482;21.19
5_Notebooks/mlruns/2/models/m-7d0b2bca11e140be907efb132e749af8/artifacts/model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee985276707b479db2f000d76455b7c48c0a72704218f7b373ae576eeeee50dd
3
+ size 28419612
8_Tests/test_functional.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Test fonctionnel pour l'API FastAPI de prédiction ML.
3
+ Ce test démarre réellement le serveur et fait une vraie requête HTTP sur /health.
4
+ """
5
+
6
+ import subprocess
7
+ import time
8
+ import sys
9
+ import httpx
10
+ import signal
11
+ import os
12
+
13
+
14
+ def wait_for_server(url: str, timeout: int = 30) -> bool:
15
+ """Attend que le serveur soit prêt."""
16
+ start_time = time.time()
17
+ while time.time() - start_time < timeout:
18
+ try:
19
+ response = httpx.get(url, timeout=2)
20
+ if response.status_code == 200:
21
+ return True
22
+ except httpx.RequestError:
23
+ pass
24
+ time.sleep(0.5)
25
+ return False
26
+
27
+
28
+ def run_functional_tests():
29
+ """Exécute le test fonctionnel sur l'endpoint /health."""
30
+
31
+ base_url = "http://127.0.0.1:7860"
32
+ server_process = None
33
+
34
+ try:
35
+ # Démarrer le serveur uvicorn
36
+ print("🚀 Démarrage du serveur uvicorn...")
37
+ server_process = subprocess.Popen(
38
+ ["uvicorn", "main:app", "--host", "127.0.0.1", "--port", "7860"],
39
+ stdout=subprocess.PIPE,
40
+ stderr=subprocess.PIPE,
41
+ preexec_fn=os.setsid
42
+ )
43
+
44
+ # Attendre que le serveur soit prêt
45
+ print("⏳ Attente du serveur...")
46
+ if not wait_for_server(f"{base_url}/health"):
47
+ print("❌ Le serveur n'a pas démarré dans le délai imparti")
48
+ return False
49
+
50
+ print("✅ Serveur démarré avec succès")
51
+
52
+ # ============================================
53
+ # TEST: Endpoint /health
54
+ # ============================================
55
+ print("\n📋 Test fonctionnel: Endpoint /health")
56
+
57
+ response = httpx.get(f"{base_url}/health")
58
+ assert response.status_code == 200, f"Expected 200, got {response.status_code}"
59
+
60
+ data = response.json()
61
+ assert data["status"] == "ok", f"Expected status 'ok', got {data['status']}"
62
+ assert data["model_loaded"] is True, "Model should be loaded"
63
+ assert "available_items" in data, "Clé 'available_items' absente"
64
+ assert "available_areas" in data, "Clé 'available_areas' absente"
65
+ assert data["available_items"] > 0, "Should have items"
66
+ assert data["available_areas"] > 0, "Should have areas"
67
+
68
+ print(f" ✅ Status: {data['status']}")
69
+ print(f" ✅ Modèle chargé: {data['model_loaded']}")
70
+ print(f" ✅ Cultures disponibles: {data['available_items']}")
71
+ print(f" ✅ Pays disponibles: {data['available_areas']}")
72
+
73
+ # ============================================
74
+ # Résultat final
75
+ # ============================================
76
+ print("\n" + "=" * 50)
77
+ print("🎉 TEST FONCTIONNEL /health RÉUSSI !")
78
+ print("=" * 50)
79
+
80
+ return True
81
+
82
+ except AssertionError as e:
83
+ print(f"\n❌ ÉCHEC DU TEST: {e}")
84
+ return False
85
+ except Exception as e:
86
+ print(f"\n❌ ERREUR: {e}")
87
+ return False
88
+ finally:
89
+ # Arrêter le serveur
90
+ if server_process:
91
+ print("\n🛑 Arrêt du serveur...")
92
+ os.killpg(os.getpgid(server_process.pid), signal.SIGTERM)
93
+ server_process.wait()
94
+
95
+
96
+ if __name__ == "__main__":
97
+ success = run_functional_tests()
98
+ sys.exit(0 if success else 1)
99
+
100
+
101
+
Dockerfile ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Dockerfile_api pour Hugging Face Spaces
2
+ FROM python:3.11-slim AS builder
3
+
4
+ # Créer un utilisateur non-root (requis par HF Spaces)
5
+ RUN useradd -m -u 1000 user
6
+
7
+ # Définir le répertoire de travail
8
+ WORKDIR /app
9
+
10
+ # Copier les fichiers de dépendances
11
+ COPY --chown=user requirements_api.txt .
12
+
13
+ # Installer les dépendances
14
+ RUN pip install --no-cache-dir --upgrade pip && \
15
+ pip install --no-cache-dir -r requirements_api.txt
16
+
17
+ # Copier le code de l'application
18
+ COPY --chown=user main.py .
19
+ COPY --chown=user config.py .
20
+ COPY --chown=user 2_Data_transformed/crop_yield_2_train_set_simplified.csv ./2_Data_transformed/
21
+ COPY --chown=user 5_Notebooks/mlruns/2/models/m-7d0b2bca11e140be907efb132e749af8/artifacts/model.pkl ./4_Model/
22
+ COPY --chown=user 8_Tests/test_functional.py ./8_Tests/
23
+
24
+ # ============================================
25
+ # Stage de test : exécution des tests fonctionnels
26
+ # ============================================
27
+ FROM builder AS test
28
+
29
+ # Installer les dépendances de test
30
+ RUN pip install --no-cache-dir httpx
31
+
32
+ # Copier le fichier de tests fonctionnels
33
+ COPY --chown=user 8_Tests/test_functional.py .
34
+
35
+ # Exécuter le test fonctionnel sur /health (démarre le serveur et fait une vraie requête HTTP)
36
+ RUN python test_functional.py
37
+
38
+ # ============================================
39
+ # Stage de production
40
+ # ============================================
41
+ FROM builder AS production
42
+
43
+ # Changer vers l'utilisateur non-root
44
+ USER user
45
+
46
+ # Exposer le port 7860 (port par défaut de HF Spaces)
47
+ EXPOSE 7860
48
+
49
+ # Variables d'environnement
50
+ ENV PYTHONUNBUFFERED=1
51
+
52
+ # Commande de démarrage
53
+ CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]
54
+
README.md CHANGED
@@ -1,10 +1,15 @@
1
  ---
2
- title: Oc Mlops Projet 4 Api
3
- emoji: 📚
4
- colorFrom: purple
5
- colorTo: indigo
6
  sdk: docker
7
  pinned: false
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
1
  ---
2
+ title: Agritech Answers - API
3
+ emoji: 🚀
4
+ colorFrom: yellow
5
+ colorTo: purple
6
  sdk: docker
7
  pinned: false
8
  ---
9
 
10
+ # oc_mlops_projet_4
11
+
12
+ ## Getting started
13
+
14
+ To make it easy for you to get started with GitLab, here's a list of recommended next steps.
15
+
config.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Définition de la séparation de la Timeseries en Train et Test sets pour les différents modèles de prédiction
2
+ YEAR_THRESHOLD = 2009
3
+
4
+ # Colonnes attendues par le modèle (features brutes)
5
+ FEATURE_COLUMNS = ["Area", "Item", "Year", "average_rain_fall_mm_per_year", "pesticides_tonnes", "avg_temp"]
6
+ TARGET_COLUMN = "hg/ha_yield"
7
+
8
+ # Chemin relatif vers le modèle MLflow (pipeline sklearn complet avec préprocesseur)
9
+ MODEL_REL_PATH = "5_Notebooks/mlruns/2/models/m-7d0b2bca11e140be907efb132e749af8/artifacts"
10
+
11
+ # Chemin relatif vers le fichier d'entraînement nettoyé
12
+ DATA_REL_PATH = "2_Data_transformed/crop_yield_2_train_set_simplified.csv"
13
+
main.py ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ API REST FastAPI pour les prédictions de rendement agricole.
3
+
4
+ Cette API charge un modèle MLflow (pipeline sklearn) au démarrage et expose des endpoints
5
+ pour effectuer des prédictions de rendement (hg/ha) à partir de variables explicatives.
6
+ """
7
+
8
+ import os
9
+ from contextlib import asynccontextmanager
10
+ from typing import Dict, List
11
+
12
+ import joblib
13
+ import numpy as np
14
+ import logfire
15
+ import pandas as pd
16
+ from dotenv import load_dotenv
17
+ from fastapi import FastAPI, HTTPException
18
+ from pydantic import BaseModel, Field
19
+
20
+ from config import FEATURE_COLUMNS, TARGET_COLUMN, MODEL_REL_PATH, DATA_REL_PATH
21
+
22
+ # Charger les variables d'environnement depuis .env
23
+ load_dotenv()
24
+
25
+ # =======================================================================================================
26
+ # Configuration Logfire (cloud)
27
+ # =======================================================================================================
28
+
29
+ logfire.configure(
30
+ token=os.environ.get("LOGFIRE_TOKEN"),
31
+ service_name="crop-yield-api",
32
+ send_to_logfire="if-token-present",
33
+ )
34
+
35
+ # =======================================================================================================
36
+ # Chemins et variables globales
37
+ # =======================================================================================================
38
+
39
+ BASE_DIR = os.path.dirname(os.path.abspath(__file__))
40
+
41
+ # Chemin vers le modèle MLflow (pipeline sklearn complet avec préprocesseur)
42
+ MODEL_PATH = os.path.join(BASE_DIR, MODEL_REL_PATH)
43
+
44
+ # Chemin vers le fichier d'entraînement nettoyé (pour récupérer les cultures et pays disponibles)
45
+ DATA_PATH = os.path.join(BASE_DIR, DATA_REL_PATH)
46
+
47
+ # Variables globales chargées au démarrage
48
+ pipeline = None # Pipeline sklearn (préprocesseur + modèle)
49
+ available_items: List[str] = [] # Cultures disponibles
50
+ available_areas: List[str] = [] # Pays disponibles
51
+ available_items_per_area: Dict[str, List[str]] = {} # Cultures disponibles par pays
52
+
53
+ # =======================================================================================================
54
+ # Chargement des ressources au démarrage
55
+ # =======================================================================================================
56
+
57
+ def load_pipeline():
58
+ """Charge le pipeline sklearn depuis le fichier model.pkl."""
59
+ try:
60
+ model_file = os.path.join(MODEL_PATH, "model.pkl")
61
+ model = joblib.load(model_file)
62
+ logfire.info("Pipeline chargé avec succès depuis {path}", path=model_file)
63
+ return model
64
+ except Exception as e:
65
+ logfire.error("Erreur lors du chargement du pipeline: {error}", error=str(e))
66
+ return None
67
+
68
+
69
+ def load_training_data():
70
+ """Charge le CSV d'entraînement pour récupérer les listes de cultures et pays."""
71
+ try:
72
+ df = pd.read_csv(DATA_PATH, sep=";", usecols=["Item", "Area"])
73
+
74
+ missing_columns = {"Item", "Area"} - set(df.columns)
75
+ if missing_columns:
76
+ raise ValueError(
77
+ f"Colonnes manquantes dans le fichier d'entraînement: {sorted(missing_columns)}"
78
+ )
79
+
80
+ items = sorted(df["Item"].dropna().unique().tolist())
81
+ areas = sorted(df["Area"].dropna().unique().tolist())
82
+
83
+ # Construire le mapping cultures par pays
84
+ items_area_map = {}
85
+ for area in areas:
86
+ area_items = sorted(df[df["Area"] == area]["Item"].dropna().unique().tolist())
87
+ items_area_map[area] = area_items
88
+
89
+ logfire.info("Données d'entraînement chargées: {n_items} cultures, {n_areas} pays", n_items=len(items), n_areas=len(areas))
90
+ return items, areas, items_area_map
91
+ except FileNotFoundError:
92
+ logfire.error("Fichier de données introuvable: {path}", path=DATA_PATH)
93
+ return [], [], {}
94
+ except Exception as e:
95
+ logfire.error("Erreur lors du chargement des données: {error}", error=str(e))
96
+ return [], [], {}
97
+
98
+
99
+ @asynccontextmanager
100
+ async def lifespan(app: FastAPI):
101
+ """Chargement des ressources au démarrage de l'API."""
102
+ global pipeline, available_items, available_areas, available_items_per_area
103
+ pipeline = load_pipeline()
104
+ available_items, available_areas, available_items_per_area = load_training_data()
105
+ logfire.info("API initialisée et prête")
106
+ yield
107
+ logfire.info("API arrêtée")
108
+
109
+
110
+ # =======================================================================================================
111
+ # Initialisation de l'application FastAPI + instrumentation Logfire
112
+ # =======================================================================================================
113
+
114
+ app = FastAPI(
115
+ title="API de Prédiction de Rendement Agricole",
116
+ description="API pour prédire le rendement agricole (hg/ha) en fonction de la culture, du pays, de l'année et de variables climatiques.",
117
+ version="1.0.0",
118
+ lifespan=lifespan,
119
+ )
120
+
121
+ logfire.instrument_fastapi(app)
122
+
123
+ # =======================================================================================================
124
+ # Modèles Pydantic pour la validation des entrées / sorties
125
+ # =======================================================================================================
126
+
127
+
128
+ class PredictInput(BaseModel):
129
+ """Données d'entrée pour une prédiction de rendement avec culture spécifiée."""
130
+
131
+ Area: str = Field(..., description="Pays (ex: 'France', 'Albania')")
132
+ Item: str = Field(..., description="Culture (ex: 'Wheat', 'Maize')")
133
+ Year: int = Field(..., ge=1990, le=2040, description="Année")
134
+ average_rain_fall_mm_per_year: float = Field(..., ge=40, le=4000, description="Précipitations moyennes annuelles (mm)")
135
+ pesticides_tonnes: float = Field(..., ge=0, le=400000, description="Quantité de pesticides utilisés (tonnes)")
136
+ avg_temp: float = Field(..., gt=0, le=35, description="Température moyenne (°C)")
137
+
138
+
139
+ class PredictionOutput(BaseModel):
140
+ """Résultat d'une prédiction de rendement."""
141
+
142
+ Area: str = Field(..., description="Pays")
143
+ Item: str = Field(..., description="Culture")
144
+ Year: int = Field(..., description="Année")
145
+ predicted_yield: float = Field(..., description="Rendement prédit (hg/ha)")
146
+
147
+
148
+ class RecommendInput(BaseModel):
149
+ """Données d'entrée pour la recommandation de cultures (sans Item)."""
150
+
151
+ Area: str = Field(..., description="Pays (ex: 'France', 'Albania')")
152
+ Year: int = Field(..., ge=1990, le=2040, description="Année")
153
+ average_rain_fall_mm_per_year: float = Field(..., ge=40, le=4000, description="Précipitations moyennes annuelles (mm)")
154
+ pesticides_tonnes: float = Field(..., ge=0, le=400000, description="Quantité de pesticides utilisés (tonnes)")
155
+ avg_temp: float = Field(..., gt=0, le=35, description="Température moyenne (°C)")
156
+
157
+
158
+ class RecommendOutput(BaseModel):
159
+ """Résultat de la recommandation : prédictions pour toutes les cultures, triées par rendement décroissant."""
160
+
161
+ area: str
162
+ year: int
163
+ recommendations: List[PredictionOutput]
164
+ status: str = "success"
165
+
166
+
167
+ # =======================================================================================================
168
+ # Endpoints
169
+ # =======================================================================================================
170
+
171
+
172
+ @app.get("/health")
173
+ def health_check():
174
+ """Vérification de l'état de santé de l'API."""
175
+ logfire.info("Health check")
176
+ return {
177
+ "status": "ok",
178
+ "model_loaded": pipeline is not None,
179
+ "available_items": len(available_items),
180
+ "available_areas": len(available_areas),
181
+ }
182
+
183
+
184
+ @app.get("/columns")
185
+ def get_columns():
186
+ """Retourne la liste des colonnes (features) attendues par le modèle."""
187
+ logfire.info("Colonnes demandées")
188
+ return {
189
+ "columns": FEATURE_COLUMNS,
190
+ "target": TARGET_COLUMN,
191
+ "available_items": available_items,
192
+ "available_areas": available_areas,
193
+ "available_items_per_area": available_items_per_area,
194
+ }
195
+
196
+
197
+ @app.post("/predict", response_model=PredictionOutput)
198
+ def predict(input_data: PredictInput):
199
+ """
200
+ Prédiction de rendement pour une culture et un ensemble de variables explicatives.
201
+ """
202
+ logfire.info(
203
+ "Requête /predict reçue: {area} / {item} / {year}",
204
+ area=input_data.Area,
205
+ item=input_data.Item,
206
+ year=input_data.Year,
207
+ )
208
+
209
+ if pipeline is None:
210
+ logfire.error("Pipeline non chargé")
211
+ raise HTTPException(status_code=503, detail="Modèle non chargé. Réessayez plus tard.")
212
+
213
+ # Validation métier : vérifier que le pays est connu
214
+ if input_data.Area not in available_areas:
215
+ raise HTTPException(
216
+ status_code=422,
217
+ detail=f"Pays '{input_data.Area}' inconnu. Consultez GET /columns pour la liste des pays.",
218
+ )
219
+
220
+ # Validation métier : vérifier que la culture est produite dans le pays sélectionné
221
+ if input_data.Item not in available_items_per_area.get(input_data.Area, []):
222
+ available_for_area = available_items_per_area.get(input_data.Area, [])
223
+ raise HTTPException(
224
+ status_code=422,
225
+ detail=f"Culture '{input_data.Item}' non produite dans '{input_data.Area}'. Cultures disponibles pour ce pays : {available_for_area}",
226
+ )
227
+
228
+ try:
229
+ df = pd.DataFrame([input_data.model_dump()])
230
+ # Appliquer la transformation log1p sur pesticides_tonnes (cohérence avec l'EDA / entraînement)
231
+ df["pesticides_tonnes"] = np.log1p(df["pesticides_tonnes"])
232
+ prediction = pipeline.predict(df)[0]
233
+
234
+ logfire.info("Prédiction effectuée: {yield_pred:.2f} hg/ha", yield_pred=float(prediction))
235
+
236
+ return PredictionOutput(
237
+ Area=input_data.Area,
238
+ Item=input_data.Item,
239
+ Year=input_data.Year,
240
+ predicted_yield=round(float(prediction), 2),
241
+ )
242
+ except Exception as e:
243
+ logfire.error("Erreur lors de la prédiction: {error}", error=str(e))
244
+ raise HTTPException(status_code=400, detail=str(e))
245
+
246
+
247
+ @app.post("/recommend", response_model=RecommendOutput)
248
+ def recommend(input_data: RecommendInput):
249
+ """
250
+ Recommandation de cultures : prédit le rendement pour les cultures disponibles
251
+ dans le pays sélectionné et les renvoie classées par rendement décroissant.
252
+ """
253
+ logfire.info(
254
+ "Requête /recommend reçue: {area} / {year}",
255
+ area=input_data.Area,
256
+ year=input_data.Year,
257
+ )
258
+
259
+ if pipeline is None:
260
+ logfire.error("Pipeline non chargé")
261
+ raise HTTPException(status_code=503, detail="Modèle non chargé. Réessayez plus tard.")
262
+
263
+ if input_data.Area not in available_areas:
264
+ raise HTTPException(
265
+ status_code=422,
266
+ detail=f"Pays '{input_data.Area}' inconnu. Consultez GET /columns pour la liste des pays.",
267
+ )
268
+
269
+ area_items = available_items_per_area.get(input_data.Area, [])
270
+ if not area_items:
271
+ raise HTTPException(
272
+ status_code=422,
273
+ detail=f"Aucune culture disponible pour le pays '{input_data.Area}'.",
274
+ )
275
+
276
+ try:
277
+ # Construire un DataFrame avec une ligne par culture disponible dans le pays
278
+ base_data = input_data.model_dump()
279
+ rows = []
280
+ for item in area_items:
281
+ row = {**base_data, "Item": item}
282
+ rows.append(row)
283
+
284
+ df = pd.DataFrame(rows)
285
+ # Appliquer la transformation log1p sur pesticides_tonnes (cohérence avec l'EDA / entraînement)
286
+ df["pesticides_tonnes"] = np.log1p(df["pesticides_tonnes"])
287
+ predictions = pipeline.predict(df)
288
+
289
+ # Associer chaque culture à sa prédiction et trier par rendement décroissant
290
+ results = [
291
+ PredictionOutput(Area=input_data.Area, Item=item, Year=input_data.Year, predicted_yield=round(float(pred), 2))
292
+ for item, pred in zip(area_items, predictions)
293
+ ]
294
+ results.sort(key=lambda x: x.predicted_yield, reverse=True)
295
+
296
+ logfire.info(
297
+ "Recommandation effectuée: meilleure culture = {best} ({yield_pred:.2f} hg/ha)",
298
+ best=results[0].Item,
299
+ yield_pred=results[0].predicted_yield,
300
+ )
301
+
302
+ return RecommendOutput(area=input_data.Area, year=input_data.Year, recommendations=results)
303
+
304
+ except Exception as e:
305
+ logfire.error("Erreur lors de la recommandation: {error}", error=str(e))
306
+ raise HTTPException(status_code=400, detail=str(e))
307
+
requirements_api.txt ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ─── API FastAPI ───────────────────────────────────────────────────────────────
2
+ fastapi>=0.104.0
3
+ uvicorn[standard]>=0.24.0
4
+ pydantic>=2.0.0
5
+ python-multipart>=0.0.6
6
+
7
+ # ─── Données & ML ─────────────────────────────────────────────────────────────
8
+ numpy>=1.24.0
9
+ pandas>=2.0.0
10
+ scikit-learn>=1.3.0
11
+ joblib>=1.3.0
12
+
13
+ # ─── Observabilité ────────────────────────────────────────────────────────────
14
+ logfire[fastapi]>=0.40.0
15
+
16
+ # ─── Configuration ────────────────────────────────────────────────────────────
17
+ python-dotenv>=1.0.0
18
+
19
+ # ─── Tests ────────────────────────────────────────────────────────────────────
20
+ pytest>=8.0.0
21
+ httpx>=0.27.0