|
27 | 27 | }, |
28 | 28 | { |
29 | 29 | "cell_type": "code", |
30 | | - "execution_count": null, |
| 30 | + "execution_count": 1, |
31 | 31 | "metadata": {}, |
32 | 32 | "outputs": [], |
33 | 33 | "source": [ |
|
36 | 36 | "from rectools.models import (\n", |
37 | 37 | " ImplicitItemKNNWrapperModel, \n", |
38 | 38 | " ImplicitALSWrapperModel, \n", |
| 39 | + " ImplicitBPRWrapperModel, \n", |
39 | 40 | " EASEModel, \n", |
40 | 41 | " PopularInCategoryModel, \n", |
41 | 42 | " PopularModel, \n", |
|
329 | 330 | "- \"ItemItemRecommender\"\n", |
330 | 331 | "- A path to a class (including any custom class) that can be imported. Like \"implicit.nearest_neighbours.TFIDFRecommender\"\n", |
331 | 332 | "\n", |
332 | | - "Specify wrapped model hyper-params under the \"model.params\" key" |
| 333 | + "Specify wrapped model hyper-params under the \"model\" dict relevant keys." |
333 | 334 | ] |
334 | 335 | }, |
335 | 336 | { |
|
381 | 382 | "\n", |
382 | 383 | "Specify which model you want to wrap under the \"model.cls\" key. Since there is only one default model, you can skip this step. \"implicit.als.AlternatingLeastSquares\" will be used by default. Also you can pass a path to a class (including any custom class) that can be imported.\n", |
383 | 384 | "\n", |
384 | | - "Specify wrapped model hyper-params under the \"model.params\" key. \n", |
| 385 | + "Specify wrapped model hyper-params under the \"model\" dict relevant keys. \n", |
385 | 386 | "\n", |
386 | | - "Specify wrapper hyper-params under relevant keys." |
| 387 | + "Specify wrapper hyper-params under relevant config keys." |
387 | 388 | ] |
388 | 389 | }, |
389 | 390 | { |
|
440 | 441 | "model.get_params(simple_types=True)" |
441 | 442 | ] |
442 | 443 | }, |
| 444 | + { |
| 445 | + "cell_type": "markdown", |
| 446 | + "metadata": {}, |
| 447 | + "source": [ |
| 448 | + "### BPR-MF\n", |
| 449 | + "`ImplicitBPRWrapperModel` is a wrapper. \n", |
| 450 | + "Use \"model\" key in config to specify wrapped model class and params: \n", |
| 451 | + "\n", |
| 452 | + "Specify which model you want to wrap un\\der the \"model.cls\" key. Since there is only one default model, you can skip this step. \"implicit.bpr.BayesianPersonalizedRanking\" will be used by default. Also you can pass a path to a class (including any custom class) that can be imported.\n", |
| 453 | + "\n", |
| 454 | + "Specify wrapped model hyper-params under the \"model\" dict relevant keys. \n", |
| 455 | + "\n", |
| 456 | + "Specify wrapper hyper-params under relevant config keys." |
| 457 | + ] |
| 458 | + }, |
| 459 | + { |
| 460 | + "cell_type": "code", |
| 461 | + "execution_count": 12, |
| 462 | + "metadata": {}, |
| 463 | + "outputs": [], |
| 464 | + "source": [ |
| 465 | + "config = {\n", |
| 466 | + " \"model\": {\n", |
| 467 | + " # \"cls\": \"BayesianPersonalizedRanking\", # will work too\n", |
| 468 | + " # \"cls\": \"implicit.bpr.BayesianPersonalizedRanking\", # will work too\n", |
| 469 | + " \"factors\": 16,\n", |
| 470 | + " \"num_threads\": 2,\n", |
| 471 | + " \"iterations\": 2,\n", |
| 472 | + " \"random_state\": 32\n", |
| 473 | + " },\n", |
| 474 | + " \"recommend_use_gpu_ranking\": False,\n", |
| 475 | + "}\n", |
| 476 | + "model = ImplicitBPRWrapperModel.from_config(config)" |
| 477 | + ] |
| 478 | + }, |
| 479 | + { |
| 480 | + "cell_type": "code", |
| 481 | + "execution_count": 13, |
| 482 | + "metadata": {}, |
| 483 | + "outputs": [ |
| 484 | + { |
| 485 | + "data": { |
| 486 | + "text/plain": [ |
| 487 | + "{'cls': 'ImplicitBPRWrapperModel',\n", |
| 488 | + " 'verbose': 0,\n", |
| 489 | + " 'model.cls': 'BayesianPersonalizedRanking',\n", |
| 490 | + " 'model.factors': 16,\n", |
| 491 | + " 'model.learning_rate': 0.01,\n", |
| 492 | + " 'model.regularization': 0.01,\n", |
| 493 | + " 'model.dtype': 'float64',\n", |
| 494 | + " 'model.iterations': 2,\n", |
| 495 | + " 'model.verify_negative_samples': True,\n", |
| 496 | + " 'model.random_state': 32,\n", |
| 497 | + " 'model.use_gpu': True,\n", |
| 498 | + " 'recommend_n_threads': None,\n", |
| 499 | + " 'recommend_use_gpu_ranking': False}" |
| 500 | + ] |
| 501 | + }, |
| 502 | + "execution_count": 13, |
| 503 | + "metadata": {}, |
| 504 | + "output_type": "execute_result" |
| 505 | + } |
| 506 | + ], |
| 507 | + "source": [ |
| 508 | + "model.get_params(simple_types=True)" |
| 509 | + ] |
| 510 | + }, |
443 | 511 | { |
444 | 512 | "cell_type": "markdown", |
445 | 513 | "metadata": {}, |
|
535 | 603 | "\n", |
536 | 604 | "Specify which model you want to wrap under the \"model.cls\" key. Since there is only one default model, you can skip this step. \"LightFM\" will be used by default. Also you can pass a path to a class (including any custom class) that can be imported. Like \"lightfm.lightfm.LightFM\"\n", |
537 | 605 | "\n", |
538 | | - "Specify wrapped model hyper-params under the \"model.params\" key. \n", |
| 606 | + "Specify wrapped model hyper-params under the \"model\" dict relevant keys. \n", |
539 | 607 | "\n", |
540 | | - "Specify wrapper hyper-params under relevant keys." |
| 608 | + "Specify wrapper hyper-params under relevant config keys." |
541 | 609 | ] |
542 | 610 | }, |
543 | 611 | { |
|
736 | 804 | } |
737 | 805 | ], |
738 | 806 | "metadata": { |
| 807 | + "kernelspec": { |
| 808 | + "display_name": "rectools", |
| 809 | + "language": "python", |
| 810 | + "name": "rectools" |
| 811 | + }, |
739 | 812 | "language_info": { |
740 | | - "name": "python" |
| 813 | + "codemirror_mode": { |
| 814 | + "name": "ipython", |
| 815 | + "version": 3 |
| 816 | + }, |
| 817 | + "file_extension": ".py", |
| 818 | + "mimetype": "text/x-python", |
| 819 | + "name": "python", |
| 820 | + "nbconvert_exporter": "python", |
| 821 | + "pygments_lexer": "ipython3", |
| 822 | + "version": "3.9.12" |
741 | 823 | } |
742 | 824 | }, |
743 | 825 | "nbformat": 4, |
|
0 commit comments