Code Monkey home page Code Monkey logo

Comments (9)

bdwilliamson avatar bdwilliamson commented on June 3, 2024

Thanks for using the package!

I'm unclear what you mean by "arbitrary prediction functions" -- the Super Learner does allow you to use a wide variety of candidate prediction functions (you can see all of them using SuperLearner::listWrappers()), and you can use single algorithms in vimp::sp_vim by specifying a single character value (e.g., SL.library = "SL.glm"). You can also specify tuning parameters, etc. using the Super Learner; see SuperLearner::createLearner for more details.

Thanks also for looking at the python package. I'm not sure why you're having issues with setup.py (which works fine on my machine; this is really for sending to PyPI, not for installing the package locally), but I'm glad that you found a workaround.

Can you provide a minimum working example so that I can see what's going on in spvim()? I fixed the indexing and z_counts_ issue (thanks!).

from vimpy.

Tim-Re avatar Tim-Re commented on June 3, 2024

Hi thanks for the answer.

By arbitrary prediction functions, I really just meant that in Python spvim() only seems to ask for any learner with a fit and predict method, while in R one is bound to the SuperLearner framework. However as it turns out I also have underestimated the capabilities of SuperLearner.

Regarding the setup.py issue it might be worth noting that the error message did not just occur on my local computer but also on google colab. However, when installing version 2.0.2.2, which does not include 'scipy_stats' in the install_requires list, the installation worked fine. Pip also seems to check the dependencies according to the provided install_requires list and installs missing packages if necessary.
I would then imagine that it tries to install scipy.stats which throws the same error as trying to install vimpy 2.1 and should already be available through scipy.
Right now, when not specifing a version, pip automatically installs vimpy 2.0.2.2 instead of 2.1.

In colab:
!pip install vimpy==2.1 #error occurs
!pip install git+https://github.com/bdwilliamson/vimpy #error occurs
!pip install vimpy==2.0.2.2 #error does not occur

A small example for the issue with spvim() is given below. Attached is also a screenshot of the error message triggered by vimpy_obj.get_ses().

import numpy as np
import vimpy
import pkg_resources
from sklearn.linear_model import LinearRegression
pckg = pkg_resources.get_distribution("vimpy")
print(pckg.version) #2.1

def lm(n):
mean = np.zeros(3)
cov = np.eye(3)
X = np.random.default_rng().multivariate_normal(mean, cov, n)
x1 = X[:,0]
x2 = X[:,1]
x3 = X[:,2]
f = x1 + 2*x2 - x3
y = f + np.random.normal(0,1,n)
return y, X

y,x = lm(1000)
model = LinearRegression()
vimpy_obj = vimpy.spvim(y = y, x = x, V = 5, pred_func = model, measure_type = "r_squared")

vimpy_obj.get_point_est()
vimpy_obj.get_influence_functions()
vimpy_obj.get_ses()
vimpy_obj.get_cis()

image

from vimpy.

bdwilliamson avatar bdwilliamson commented on June 3, 2024

Thanks for the MWE. I've just completed a patch that should solve your issue (on GitHub, not PyPI yet). Please let me know if you're still seeing problems!

from vimpy.

Tim-Re avatar Tim-Re commented on June 3, 2024

Thanks for the ammendments. Unfortunately using the MWE from above (or the example on the vimpy git page) there seems to be another error in get_ses() for var_s = np.nanvar(shapley_ics['contrib_s'][idx, :]) in vimpy/spvim_ic.py line 50.

image

from vimpy.

bdwilliamson avatar bdwilliamson commented on June 3, 2024

I'm not getting that error when I use the latest version of the package on GitHub. Can you try updating vimpy using python -m pip install git+https://github.com/bdwilliamson/vimpy.git@aef6b90dbaa77d9a9dce9a45b4786b37a294c36c and re-running the MWE?

from vimpy.

Tim-Re avatar Tim-Re commented on June 3, 2024

I've reinstalled the version of the most recent commit hash on both my local machine as well as on colab. The error unfortunately persists. What seems odd to me is that the .dtype attribute is different between contrib_s and contrib_v (see image below). I've also tried different versions of numpy which did not help.

image

from vimpy.

bdwilliamson avatar bdwilliamson commented on June 3, 2024

Ok I've made the dtypes of the two the same (should both be float64). I've also bumped the version number to 2.1.1, so you should be able to confirm that this version is installed. Other than that, I'm not sure how to help, since I'm not seeing any errors when running the MWE on my machine (Python 3.8).

from vimpy.

Tim-Re avatar Tim-Re commented on June 3, 2024

Thanks a lot for the efforts and the quick responses! After the dtype change it now works.

(As a small final and hopefully not annoying sidenote: in get_cis() the interval is assigned to self.ci_, however, under init it is self.cis_ so the confidence intervals are not returned in the end.)

from vimpy.

bdwilliamson avatar bdwilliamson commented on June 3, 2024

Thank you for your help finding these bugs! I really appreciate your patience. Just fixed that last bug as well, I'll try to get a release to PyPI soon.

from vimpy.

Related Issues (4)

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.