Skip to content

Commit 167fc95

Browse files
committed
release 0.1.2
1 parent 6208623 commit 167fc95

7 files changed

Lines changed: 26 additions & 22 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7-
## [Unreleased]
7+
## [0.1.2] - 2018-11-22
88
### Added
99
- CHANGELOG.md file
1010
- Add simple Linear Regression predictor
1111

12+
### Modified
13+
- Readme
14+
- Tests
15+
1216
## [0.1.1] - 2018-11-19
1317
### Added
1418
- Gaussian Naive Bayes algorithm

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ by adding `learn_kit` to your list of dependencies in `mix.exs`:
1919
```elixir
2020
def deps do
2121
[
22-
{:learn_kit, "~> 0.1.1"}
22+
{:learn_kit, "~> 0.1.2"}
2323
]
2424
end
2525
```

lib/learn_kit/knn.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ defmodule LearnKit.Knn do
2424
%LearnKit.Knn{data_set: []}
2525
2626
"""
27-
@spec new() :: %LearnKit.Knn{data_set: []}
27+
@spec new() :: %Knn{data_set: []}
2828

2929
def new do
3030
[]
@@ -44,7 +44,7 @@ defmodule LearnKit.Knn do
4444
%LearnKit.Knn{data_set: [a1: [[1, 2], [2, 3]], b1: [[-1, -2]]]}
4545
4646
"""
47-
@spec new(data_set) :: %LearnKit.Knn{data_set: data_set}
47+
@spec new(data_set) :: %Knn{data_set: data_set}
4848

4949
def new(data_set) do
5050
%Knn{data_set: data_set}
@@ -60,11 +60,11 @@ defmodule LearnKit.Knn do
6060
6161
## Examples
6262
63-
iex> classificator |> LearnKit.Knn.add_train_data({:a1, [-1, -1]})
63+
iex> classificator = classificator |> LearnKit.Knn.add_train_data({:a1, [-1, -1]})
6464
%LearnKit.Knn{data_set: [a1: [[-1, -1]]]}
6565
6666
"""
67-
@spec add_train_data(%LearnKit.Knn{data_set: data_set}, point) :: %LearnKit.Knn{data_set: data_set}
67+
@spec add_train_data(%Knn{data_set: data_set}, point) :: %Knn{data_set: data_set}
6868

6969
def add_train_data(%Knn{data_set: data_set}, {key, value}) do
7070
features = if Keyword.has_key?(data_set, key), do: Keyword.get(data_set, key), else: []
@@ -93,7 +93,7 @@ defmodule LearnKit.Knn do
9393
{:ok, :a1}
9494
9595
"""
96-
@spec classify(%LearnKit.Knn{data_set: data_set}, [tuple]) :: {:ok, label}
96+
@spec classify(%Knn{data_set: data_set}, [tuple]) :: {:ok, label}
9797

9898
def classify(%Knn{data_set: data_set}, options \\ []) do
9999
try do

lib/learn_kit/naive_bayes/gaussian.ex

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
3131
%LearnKit.NaiveBayes.Gaussian{data_set: [], fit_data: []}
3232
3333
"""
34-
@spec new() :: %LearnKit.NaiveBayes.Gaussian{data_set: []}
34+
@spec new() :: %Gaussian{data_set: []}
3535

3636
def new do
3737
[]
@@ -51,7 +51,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
5151
%LearnKit.NaiveBayes.Gaussian{data_set: [a1: [[1, 2], [2, 3]], b1: [[-1, -2]]], fit_data: []}
5252
5353
"""
54-
@spec new(data_set) :: %LearnKit.NaiveBayes.Gaussian{data_set: data_set}
54+
@spec new(data_set) :: %Gaussian{data_set: data_set}
5555

5656
def new(data_set) do
5757
%Gaussian{data_set: data_set}
@@ -67,11 +67,11 @@ defmodule LearnKit.NaiveBayes.Gaussian do
6767
6868
## Examples
6969
70-
iex> classificator |> LearnKit.NaiveBayes.Gaussian.add_train_data({:a1, [-1, -1]})
70+
iex> classificator = classificator |> LearnKit.NaiveBayes.Gaussian.add_train_data({:a1, [-1, -1]})
7171
%LearnKit.NaiveBayes.Gaussian{data_set: [a1: [[-1, -1]]], fit_data: []}
7272
7373
"""
74-
@spec add_train_data(%LearnKit.NaiveBayes.Gaussian{data_set: data_set}, point) :: %LearnKit.NaiveBayes.Gaussian{data_set: data_set}
74+
@spec add_train_data(%Gaussian{data_set: data_set}, point) :: %Gaussian{data_set: data_set}
7575

7676
def add_train_data(%Gaussian{data_set: data_set}, {key, value}) do
7777
features = if Keyword.has_key?(data_set, key), do: Keyword.get(data_set, key), else: []
@@ -88,7 +88,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
8888
8989
## Examples
9090
91-
iex> classificator |> LearnKit.NaiveBayes.Gaussian.fit
91+
iex> classificator = classificator |> LearnKit.NaiveBayes.Gaussian.fit
9292
%LearnKit.NaiveBayes.Gaussian{
9393
data_set: [a1: [[-1, -1]]],
9494
fit_data: [
@@ -100,7 +100,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
100100
}
101101
102102
"""
103-
@spec fit(%LearnKit.NaiveBayes.Gaussian{data_set: data_set}) :: %LearnKit.NaiveBayes.Gaussian{data_set: data_set, fit_data: fit_data}
103+
@spec fit(%Gaussian{data_set: data_set}) :: %Gaussian{data_set: data_set, fit_data: fit_data}
104104

