Skip to content

Commit

Permalink
Updated doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
norm4nn committed Aug 17, 2024
1 parent 78e37bc commit 990ba96
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/scholar/cluster/optics.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,32 @@ defmodule Scholar.Cluster.OPTICS do
## Examples
iex> x = Nx.tensor([[1, 2], [2, 5], [3, 6], [8, 7], [8, 8], [7, 3]])
iex> Scholar.Cluster.OPTICS.fit(x, min_samples: 2)
iex> Scholar.Cluster.OPTICS.fit(x, min_samples: 2).labels
#Nx.Tensor<
s64[6]
[-1, -1, -1, -1, -1, -1]
>
iex> Scholar.Cluster.OPTICS.fit(x, eps: 4.5, min_samples: 2)
iex> Scholar.Cluster.OPTICS.fit(x, eps: 4.5, min_samples: 2).labels
#Nx.Tensor<
s64[6]
[0, 0, 0, 1, 1, 1]
>
iex> Scholar.Cluster.OPTICS.fit(x, eps: 2, min_samples: 2)
iex> Scholar.Cluster.OPTICS.fit(x, eps: 2, min_samples: 2).labels
#Nx.Tensor<
s64[6]
[-1, 0, 0, 1, 1, -1]
>
iex> Scholar.Cluster.OPTICS.fit(x, eps: 2, min_samples: 2, algorithm: :kd_tree, metric: {:minkowski, 1})
iex> Scholar.Cluster.OPTICS.fit(x, eps: 2, min_samples: 2, algorithm: :kd_tree, metric: {:minkowski, 1}).labels
#Nx.Tensor<
s64[6]
[-1, 0, 0, 1, 1, -1]
>
iex> Scholar.Cluster.OPTICS.fit(x, eps: 1, min_samples: 2)
iex> Scholar.Cluster.OPTICS.fit(x, eps: 1, min_samples: 2).labels
#Nx.Tensor<
s64[6]
[-1, -1, -1, 0, 0, -1]
>
iex> Scholar.Cluster.OPTICS.fit(x, eps: 4.5, min_samples: 3)
iex> Scholar.Cluster.OPTICS.fit(x, eps: 4.5, min_samples: 3).labels
#Nx.Tensor<
s64[6]
[0, 0, 0, 1, 1, -1]
Expand Down Expand Up @@ -134,7 +134,7 @@ defmodule Scholar.Cluster.OPTICS do
"""
end

algorithm_opts = Keyword.put(algorithm_opts, :num_neighbors, min_samples)
algorithm_opts = Keyword.put(algorithm_opts, :num_neighbors, 1)

algorithm_module =
case opts[:algorithm] do
Expand Down

0 comments on commit 990ba96

Please sign in to comment.