verbal-autopsy-software / tariff Goto Github PK
View Code? Open in Web Editor NEWR package of Tariff method for VA
R package of Tariff method for VA
Logic is either missing or the entire statement can be removed to clean up the code.
Lines 115 to 117 in 5144ad8
The code works and is harmless in intended case but it would be a good idea to alert the user. If they inadvertently passed in the wrong dataset or something, a warning would catch it.
Lines 78 to 81 in 2324381
It appears that when you use the reported csmf from the tariff function, this is not identical to calculating it directly from the most likely COD for each test subject. Furthermore, it appears that this has to do with the naming of the items:
data("RandomVA3")
test <- RandomVA3[1:200, ]
train <- RandomVA3[201:400, ]
allcauses <- unique(train$cause)
set.seed(123)
fit <- tariff(causes.train = "cause", symps.train = train,
symps.test = test, causes.table = allcauses)
fit$csmf
prop.table(table(fit$causes.test[,2]))
You can see above that in fact the percentages are the same, but the names associated with each one are not. This is important to know which is the right way to get the CSMF, as it may confuse users.
An assumption is being made that ID is column 1. Safer to add a check first or alternatively could access by column name (this may require name to be part of the function input, though, if name may not be consistent)
Lines 74 to 77 in 2324381
The paper documenting this algorithm doesn't seem to provide the process to select significant tariffs in the first bootstrap. Can you clarify this process for us to aid in our review?
Lines 203 to 233 in 2324381
The documentation should define all variables for users who might not be familiar with the algorithms at a detailed level
Lines 10 to 12 in 2324381
Is it possible for y to be lower case here? If so, recommendation to compare using 'toUpper()' just in case.
Lines 118 to 120 in 2324381
We believe N causes is a vector here, not a matrix
Line 99 in 2324381
The paper documenting this algorithm does not provide details for the ranking process. What is the pseudocode for this part of the algorithm? At a first glance it appears this code (as well as the code leading up to calling this code) may be able to be simplified.
Lines 153 to 176 in 2324381
The name causes.table2 does not help the reader/maintainer of the code to understand its meaning. Suggestion is to rename to something more descriptive.
Lines 193 to 198 in 2324381
Although it may be harmless in the expected scenario, there is a possibility the user accidentally passed in the wrong dataset. It is never a bad idea to throw a warning to alert the user something is being deleted.
Lines 63 to 67 in 2324381
The names colindex and colindex2 could be renamed to something having to do with train and test, respectively. This would improve readability and maintainability.
Lines 54 to 55 in 2324381
The code inside the if
statement on line 323 is the same as what is outside at line 321 - is this intentional?
Lines 321 to 324 in 5144ad8
Could condense the following code to
causes.train.out <- data.frame(ID = id.train, cause = causes.train, stringsAsFactors = F)
Lines 324 to 325 in 2324381
We recommend adhering to the Tidyverse R style guide (https://style.tidyverse.org) to improve readability and consistency of code. The tidyverse style guide sums up the need for a consistent style in a particularly effective way: “Good coding style is like correct punctuation: you can manage without it, butitsuremakesthingseasiertoread.”
As the project continues to grow, particularly in an open source environment, having consistent style standards enables easy onboarding of new staff as the code can be quickly read and understood. While a specific style guide is inherently personal preference, we like the tidyverse style guide because it specifically applies to R and works with the lintR tool that can perform automated adherence checks.
Two examples where the style guide could be helpful:
Line 49 in 2324381
as.data.frame.data.frame()
.
Line 104 in 2324381
Sometimes code lines can get extremely long, and having to scroll to the right adds unnecessary complexity. Limiting line length and adding line breaks can make the code significantly easier to read. The tidyverse style guide specifically recommends:
Strive to limit your code to 80 characters per line. This fits comfortably on a printed page with a reasonably sized font […] If a function call is too long to fit on a single line, use one line each for the function name, each argument, and the closing ). This makes the code easier to read and to change later.
This mention of converting InterVA input is confusing. Should be fixed for better understanding and maintenance.
Line 296 in 2324381
The following code defines a function that is never used. Code should be removed.
Lines 179 to 182 in 2324381
It would be helpful for the user documentation to have more detailed information about what a 'TRUE' value means for use.rank in case they are not completely familiar with the algorithm.
Line 13 in 2324381
The algorithm describes taking the top 40 Tariffs, but this code seems to be setting the top 40 Tariffs to zero thereby only looking at 41 to the end
Lines 235 to 251 in 2324381
Because of the join performed at line 318, it seems that line 321 is unnecessary. There should not be anything in CSMF that is not in causes.table2
Lines 317 to 321 in 2324381
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.