Open flycloudking opened 5 years ago
from pyod.models.lscp import LSCP
from sklearn.neighbors import KNeighborsClassifier as KNN
import pandas as pd
# Load your data
# Example: country_df = pd.read_csv('dummy.txt', delimiter='\t')
# Define KNN models with valid `n_neighbors` values
knn_list = [KNN(n_neighbors=2), KNN(n_neighbors=4)] # Ensure n_neighbors is less than or equal to number of samples
# Initialize LSCP model with the list of KNN models
clf = LSCP(knn_list)
# Fit LSCP model
clf.fit(country_df)
I run the following code on a data frame country_df of 25 samples, 18 columns:
knn_list = [KNN(n_neighbors=2), KNN(n_neighbors=4)]
print(knn_list)
clf = LSCP(knn_list) clf.fit(country_df)
and get error: ValueError Traceback (most recent call last)