-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ISM returns now a dictionary. ISM's input is now a list of 2D arrays. Completed README with simulation example.
- Loading branch information
1 parent
9dc2484
commit 381ece8
Showing
6 changed files
with
160 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
__pycache__/ | ||
example/.ipynb_checkpoints/ | ||
adilsm.egg-info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"Relative error: 0.08\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"import adilsm.adilsm as ilsm\n", | ||
"import pandas as pd\n", | ||
"import numpy as np\n", | ||
"\n", | ||
"max_noise_level = 0.01\n", | ||
"# Generate a random non-negative matrix with 100 rows and 10 columns\n", | ||
"A = np.random.rand(100, 10)\n", | ||
"# Swap the columns of the A and add some noise to generate B\n", | ||
"B = np.random.permutation(A.T).T + np.random.uniform(low=0, high=max_noise_level, size=A.shape)\n", | ||
"# Add noise to A\n", | ||
"A += np.random.uniform(low=0, high=max_noise_level, size=A.shape)\n", | ||
"\n", | ||
"# ISM is expected to recognize that A and B convey the same information up to some noise, albeit with the columns of B swapped around.\n", | ||
"\n", | ||
"m0 = np.hstack((A, B))\n", | ||
"\n", | ||
"n_items = [A.shape[1], B.shape[1]]\n", | ||
"n_scores = len(n_items)\n", | ||
"n_embedding, n_themes = [10,10]\n", | ||
"\n", | ||
"h4_updated, h4_updated_sparse, w4_ism, h4_ism, q4_ism, tensor_score, m0_norm = ilsm.ism(m0, n_embedding, n_themes, n_scores, n_items, norm_m0=False, update_h4_ism=True,\n", | ||
" max_iter_mult=200, sparsity_coeff=.8)\n", | ||
"error = np.linalg.norm(m0 - w4_ism @ h4_updated_sparse.T) / np.linalg.norm(m0)\n", | ||
"print('Relative error: ',round(error, 2))\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.0" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
|
||
setup( | ||
name="adilsm", | ||
version='0.0.7', | ||
version='0.0.8', | ||
author="Mazars", | ||
author_email="[email protected]", | ||
description=f"{description}", | ||
|