diff --git a/README.md b/README.md index 5a307ff..47ef4ef 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # eindex -Multidimensional indexing for tensors +Concept of multidimensional indexing for tensors ## Example of K-means clustering @@ -23,9 +23,8 @@ def kmeans(init_centers, X, n_iterations: int): clusters = np.argmin(d, axis=0) new_centers_sum = np.zeros_like(centers) clstr_indices = np.tile(clusters[:, None], reps=(1, n_dim)) - dim___indices = np.tile(np.arange(n_dim)[None, :], - reps=(n_onservations, 1)) - np.add.at(new_centers_sum, (clstr_indices, dim___indices), X) + dim_indices = np.tile(np.arange(n_dim)[None, :], reps=(n_onservations, 1)) + np.add.at(new_centers_sum, (clstr_indices, dim_indices), X) cluster_counts = np.bincount(clusters, minlength=n_clusters) centers = new_centers_sum / cluster_counts[:, None] return centers @@ -40,7 +39,7 @@ def kmeans_eindex(init_centers, X, n_iterations: int): for _ in range(n_iterations): d = cdist(centers, X) clusters = EX.argmin(d, 'cluster i -> [cluster] i') - centers = EX.scatter('i c, [cluster] i -> cluster c', X, clusters, + centers = EX.scatter(X, clusters, 'i c, [cluster] i -> cluster c', agg='mean', cluster=len(centers)) return centers ``` diff --git a/tutorial/data.py b/tutorial/data.py index 783737a..6f56d99 100644 --- a/tutorial/data.py +++ b/tutorial/data.py @@ -16,9 +16,9 @@ def __init__(self): "Yoda", "Alice", "Gandalf", - "R. Daneel Olivaw", + "Harry Potter-Verres", "Devola & Popola", - # "Harry James Potter-Evans-Verres", + # "R. Daneel Olivaw", # Aerith, # Aloy, ] diff --git a/tutorial/tutorial.ipynb b/tutorial/tutorial.ipynb index 1074d8d..4ebbd8f 100644 --- a/tutorial/tutorial.ipynb +++ b/tutorial/tutorial.ipynb @@ -109,7 +109,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
Amber, City Center
\n", "
Amber, City Center
\n", @@ -173,6 +173,13 @@ "data.visualize(data.travels, '[world, place] hero year month', cols='hero', rows='year month')" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Important:** If above does not look like a table, but more like a list, you need to rerun notebook, or trust the notebook." + ] + }, { "cell_type": "code", "execution_count": 5, @@ -1401,7 +1408,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
2020
\n", " August
\n", @@ -1684,7 +1691,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
2020
\n", "
2021
\n", @@ -1749,7 +1756,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
2020
\n", "
2021
\n", @@ -1788,7 +1795,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
\n", "
-18.1
\n", @@ -1857,7 +1864,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
2020
\n", " August
\n", @@ -2642,7 +2649,7 @@ "
Yoda
\n", "
Alice
\n", "
Gandalf
\n", - "
Harry James Potter-Evans-Verres
\n", + "
Harry Potter-Verres
\n", "
Devola & Popola
\n", "
\n", "
2
\n",