Is there a way to calculate the explained variance (eigenvalues) from scikit learn's MDS? I've seen this thread, but I think scikit learn's MDS is a "non-classical" form of MDS, so I'm guessing it wouldn't work? Is there a way to compute the explained variance from running scikit learn's implementation of MDS?
Also, if I'm using a precomputed dissimilarity matrix for scikit learn's MDS, is it then running classical MDS? Based on the code it seems like it's still running the SMACOF algorithm regardless (rather than eigendecomposition)?
Related
my inputs are feature vectors, and my outputs/targets are floats between 0 and 1 for training.
I am familiar that XGBRFRegressor and XGBRegressor are capable of this, but I am seeking logistic regression equivalent rather than using gradient boosting. I guess I could manually do the log transformations turning it into a standard linear regression problem, but seeking to see if there is already a solution for this.
Thanks,
Will
I solved this by transforming to linear scale then training using any regression method, and then transforming back with a log transformation.
see an example at how to use sklearn when target variable is a proportion
This might be a stupid question but I was just wondering what the difference between ML-KNN implemented in scikit.ml and scikit-learn's KNeighborsClassifier is. According to sklearn's docs KNeighborsClassifier has support for multilabel classification. ML-KNN however is KNN adapted for multilabel classification built on top of sklearn's architecture based on it's docs.
When searching for sample multilabel problems, MLkNN mostly appears but I do not understand if there's any advantage of using it over the base implementation of sklearn if it already supports it. Is it only a late adaptation in sklearn's side or are there more differences in the implementation?
Any input is appreciated. Thanks!
scikit-multilearn's ML-KNN implementations is an improved version of scikit-learn's KNeighborsClassifier. It is actually built on top of it. After the k nearest neighbors in the training data are found, it uses maximum a posteriori principle to label a new instance to achieve a better performance. Also, since it operates on sparse matrices internally using SciPy sparse matrix library, it is highly memory-efficient. More info here and here.
I know this one: Find p-value (significance) in scikit-learn LinearRegression
I've never extended a class in python and I'm not sure whether this is the right solution for me (I've tried but getting a TypeError). I'm calculating an elastic net regression with scikitlearn. Since my regressors are in a sparse matrix, Statsmodels package is not an option. Thus, I'm looking for a reliable solution to calculate p-values for each coefficient in my elastic net regression. Is there a solution given by scikitlearn nowadays?
Is there any automated way to evaluate convergence of the SGDClassifier?
I'm trying to run an elastic net logit in python and am using scikit learn's SGDClassifier with log loss and elastic net penalty. When I fit the model in python, I get all zeros for my coefficients. When I run glmnet in R, I get significant non-zero coefficients.
After some twiddling I found that the scikit learn coefficients approach the R coefficients after around 1000 iterations.
Is there any method that I'm missing in scikit learn to iterate until the change in coefficients is relatively small (or a max amount of iterations has been performed), or do I need to do this myself via cross-validation.
This a known limitation of the current implementation of scikit-learn's SGD classifier, there is currently no automated convergence check on that model. You can set verbose=1 to get some feedback when running though.
I am trying to fit vector autoregressive (VAR) models using the generalized linear model fitting methods included in scikit-learn. The linear model has the form y = X w, but the system matrix X has a very peculiar structure: it is block-diagonal, and all blocks are identical. To optimize performance and memory consumption the model can be expressed as Y = BW, where B is a block from X, and Y and W are now matrices instead of vectors.
The classes LinearRegression, Ridge, RidgeCV, Lasso, and ElasticNet readily accept the latter model structure. However, fitting LassoCV or ElasticNetCV fails due to Y being two-dimensional.
I found https://github.com/scikit-learn/scikit-learn/issues/2402
From this discussion I assume that the behavior of LassoCV/ElasticNetCV is intended.
Is there a way to optimize the alpha/rho parameters other than manually implementing cross-validation?
Furthermore, Bayesian regression techniques in scikit-learn also expect y to be one-dimensional. Is there any way around this?
Note: I use scikit-learn 0.14 (stable)
How crucial is the performance and memory optimization gained by using this formulation of the regression? Given that your reformulation breaks scikit-learn, I wouldn't really call it an optimization... I would suggest:
Running the unoptimized version and waiting (if possible).
Git pull the following code, which supposedly solves your problem. It's referenced in the conversation you posted from the scikit-learn github project. See here for instructions on building scikit-learn from a git pull. You can then add the branched scikit-learn location to your python path and execute your regression using the modified library code. Be sure to post your experiences and any issues you encounter; I'm sure the scikit developers would appreciate it.
To predict matrices instead of vectors there is for Lasso and ElasticNet their MultiTask* counterpart:
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskLasso.html
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskElasticNet.html