def test_KMeans_random_init(self): datapoints, labels = gaussian(n=100, d=2, labels=3, sigma=0.1, seed=1970) X_train, y_train, X_test, y_test = train_test_split(datapoints, labels, train_split=0.95, seed=1970) classifier = KMeans(k=3, seed=1970, initialisation='Random') classifier.train(X=X_train) self.assertEqual(self.classifier.iterations, 7)
def setUpClass(cls): cls.datapoints, cls.labels = gaussian(n=100, d=2, labels=3, sigma=0.1, seed=1970) cls.X_train, cls.y_train, cls.X_test, cls.y_test = train_test_split( cls.datapoints, cls.labels, train_split=0.95, seed=1970) cls.classifier = KNNClassifier(n=5) cls.classifier.train(X=cls.X_train, y=cls.y_train)
def setUpClass(cls): set_seed(2017) cls.A = [[random.random() for e in range(3)] for x in range(3)] cls.B = [[random.random() for e in range(3)] for x in range(3)] cls.X, cls.y = regression(100, seed=1970) cls.X_train, cls.y_train, cls.X_test, cls.y_test = train_test_split( cls.X, cls.y, train_split=0.8, seed=1970) cls.regressor = KNNRegressor(n=5) cls.regressor.train(X=cls.X_train, y=cls.y_train)
def setUpClass(cls): cls.X, cls.y = regression(100, seed=1970) cls.X_train, cls.y_train, cls.X_test, cls.y_test = train_test_split( cls.X, cls.y, train_split=0.8, seed=1970) cls.regressor = KNNRegressor(n=5) cls.regressor.train(X=cls.X_train, y=cls.y_train)