Cluster one-dimensional data optimally? [closed] - r

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Does anyone have a paper that explains how the Ckmeans.1d.dp algorithm works?
Or: what is the most optimal way to do k-means clustering in one-dimension?

Univariate k-means clustering can be solved in O(kn) time (on already sorted input) based on theoretical results on Monge matrices, but the approach was not popular most likely due to numerical instability and also perhaps coding challenges.
A better option is an O(knlgn) method that is now implemented in Ckmeans.1d.dp version 3.4.6. This implementation is as fast as heuristic k-means but offers guaranteed optimality, orders of magnitude better than heuristic k-means especially for large k's.
The generic dynamic programming solution by Richard Bellman (1973) does not touch upon specifics of the k-means problem and the implied runtime is O(kn^3).

Related

Group-based trajectory modelling in R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 9 months ago.
Improve this question
I've been looking for a way to conduct group-based trajectory modeling in R with no avail. Something along the lines of what PROC TRAJ (http://www.andrew.cmu.edu/user/bjones/index.htm) accomplishes in SAS. Does anyone know of a similar package in R?
My outcome of interest (the model input) is categorical so i need something that can handle that.
The only package I've been able to find for this in R is crimCV. Here it is on Cran, and here is a working paper by the authors of the package on how it's done. I have not yet investigated this myself (and it seems like it hasn't been updated for years), but this page describes using it to fit a set of trajectories.

Is there a way to inform classifiers in R of the relative costs of misclassification? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
This is a general question. Are there classifiers in R -- functions that perform classification implementing classification algorithms-- that accept as input argument the relative cost of misclassification. E.g. if a misclassification of a positive to negative has cost 1 the opposite has cost 3.
If yes which are these functions?
Yes. If you are using the caret package (you should; it provides 'standardization' for 200+ classification and regression methods by wrapping almost all relevant R's packages), you can set the weights argument of the train function (see p.152; see also here) for models that support class weights. This answer lists some of the models that support class weights.

glmnet algorithm in a different programming language [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm trying use linear regression with elastic net penalties for a mixed model. In the past I have used the R glmnet package with the penalty.factors parameter to accomplish this, but R is no longer an option for my project. I have found several implementations of elastic net in different languages, but none which allow for different penalty factors for each feature the way that the R glmnet package does.
Does a true translation of the R glmnet function exist in any other language? Thanks!
EDIT: Note that the R code is actually a wrapper of the FORTRAN code written for the R package. A few other wrappers exist in other languages, but I am looking for an new implementation of the full algorithm, not just an alternative wrapper. I want to be able to edit the code a bit, but I am not at all familiar with FORTRAN.
I would have put this in comments if I had enough points, but there is an implementation in Matlab, written by a few members of the team that wrote the original glmnet package:
http://web.stanford.edu/~hastie/glmnet_matlab/

Implementing pathfinding in R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for an existing package that provides pathfinding algorithms for 2d data. I have a regular grid with scores and would like to start out with the A* algorithm.
I am surprised that there doesn't seem to be an R package dealing with such a task (obviously, googling for "a* algorithm in R" gives very unspecific results).
Does anyone know of an existing package and if there is none, can point me towards an efficient way of implementing the algorithm in R?
Thanks!
There is e1071 and igraph. Not sure if they do A*, but they seem to have other shortest past algorithms.

Is there any Genetic Programming code written R [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm interesting in evolutionary algorithms. I have tested genetic algorithms with R but has someone tried with genetic programming? Do you know, if there are code somewhere written in R.
I'm not aware of anything on CRAN for genetic programming in particular, although there is some work being done on the problem. In particular, have a look at the RGP package that is still in development.
Otherwise, have a look at the RFreak package, which is a wrapper for the "Free Evolutionary Algorithm Kit".
You might want to have a look at genalg, at GA and at galgo
There is a new package available:gramEvol: Grammatical Evolution for R
A native R implementation of grammatical evolution (GE). GE
facilitates the discovery of programs that can achieve a desired goal.
This is done by performing an evolutionary optimisation over a
population of R expressions generated via a user-defined context-free
grammar (CFG) and cost function.
You can find the vignette here:Grammatical Evolution: A Tutorial using gramEvol
UPDATE: I posted an article on my blog about it:
Symbolic Regression, Genetic Programming… or if Kepler had R.

Resources