105105
def fit(%Gaussian{data_set: data_set}) do
106106
%Gaussian{data_set: data_set, fit_data: fit_data(data_set)}
@@ -119,7 +119,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
119119
{:ok, [a1: 0.0359, a2: 0.0039]}
120120
121121
"""
122-
@spec predict_proba(%LearnKit.NaiveBayes.Gaussian{fit_data: fit_data}, feature) :: {:ok, predictions}
122+
@spec predict_proba(%Gaussian{fit_data: fit_data}, feature) :: {:ok, predictions}
123123

124124
def predict_proba(%Gaussian{fit_data: fit_data}, feature) do
125125
result = fit_data |> classify_data(feature)
@@ -139,7 +139,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
139139
{:ok, {:a1, 0.334545454}}
140140
141141
"""
142-
@spec predict(%LearnKit.NaiveBayes.Gaussian{fit_data: fit_data}, feature) :: {:ok, prediction}
142+
@spec predict(%Gaussian{fit_data: fit_data}, feature) :: {:ok, prediction}
143143

144144
def predict(%Gaussian{fit_data: fit_data}, feature) do
145145
result = fit_data |> classify_data(feature) |> Enum.sort_by(&(elem(&1, 1))) |> Enum.at(-1)
@@ -159,7 +159,7 @@ defmodule LearnKit.NaiveBayes.Gaussian do
159159
{:ok, 0.857143}
160160
161161
"""
162-
@spec score(%LearnKit.NaiveBayes.Gaussian{data_set: data_set, fit_data: fit_data}) :: {:ok, number}
162+
@spec score(%Gaussian{data_set: data_set, fit_data: fit_data}) :: {:ok, number}
163163

164164
def score(%Gaussian{data_set: data_set, fit_data: fit_data}) do
165165
result = fit_data |> calc_score(data_set)

lib/learn_kit/regression/linear.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ defmodule LearnKit.Regression.Linear do
2323
%LearnKit.Regression.Linear{factors: [], results: [], coefficients: []}
2424
2525
"""
26-
@spec new() :: %LearnKit.Regression.Linear{factors: [], results: [], coefficients: []}
26+
@spec new() :: %Linear{factors: [], results: [], coefficients: []}
2727

2828
def new do
2929
Linear.new([], [])
@@ -43,7 +43,7 @@ defmodule LearnKit.Regression.Linear do
4343
%LearnKit.Regression.Linear{factors: [1, 2, 3, 4], results: [3, 6, 10, 15], coefficients: []}
4444
4545
"""
46-
@spec new(factors, results) :: %LearnKit.Regression.Linear{factors: factors, results: results, coefficients: []}
46+
@spec new(factors, results) :: %Linear{factors: factors, results: results, coefficients: []}
4747

4848
def new(factors, results) do
4949
%Linear{factors: factors, results: results}
@@ -66,7 +66,7 @@ defmodule LearnKit.Regression.Linear do
6666
}
6767
6868
"""
69-
@spec fit(%LearnKit.Regression.Linear{factors: factors, results: results}) :: %LearnKit.Regression.Linear{factors: factors, results: results, coefficients: coefficients}
69+
@spec fit(%Linear{factors: factors, results: results}) :: %Linear{factors: factors, results: results, coefficients: coefficients}
7070

7171
def fit(%Linear{factors: factors, results: results}) do
7272
%Linear{factors: factors, results: results, coefficients: fit_data(factors, results)}
@@ -86,7 +86,7 @@ defmodule LearnKit.Regression.Linear do
8686
{:ok, [14.5, 30.5, 50.5]}
8787
8888
"""
89-
@spec predict(%LearnKit.Regression.Linear{coefficients: coefficients}, list) :: {:ok, list}
89+
@spec predict(%Linear{coefficients: coefficients}, list) :: {:ok, list}
9090

9191
def predict(%Linear{coefficients: coefficients}, samples) do
9292
result = samples |> Enum.map(fn sample -> predict_sample(sample, coefficients) end)
@@ -106,7 +106,7 @@ defmodule LearnKit.Regression.Linear do
106106
{:ok, 0.9876543209876543}
107107
108108
"""
109-
@spec score(%LearnKit.Regression.Linear{factors: factors, results: results, coefficients: coefficients}) :: {:ok, number}
109+
@spec score(%Linear{factors: factors, results: results, coefficients: coefficients}) :: {:ok, number}
110110

111111
def score(%Linear{factors: factors, results: results, coefficients: coefficients}) do
112112
{:ok, calculate_score(coefficients, factors, results)}

mix.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ defmodule LearnKit.MixProject do
88
def project do
99
[
1010
app: :learn_kit,
11-
version: "0.1.1",
11+
version: "0.1.2",
1212
elixir: "~> 1.7",
1313
name: "LearnKit",
1414
description: @description,

0 commit comments

Comments
 (0)