xlearn icon indicating copy to clipboard operation
xlearn copied to clipboard

xlearn from Juyter notebook

Open znavoyan opened this issue 6 years ago • 10 comments

Hi. I'm trying to run xlearn's demo python code from Jupyter notebook. The code runs with no problem from python interpreter. However when I try to run it from the notebook, the notebook's kernel crashes on the linear_model.fit(param, './model.out') line with the following error : Kernel Restarting The kernel appears to have died. It will restart automatically.

Before that line, the following code ran without any problem import xlearn as xl

# Training task linear_model = xl.create_linear() # Use linear model linear_model.setTrain("./agaricus_train.txt") # Training data linear_model.setValidate("./agaricus_test.txt") # Validation data

# param: # 0. Binary classification # 1. learning rate: 0.2 # 2. lambda: 0.002 # 3. evaluation metric: accuarcy # 4. Use sgd optimization method param = {'task':'binary', 'lr':0.2, 'lambda':0.002, 'metric':'acc', 'opt':'sgd'}

Can you please advise, what can be the problem and how to fix it? I use xlearn version '0.2.0', which I cloned from git.

Thank you, Zaven.

znavoyan avatar Feb 23 '18 14:02 znavoyan

seems that I can run it successfully on jupyter 4.3.0 and Python 3. What's your environment?

randxie avatar Feb 23 '18 16:02 randxie

I use Jupyter 4.3.0 and python 3.6.3. I understand what was the problem. There was a 'model.out' file already created using root. But the jupyter works under my account, which has no privileges to overwrite the old file. After creating model from the notebook it was trying to overwrite the old model and failed. I deleted the old 'model.out' file and it started working.

However, there is still other issue: all output from xlearn functions are shown in OS console (the output from jupyterhub command) but not in jupyter notebook. For example output of training process, ffm_model.show() or ffm_model.predict() functions shows nothing in the notebook. Can you please advise how can I see output of the functions in my notebook?

znavoyan avatar Feb 26 '18 11:02 znavoyan

@znavoyan For now, xLearn can only print message to console. We will update it to show message in notebook as soon as possible.

aksnzhy avatar Mar 02 '18 06:03 aksnzhy

I have a similar problem. Kernel restarts as soon as I execute ffm_model.fit(param, "model.out") in Ubuntu14.04 and Python3.5.2

ahmedahmedov avatar Apr 11 '18 11:04 ahmedahmedov

I have the same problem, I have tried on kaggle kernels, google colab, it's failing everywhere. What to do?

deepakgupta1 avatar Nov 16 '18 14:11 deepakgupta1

I also have the same problem , but it resets when I call the model.predict() method.

ravirammamidi avatar Nov 07 '19 12:11 ravirammamidi

Xlearn c++ code uses multi-threading, so while accessing the hardware it need the user variable in the environment. And because if c compiler version issue the init_log() parameter is empty. So we have to initialize it by ourselves. So basically write user = 'Test' before the command. Or if you are running the python package of xlearn set os.environ['USER'] = 'test'

bipinkc19 avatar Jan 31 '20 11:01 bipinkc19

the kernel restarting issue is not resolved with os.environ['USER'] = 'test'.
env: Ubuntu 18.04.2 LTS and Ubuntu 18.04.2 LTS

heyx97 avatar Feb 03 '20 00:02 heyx97

just updating my comments from yesterday. it looks like the issue was that the data sets cannot be found in the "current" directory set in the original code. the code runs ok after the directory is reset to explicitly point to the directory holding the sample data.

heyx97 avatar Feb 03 '20 18:02 heyx97

Wow; I faced the same error today. Turns out I'm not alone. I have been working directly through scripts right now, looks easier.

kanodiaayush avatar Feb 03 '21 09:02 kanodiaayush