pkg_pyknnclassifier.predict
Module Contents
Functions
|
This function predicts the labels of the unlabled observations based on the similarity score calculated from Euclidean distance. |
- pkg_pyknnclassifier.predict.predict(train_X, train_y, unlabel_df, pred_method='hard', k=3)[source]
This function predicts the labels of the unlabled observations based on the similarity score calculated from Euclidean distance.
- Parameters:
train_X (pd.DataFrame) – The data frame containing labeled observations, but without the label.
train_y (numpy.array) – The array containing labels in the training dataset
unlabel_df (pd.DataFrame) – The data frame containing unlabeld observations.
pred_method (str) – ‘soft’ or ‘hard’.
k (int) – The number of nearest neighbors to consider for making predictions.
- Returns:
An array containing predicted labels for the observations.
- Return type:
array
Examples
- df = pd.DataFrame({‘A’:[0.5, 0.2, 0.4],
‘B’:[0.3, 0.2, 0.5]})
predict(df)