Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use as.class type functionality to replace epidist_prepare #73

Closed
athowes opened this issue Jun 6, 2024 · 7 comments · Fixed by #125
Closed

Use as.class type functionality to replace epidist_prepare #73

athowes opened this issue Jun 6, 2024 · 7 comments · Fixed by #125
Assignees
Labels
question Further information is requested

Comments

@athowes
Copy link
Collaborator

athowes commented Jun 6, 2024

Goal

We may want to consider as.class, is.class, validate.class, functionality either in addition to our epidist_prepare methods or somehow replacing. The options are:

  1. Replace
  2. Addition
  3. Don't add

I do not have a very clear picture about whether I prefer 1. or 2. or 3. at the moment and would need to think about it more.

Additional

As a part of this PR I think we should fix the "no warnings on default" due to abuse of the .default #82.

Related documents

@athowes athowes added the question Further information is requested label Jun 6, 2024
@athowes athowes mentioned this issue Jun 6, 2024
9 tasks
@athowes athowes changed the title Consider as.class type functionality with or replacing prepare Consider as.class type functionality with or replacing epidist_prepare Jun 6, 2024
@athowes athowes self-assigned this Jun 6, 2024
@seabbs
Copy link
Contributor

seabbs commented Jun 6, 2024

I think we want 1. probably

  1. lets us have something that converts from a common data format but also interesting enables converting from one model data format to another which could be useful.

If we did keep both its unclear to me what prepare would also do.

@athowes
Copy link
Collaborator Author

athowes commented Jun 10, 2024

@seabbs on call:

  • This adds the ability to convert between different data formats
  • "i.e as_latent.delay_model would be a s3 method to map from a "delay_model" to the latent model"
  • Do what is standard unless there is a reason not to
  • Call validate when you put it into new functions at the start and also at the end of the conversion
  • See example in scoringutils

@seabbs
Copy link
Contributor

seabbs commented Jun 11, 2024

Here is some info on potential problems with a manual validate_ function: epiforecasts/scoringutils#816

@seabbs
Copy link
Contributor

seabbs commented Jun 11, 2024

Do what is standard unless there is a reason not to

If I had a bigger forehead I might get this tattooed

@athowes
Copy link
Collaborator Author

athowes commented Jun 11, 2024

If I had a bigger forehead I might get this tattooed

Male pattern baldness could make this feature more attainable within our current roadmap

@seabbs
Copy link
Contributor

seabbs commented Jun 11, 2024

Judging by my family we are in luck

@athowes athowes changed the title Consider as.class type functionality with or replacing epidist_prepare Use as.class type functionality to replace epidist_prepare Jun 12, 2024
@athowes
Copy link
Collaborator Author

athowes commented Jun 20, 2024

@seabbs here are my preliminary designs for the new functions:

as_latent_individual <- function(...) {
  UseMethod("as_latent_individual")
}
 
as_latent_individual.default <- function(data) {
  NULL
  # Takes data as input
  # Outputs an object of class latent_individual
  # The default one would take in data
  # Other ones could take in other model data formats
  # Advanced R suggests a constructor and a helper but I think we might just
  # want this single as function
}

validate_latent_individual <- function() {
  # Checks that the object of class latent_individual has the correct properties
  # Should be put in the top of any function that uses such objects
  # Also put it at the end of as_latent_individual methods
}

Let me know what you think.

  • Add is_latent_variable using inherits function (see scoringutils)
  • Get rid of prepare_epidist default
  • Could have no default and require data.frame or data.table
    • All data.table are data.frame (as with tibble)
  • Either be from scratch, with checkmate, or with coercedt (probably with checkmate)
  • This PR should also have unit tests and documentation (all from now on)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants