Addition of Google Map API , Trees and Train data and End points for the same.
This MR addresses issue #18 (closed) , #16 (closed) ,#15 (closed) .
- This includes data for trees from extension , db script for it and the endpoint for it.
- Trains data also has been added to the raw data and the db script for the same has been made.
- The trains route and trees route has been added to the routes handler.
- Documentation and test cases has been updated accordingly.
Merge request reports
Activity
65 65 for (let i = 0; i < numOfComponents; i++) { 66 66 if(item.components[i].quantity.length > 1){ 67 67 let getInterpolatedQuantity = await interpolate(item.quantity, item.components[i].quantity, quantity); 68 console.log(`Interpolated value = ${getInterpolatedQuantity}`) 68 console.log(`Interpolated value = ${getInterpolatedQuantity}`); Everpolate is something that we had in mind , for polynomial interpolation. How ever it does not support extrapolation and the kind of data it takes in the extrapolation example is not supported in our schema. And the linear regression offered in this library has been essentially implemented in our function. http://borischumichev.github.io/everpolate/#poly
Extrapolation, doesn't matter what method you use, is always ambiguous. Now, there is a difference between linear interpolation and linear regression. Linear interpolation finds a point between two points joined by a straight line. Whereas, Linear regression finds a point on a straight line whose slope depends on many points.
See the picture below. The brown line is the linear regression of the data represented by blue circles. Whereas linear interpolation would be joining each consecutive point with a straight line(a polynomial). The second picture shows polynomial interpolation. Clearly, polynomial is more accurate than regression. So, I think it's better to go with polynomial interpolation if the data lies in between. I would also like @bruno-wp to share his views.
Edited by Chirag Arora@heychirag we just did some calculations using polynomial interpolation and the results are really bad. Have a look at https://runkit.com/embed/rjcp7jlnzk0i. I think we need to have more data points to get the results that are actually useful.
Here is the linear interpolation result for reference. https://runkit.com/embed/9qpyhf7lppy7
So the method in the 2nd figure is not actually polynomial interpolation. Sorry for this. It's actually more closer to either
spline
orpchip
interpolation. The following interpolated results have been calculated using MATLAB for the same data set and test point(2720).- linear interpolation: 14789.68
- spline interpolation: 14794.34
- pchip interpolation: 14794.22
- linear regression: 14899.14
pchip
andspline
can be well used for extrapolation too.The best method depends on the type of data we are dealing with. If we are dealing with data about which we are certain is a non-linear function, then it is better to go with
spline
orpchip
. Here is a good answer that differentiates when to use interpolation and when to use regression.So if we decide to stick with regression, then I would suggest you to change all the function names because it's quite misleading.
Edited by Chirag Arora@heychirag we are actually using linear interpolation and not linear regression.
Linear Regression yields some inaccurate values in the lower range even: https://runkit.com/embed/3xjfg2cfrrz5
And the linear regression offered in this library has been essentially implemented in our function.
With reference to above, I was under the impression that we were were using linear regression.
So if we are using
linear
interpolation, then I would recommend to instead go forspline
orpchip
interpolation. You can clearly see the difference betweenspline
/pchip
andlinear
interpolation.Edited by Chirag Arora
101 101 obj.region="Default"; 102 102 obj.quantity=[1]; 103 103 obj.unit="kg"; 104 obj.categories=["flights"]; 104 obj.categories=["flights","transport"]; The idea here is that this piece of data should belong both to the "flights" category and to the "transport" category.
On the one hand, this makes sense, since flights are a form of transport.
On the other hand, I wonder if adding both the category and its super-categories in all pieces of data that belong to that category is an efficient way to organize the sub-categorization information. It seems redundant. It should suffice to describe once that "flights" is a sub-category of "transport".
This is not a new problem in computer science. There is whole field of research concerned about this. Google "Ontology", "Decription Logics", and so on...
Anyway, these concerns are a little bit beyond the scope of our project for now. So, choose whatever feels more natural for you, and let's worry about this later only if it becomes a problem.
- raw_data/trains.json 0 → 100644
9 "quantity" : [1], 10 "unit" : "kg/km", 11 "M.F.(multiply factor)" : 443 12 }, 13 "frieght" : { 14 "C02" : 0.0191, 15 "NO2" : 0, 16 "CH4" : 0, 17 "region" : "Default", 18 "category" : "transport", 19 "method" : "simple", 20 "quantity" : [1], 21 "unit" : "kg/km", 22 "M.F.(multiply factor)" : 1225 23 }, 24 "intercités" : { changed this line in version 2 of the diff
- raw_data/trains.json 0 → 100644
31 "quantity" : [1], 32 "unit" : "kg/km", 33 "M.F.(multiply factor)" : 992 34 }, 35 "tgv" : { 36 "C02" : 0.0032, 37 "NO2" : 0, 38 "CH4" : 0, 39 "region" : "France", 40 "category" : "transport", 41 "method" : "simple", 42 "quantity" : [1], 43 "unit" : "kg/km", 44 "M.F.(multiply factor)" : 516 45 }, 46 "tgv lyria" : { changed this line in version 2 of the diff
Hi @Everyone! Just a general comment, as I haven't had time to look into this MR in detail yet. I noticed that this MR addresses several issues (and quite unrelated issues: trains, trees, ...). I strongly recommend that, in the future, you try to submit smaller MRs, and one MR per issue. This has several advantages, including the following:
-
it reduces MR reviewing and acceptance time
-
if you submit a single MR for two issues, a good solution for one of the issues might be blocked, if the MR gets stuck because the reviewers think that it doesn't solve the other issue properly. If 2 separate MRs had been submitted, the one containing the good solution could be accepted quickly.
-
the ability to submit separate and independent MRs is also an indication that your code is modular and capable of scaling independently in different directions. If you only submit big MRs that solve several issues at once, this may be an indication that your code is becoming too monolithic, with interdependencies that prevent independent MRs.
-
- raw_data/trains.json 0 → 100644
174 "quantity" : [1], 175 "unit" : "kg/km", 176 "M.F.(multiply factor)" : 425 177 }, 178 "railcars india" : { 179 "C02" : 0.0412, 180 "NO2" : 0, 181 "CH4" : 0, 182 "region" : "India", 183 "category" : "transport", 184 "method" : "simple", 185 "quantity" : [1], 186 "unit" : "kg/km", 187 "M.F.(multiply factor)" : 1240 188 }, 189 "freight india" : { changed this line in version 3 of the diff
104 100 }); 105 101 } 106 102 107 exports.calculate = async function(a, b, c){ 103 exports.calculate = async function(a, b, c, d = 1){ changed this line in version 5 of the diff
- raw_data/trains.json 0 → 100644
1 { 2 "railcars" : { 3 "C02" : 0.0412, 4 "NO2" : 0, 5 "CH4" : 0, 6 "region" : "Default", 7 "category" : "transport", 8 "method" : "simple", 9 "quantity" : [1], 10 "unit" : "kg/km", 11 "M.F.(multiply factor)" : 443 12 }, 13 "frieght" : { changed this line in version 5 of the diff
added 1 commit
- 1ad26e63 - added tree test case , changed freight spelling and controller parameter names
added 19 commits
-
1ad26e63...fc0287ee - 18 commits from branch
aossie:master
- 08c994ce - mr11 merge conflicts resolved
-
1ad26e63...fc0287ee - 18 commits from branch
@bruno-wp @Kolpa @heychirag The merge conflicts are resolved and the changed required are incorporated.
mentioned in commit c05ea726