Skip to content

Commit a6625a3

Browse files
committed
Slicing corrected.
1 parent 8732493 commit a6625a3

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

codonPython/tolerance.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ def check_tolerance(X, y, to_exclude: int = 1, poly_features: int = 2, alpha: fl
3737
Examples
3838
--------
3939
>>> check_tolerance(
40-
... X = np.array([1001,1002,1003,1004,1005]),
41-
... y = np.array([2,3,4,4.5,5])
40+
... X = np.array([1001,1002,1003,1004,1005,1006]),
41+
... y = np.array([2,3,4,4.5,5,5.1]),
4242
... ).round(3).to_dict()
43-
{'yhat_u': {0: 9.077}, 'yobs': {0: 5.0}, 'yhat': {0: 4.875}, 'yhat_l': {0: 0.673}}
43+
{'yhat_u': {0: 6.061}, 'yobs': {0: 5.1}, 'yhat': {0: 5.2}, 'yhat_l': {0: 4.339}}
4444
"""
4545

4646
if not isinstance(poly_features, int) or 0 >= poly_features >= 4:
@@ -66,11 +66,11 @@ def check_tolerance(X, y, to_exclude: int = 1, poly_features: int = 2, alpha: fl
6666
)
6767

6868
# Fit transforms to train data, apply them to all data
69-
fitted_transforms = transforms.fit(X[:to_exclude].reshape(-1, 1))
69+
fitted_transforms = transforms.fit(X[:-to_exclude].reshape(-1, 1))
7070
X = fitted_transforms.transform(X.reshape(-1, 1))
7171

7272
X_train, y_train = X[:-to_exclude, :], y[:-to_exclude]
73-
X_predict, y_predict = X[(N-to_exclude):, :], y[(N-to_exclude):]
73+
X_predict, y_predict = X[-to_exclude:, :], y[-to_exclude:]
7474

7575
# Fit ordinary least squares model to the training data, then predict for the
7676
# prediction data.

0 commit comments

Comments
 (0)