8000 TypeError: only size-1 arrays can be converted to Python scalars (Windows, Python 3.5) · Issue #26 · anttttti/Wordbatch · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

TypeError: only size-1 arrays can be converted to Python scalars (Windows, Python 3.5) #26

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

Open
nikrepp opened this issue Jun 29, 2018 · 1 comment

Comments

@nikrepp
Copy link
nikrepp commented Jun 29, 2018

Hello,

I run the following code with WordBatch on windows:

import wordbatch
from wordbatch.extractors import WordBag
from wordbatch.models import FTRL, FM_FTRL
import pandas as pd
import pandas as pd
import numpy as np
from sklearn.datasets import make_moons

X, y = make_moons(n_samples=10000, noise=0.7)
from sklearn.model_selection import train_test_split
X_t, X_v, y_t, y_v = train_test_split(X, y, stratify=y, test_size=0.2, random_state=8)

train_weight = np.array(pd.DataFrame(y_t).replace(1,400).replace(0,1).astype('float64'))

clf = FM_FTRL(alpha=0.5, beta=1, L1=10.0, L2=10.0, D=2 * 20, alpha_fm=0.02,
L2_fm=0.0, init_fm=0.01, weight_fm=1.0,
D_fm=2, e_noise=0.0, iters=3,
inv_link="sigmoid", threads=4
)

clf.fit(X_t, y_t, train_weight)
class_pred = clf.predict(X_v)

I get the following error:

TypeError Traceback (most recent call last)
in ()
---> 30 clf.fit(X_t, y_t, train_weight)
31 class_pred = clf.predict(X_v)

wordbatch\models\fm_ftrl.pyx in wordbatch.models.fm_ftrl.FM_FTRL.fit()

TypeError: only size-1 arrays can be converted to Python scalars

It appears only when WEIGHT is used.

Do you know possible cause?

Thanks,
Nikita

@anttttti
Copy link
Owner

Can you give more details?
This doesn't reproduce on Ubuntu 16.04, Python 3.6.4 |Anaconda custom (64-bit), Numpy 1.14.2 and WB 1.35. The model trains fine with this setup.

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

No branches or pull requests

2 participants
0