odak.fit
odak.fit
Provides functions to fit models to a provided data. These functions could be best described as a catalog of machine learning models.
gradient_descent_1d(input_data, ground_truth_data, parameters, function, gradient_function, loss_function, learning_rate=0.1, iteration_number=10)
¶
Vanilla Gradient Descent algorithm for 1D data.
Parameters:
-
input_data
–One-dimensional input data.
-
ground_truth_data
(array
) –One-dimensional ground truth data.
-
parameters
–Parameters to be optimized.
-
function
–Function to estimate an output using the parameters.
-
gradient_function
(function
) –Function used in estimating gradient to update parameters at each iteration.
-
learning_rate
–Learning rate.
-
iteration_number
–Iteration number.
Returns:
-
parameters
(array
) –Optimized parameters.
Source code in odak/fit/__init__.py
least_square_1d(x, y)
¶
A function to fit a line to given x and y data (y=mx+n). Inspired from: https://mmas.github.io/least-squares-fitting-numpy-scipy
Parameters:
-
x
–1D input data.
-
y
–1D output data.
Returns:
-
parameters
(array
) –Parameters of m and n in a line (y=mx+n).
Source code in odak/fit/__init__.py
perceptron(x, y, learning_rate=0.1, iteration_number=100)
¶
A function to train a perceptron model.
Parameters:
-
x
–Input X-Y pairs [m x 2].
-
y
–Labels for the input data [m x 1]
-
learning_rate
–Learning rate.
-
iteration_number
(int
, default:100
) –Iteration number.
Returns:
-
weights
(array
) –Trained weights of our model [3 x 1].
Source code in odak/fit/__init__.py
threshold_linear_model(x, w, threshold=0)
¶
A function for thresholding a linear model described with a dot product.
Parameters:
-
x
–Input data [3 x 1].
-
w
–Weights [3 x 1].
-
threshold
–Value for thresholding.
Returns:
-
result
(int
) –Estimated class of the input data. It could either be one or zero.