Giter Site home page Giter Site logo

imputation's People

Contributors

jeffwong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

imputation's Issues

Error: "new columns would leave holes"

Hi Jeff,

I am a statistics PhD student at CMU. This package looks great, however I cannot get it to run on my data due to the following error.

Error in [<-.data.frame(*tmp*, remove.indices, value = NA) :
new columns would leave holes after existing columns

It seems as though the NAs are being replaced with a character string and this is creating problems?

Error: kNNImpute() fails if only 1 row contains missing

Hi,

in the special case that only 1 row contains missing values, kNNImpute() returns:
"Error in apply(x.missing, 1, function(i) { :
dim(X) must have a positive length")

As far as I can see, the sub-function impute.prelim() is responsible in line
prelim = impute.prelim(x).

If more than 2 rows contain missing, this function returns a matrix for impute.prelim()$x.missing.
If only 1 row contains missings, it returns a named vector, which later on can not be handled by the apply-function
t(apply(x.missing, 1, function(i) {

My suggestion was to test, if inserting the drop=FALSE option at the end of function impute.prelim() solves the problem:
if (byrow)
x.missing = cbind(1:nrow(x), x)[missing.rows.indices, ,drop=FALSE ]
else x.missing = rbind(1:ncol(x), x)[, missing.cols.indices ,drop=FALSE]

Thanks for reading :)

implement cross imputation

If a missing value is located at row i, column j, use all information in both row i and column j to impute.
In a sense use both horizontal neighbors and vertical neighbors

for n large pdist creates too much overhead

when using kNNImpute, pdist is called once for each row that has missing data. Too many calls to pdist can cause lots of overhead because of the transfer to C. One larger dist call is likely to be faster than many pdist calls

R dimension dropping leads to bugs in imputation

Hi,

here is a simple example

x = matrix(rnorm(100),10,10)
x[1,1] = NA
meanImpute(x)

error:
Error in apply(x.missing, 2, function(j) { :
dim(X) must have a positive length

traceback()
7: stop("dim(X) must have a positive length")
6: apply(x.missing, 2, function(j) {
bad.indices = which(is.na(j))
j[bad.indices] = mean(j[-1], na.rm = T)
j[-1]
})
5: meanImpute(x) at preprocess.R#40
4: eval(expr, envir, enclos)
3: eval(ei, envir)
2: withVisible(eval(ei, envir))
1: source("../comparison_study/preprocess.R")

Fix:

You are not telling R to avoid dropping dimension in impute.prelim

if (byrow)
x.missing = cbind(1:nrow(x), x)[missing.rows.indices,
]
else x.missing = rbind(1:ncol(x), x)[, missing.cols.indices]

Add a drop = FALSE.
Also I don't really see the need for adding a 1:n row or column, but i didnt bother to look up whether this is useful for you.

Bernd

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.