Skip to content

Commit ba3bc12

Browse files
committed
modify readme
1 parent 933fe1f commit ba3bc12

2 files changed

Lines changed: 38 additions & 7 deletions

File tree

README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,15 @@ def deps do
1919
end
2020
```
2121

22-
### K-Nearest Neighbours
22+
### K-Nearest Neighbours classification
2323

2424
Initialize classificator with data set consists from labels and features:
2525

2626
```elixir
2727
classificator = LearnKit.Knn.new
2828
|> LearnKit.Knn.add_train_data({:a1, [-1, -1]})
2929
|> LearnKit.Knn.add_train_data({:a1, [-2, -1]})
30-
|> LearnKit.Knn.add_train_data({:a1, [-3, -2]})
3130
|> LearnKit.Knn.add_train_data({:a2, [1, 1]})
32-
|> LearnKit.Knn.add_train_data({:a2, [2, 1]})
33-
|> LearnKit.Knn.add_train_data({:a2, [3, 2]})
34-
|> LearnKit.Knn.add_train_data({:a2, [-2, -2]})
3531
```
3632

3733
Predict label for new feature:
@@ -44,6 +40,43 @@ Predict label for new feature:
4440
algorithm - algorithm for calculation of distances, one of the [brute], optional, default - "brute"
4541
weight - method of weighted neighbors, one of the [uniform|distance], optional, default - "uniform"
4642

43+
### Gaussian Naive Bayes classification
44+
45+
Initialize classificator with data set consists from labels and features:
46+
47+
```elixir
48+
classificator = LearnKit.NaiveBayes.Gaussian.new
49+
|> LearnKit.NaiveBayes.Gaussian.add_train_data({:a1, [-1, -1]})
50+
|> LearnKit.NaiveBayes.Gaussian.add_train_data({:a1, [-2, -1]})
51+
|> LearnKit.NaiveBayes.Gaussian.add_train_data({:a2, [1, 1]})
52+
```
53+
54+
Fit data set
55+
56+
```elixir
57+
classificator = classificator |> LearnKit.NaiveBayes.Gaussian.fit
58+
```
59+
60+
Return probability estimates for the feature
61+
62+
```elixir
63+
classificator = classificator |> LearnKit.NaiveBayes.Gaussian.predict_proba([1, 2])
64+
```
65+
feature - new feature for prediction, required
66+
67+
Return exact prediction for the feature
68+
69+
```elixir
70+
classificator = classificator |> LearnKit.NaiveBayes.Gaussian.predict([1, 2])
71+
```
72+
feature - new feature for prediction, required
73+
74+
Returns the mean accuracy on the given test data and labels
75+
76+
```elixir
77+
classificator = classificator |> LearnKit.NaiveBayes.Gaussian.score
78+
```
79+
4780
## Contributing
4881

4982
Bug reports and pull requests are welcome on GitHub at https://github.com/kortirso/elixir_learn_kit.

lib/learn_kit/naive_bayes/gaussian.ex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ defmodule LearnKit.NaiveBayes.Gaussian do
155155
156156
## Examples
157157
158-
iex> classificator = LearnKit.NaiveBayes.Gaussian.new([{:label1, [[-1, -1], [-2, -1], [-3, -2]]}, {:label2, [[1, 1], [2, 1], [3, 2], [-2, -2]]}])
159-
iex> classificator = classificator |> LearnKit.NaiveBayes.Gaussian.fit
160158
iex> classificator |> LearnKit.NaiveBayes.Gaussian.score
161159
{:ok, 0.857143}
162160

0 commit comments

Comments
 (0)