This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def perceptron(data, label, iteration, y): | |
''' | |
The perceptron classifier | |
Arguments | |
data: This is the training data with a certain shape (x, y), meaning there are x samples and each sample has y features. | |
label: This is the training data's label with shape (x, 1). The 1 corresponds to the correct classification of the data. | |
iteration: This is the number of times the function will iterate. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def thirdorder(data): | |
''' | |
3rd order polynomial transform of data | |
Arguments | |
data: The input data is assumed to have shape (:, 3). The first dimension represents | |
the total samples and the second dimension represents the total features. | |
Returns | |
result: A numpy array format of the new data with shape (:,10), where the feature | |
numbers are extended. | |
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def logistic_regression(data, label, iteration, learning_rate): | |
''' | |
Logistic regression classifier | |
Arguments | |
data: This is the training data with shape (n, d), which corresponds to n samples and each sample has d features. | |
label: This is the training data's label with shape (n,1). The 1 corresponds to the correct classification of the data. | |
iteration: The number of times to iterate. |