Giter Site home page Giter Site logo

sizemat's Introduction

sizemat's People

Contributors

ejosymart avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

sizemat's Issues

classify_mature() - Function assigns adults as juveniles

Dear Josymar Torrejon-Magallanes,

I am currently trying to undertake some size of maturity analysis on some Whelk data, I am trying to classify the juveniles from adults using the classify_mature() function. However when plotting the results the PCA seems to deem the smaller individuals as Adults and the larger ones of Juveniles. A screen shot is below: (x = total shell length, y = penis length)

screen shot 2019-02-05 at 14 45 14

the call of classify_mature():

screen shot 2019-02-05 at 14 45 22

Is there a solution to this issue??

Allow manual creation of `classify` objects

It might be useful to allow for the case where maturity has been determined elsewehere (not via classify_mature()) but the size at maturity still needs to be calculated via morph_mature() (guess who had this use case today?).

Prototype:

manual_classify <- function(x, y, mature) {
   mat_data <- data.frame(x = x, y = y, mature = mature)
   class(mat_data)  <- c("classify", class(mat_data))
   return(mat_data)
}

If there's nothing else that I'm missing (in terms of interacting with other functions) then sure, it's simple enough, but appending a specific class to a data.frame isn't something that every user will know how to do (correctly) to satisfy morph_mature()'s requirement.

Apologies if I've missed any existing implementation.

Excessive memory usage and clean-ups

The new_data list in .morph_mature_fq() stores an excessive amount of data. It retains the entire list of niter re-samples despite these only being required in the glm on the line following, within the same loop.

new_data[[i]] <- data[sample(nrow(data), nrow(data), replace = T), ]

This quickly used up available memory when the input data was large and the default number of iterations were used.

I suggest the following replacement:

set.seed(seed)
n_coef <- list()
for(i in seq_len(niter)) {
  new_data   <- data[sample(nrow(data), replace = TRUE), ]
  model_boot <- glm(mature ~ x, data = new_data, family = binomial(link = "logit"))
  glm_coef   <- coef(model_boot)
  n_coef     <- rbind(glm_coef, n_coef)
}

I also recommend updating 1:niter to seq_len(niter) which better handles the niter = 0 case (not explicitly forbidden, good practice in any case), and using TRUE rather than T. sample by default takes size to be the "number of items inferred from the first argument", which expands to 1:nrow(data), so the second nrow(data) is redundant.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.