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

Can not run examples given by notebooks #12

Closed
Yutong-Dai opened this issue Jul 18, 2018 · 5 comments
Closed

Can not run examples given by notebooks #12

Yutong-Dai opened this issue Jul 18, 2018 · 5 comments

Comments

@Yutong-Dai
Copy link

Greetings,

I can not reproduce notebooks given in the ./notebooks. For example, run code given in the Real World MERF Examples notebook thrower out two errors.

When I tried to import the modules, the first error popped out

No module named 'merf.evaluator'

When I tried to call mrf.fit(X_train, Z_train, clusters_train, y_train), the error popped out

ValueError: operands could not be broadcast together with shapes (10,) (162,)

I also attached the full information below FYI.
BTW, I installed the merf using pip install merf. It should be the latest version.

Any suggestion is appreciated.

ValueError Traceback (most recent call last)
in ()
13 clusters_train = train['Subject']
14 y_train = train['Reaction']
---> 15 mrf.fit(X_train, Z_train, clusters_train, y_train)
16
17 # Mixed Effects Random Forest Test

~/anaconda/lib/python3.6/site-packages/merf/merf.py in fit(self, X, Z, clusters, y)
142
143 # Compute y_star for this cluster and put back in right place
--> 144 y_star_i = y_i - Z_i.dot(b_hat_i)
145 y_star[indices_i] = y_star_i
146

~/anaconda/lib/python3.6/site-packages/pandas/core/ops.py in wrapper(left, right, name, na_op)
713 lvalues = lvalues.values
714
--> 715 result = wrap_results(safe_na_op(lvalues, rvalues))
716 return construct_result(
717 left,

~/anaconda/lib/python3.6/site-packages/pandas/core/ops.py in safe_na_op(lvalues, rvalues)
674 try:
675 with np.errstate(all='ignore'):
--> 676 return na_op(lvalues, rvalues)
677 except Exception:
678 if isinstance(rvalues, ABCSeries):

~/anaconda/lib/python3.6/site-packages/pandas/core/ops.py in na_op(x, y)
650 try:
651 result = expressions.evaluate(op, str_rep, x, y,
--> 652 raise_on_error=True, **eval_kwargs)
653 except TypeError:
654 if isinstance(y, (np.ndarray, ABCSeries, pd.Index)):

~/anaconda/lib/python3.6/site-packages/pandas/computation/expressions.py in evaluate(op, op_str, a, b, raise_on_error, use_numexpr, **eval_kwargs)
208 if use_numexpr:
209 return _evaluate(op, op_str, a, b, raise_on_error=raise_on_error,
--> 210 **eval_kwargs)
211 return _evaluate_standard(op, op_str, a, b, raise_on_error=raise_on_error)
212

~/anaconda/lib/python3.6/site-packages/pandas/computation/expressions.py in _evaluate_numexpr(op, op_str, a, b, raise_on_error, truediv, reversed, **eval_kwargs)
119
120 if result is None:
--> 121 result = _evaluate_standard(op, op_str, a, b, raise_on_error)
122
123 return result

~/anaconda/lib/python3.6/site-packages/pandas/computation/expressions.py in _evaluate_standard(op, op_str, a, b, raise_on_error, **eval_kwargs)
61 _store_test_result(False)
62 with np.errstate(all='ignore'):
---> 63 return op(a, b)
64
65

ValueError: operands could not be broadcast together with shapes (10,) (162,)

@resdntalien
Copy link
Contributor

@Rothdyt Thanks for the heads up. I will take a look at this when I get a chance. Not sure about this -- it still works when I pip install it. You're using Python3 and the pandas in the requirements file?

@Yutong-Dai
Copy link
Author

@resdntalien Hi, version info is provided below.

"Python"
version: "3.6.3 64bit [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]"

module: "merf"
version: "0.2"

module: "pandas"
version: "0.23.3"

Thanks.

@mahernadar
Copy link

Hello there :)
I am also having the same problem with the merf.evaluator module:
Thank you for your time.

error:

ModuleNotFoundError Traceback (most recent call last)
in ()
14 from merf.merf import MERF
15 from sklearn.model_selection import train_test_split, KFold
---> 16 from merf.evaluator import plot_bhat, plot_training_stats

ModuleNotFoundError: No module named 'merf.evaluator'

@resdntalien
Copy link
Contributor

For merf evaluator I think you have to import like so: import merf.merf.evaluator when pip installing. I usually run this inside my Docker dev environment which has the path set a little differently so the import works more simply.

@JayeSJY
Copy link

JayeSJY commented Dec 8, 2020

Hello,

I have the same issue and "import merf.merf.evaluator" is not working either. :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants