Skip to content

Commit 5b943e9

Browse files
committed
Subsampling in test_population
y_train is a np.array, we can pass a list of indexes directly to the operator[]. X_train is a dataframe, and our sample_idx is a list of randomly sampled integers between [0, len(X_train)), so we should operate with iloc.
1 parent 59d9f17 commit 5b943e9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

experiment/test_population.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def test_population(ml):
4848
# Few samples to try to make it quick
4949
sample_idx = np.random.choice(np.arange(len(X_train)), size=10)
5050

51-
y_train = y_train.iloc[sample_idx]
52-
X_train = X_train.iloc[sample_idx, :]
51+
y_train = y_train[sample_idx]
52+
X_train = X_train.iloc[sample_idx]
5353

5454
algorithm.est.fit(X_train, y_train)
5555

@@ -59,7 +59,6 @@ def test_population(ml):
5959
algorithm.get_best_solution = lambda est: est
6060

6161
population = algorithm.get_population(algorithm.est)
62-
6362
best_model = algorithm.get_best_solution(algorithm.est)
6463
print(algorithm.model(best_model))
6564
print(algorithm.est.predict(X_train))

0 commit comments

Comments
 (0)