Skip to content

ValueError: Unable to coerce to Series, length must be 1: given 2854 #59

Description

@wasifmasood

Hi,
I have found your approach to mixed effects modeling very appealing and therefore wanted to try my data which is about network traffic prediction, a very valuable and in demand use case. But unfortunately, I am encoutering the following error with full stack trace, can you please help me in finding the source of the problem:


ValueError                                Traceback (most recent call last)
<ipython-input-293-b5c7b2f082a6> in <module>
      1 mrf = MERF(max_iterations=500)
----> 2 mrf.fit(X_train_merf, Z_train, clusters_train, y_train)

C:\ProgramData\Anaconda3\envs\shared\lib\site-packages\merf\merf.py in fit(self, X, Z, clusters, y, X_val, Z_val, clusters_val, y_val)
    209 
    210                 # Compute y_star for this cluster and put back in right place
--> 211                 y_star_i = y_i - Z_i.dot(b_hat_i)
    212                 y_star[indices_i] = y_star_i
    213 

C:\ProgramData\Anaconda3\envs\shared\lib\site-packages\pandas\core\ops\__init__.py in f(self, other, axis, level, fill_value)
    645         # TODO: why are we passing flex=True instead of flex=not special?
    646         #  15 tests fail if we pass flex=not special instead
--> 647         self, other = _align_method_FRAME(self, other, axis, flex=True, level=level)
    648 
    649         if isinstance(other, ABCDataFrame):

C:\ProgramData\Anaconda3\envs\shared\lib\site-packages\pandas\core\ops\__init__.py in _align_method_FRAME(left, right, axis, flex, level)
    472 
    473         if right.ndim == 1:
--> 474             right = to_series(right)
    475 
    476         elif right.ndim == 2:

C:\ProgramData\Anaconda3\envs\shared\lib\site-packages\pandas\core\ops\__init__.py in to_series(right)
    463         else:
    464             if len(left.columns) != len(right):
--> 465                 raise ValueError(
    466                     msg.format(req_len=len(left.columns), given_len=len(right))
    467                 )

ValueError: Unable to coerce to Series, length must be 1: given 2854

Here is the my git repo where you can find the complete example
https://github.com/wasifmasood/network_traffic_forecast/blob/master/MERF.ipynb

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions