Closed robelgeda closed 1 year ago
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [226], in <cell line: 1>() ----> 1 PetrosianCorrection('full_grid.yaml') File /mnt/f/lcbg/petrofit/petrofit/petrosian.py:594, in PetrosianCorrection.__init__(self, grid_file) 592 self._grid_file = grid_file 593 self.grid = self._read_grid_file() --> 594 self.regressor = self._train() File /mnt/f/lcbg/petrofit/petrofit/petrosian.py:674, in PetrosianCorrection._train(self) 671 N = np.array(N) 673 clf = DecisionTreeRegressor() --> 674 clf.fit(X, N) 675 return clf File ~/miniconda3/envs/petrofit/lib/python3.10/site-packages/sklearn/tree/_classes.py:1342, in DecisionTreeRegressor.fit(self, X, y, sample_weight, check_input) 1313 def fit(self, X, y, sample_weight=None, check_input=True): 1314 """Build a decision tree regressor from the training set (X, y). 1315 1316 Parameters (...) 1339 Fitted estimator. 1340 """ -> 1342 super().fit( 1343 X, 1344 y, 1345 sample_weight=sample_weight, 1346 check_input=check_input, 1347 ) 1348 return self File ~/miniconda3/envs/petrofit/lib/python3.10/site-packages/sklearn/tree/_classes.py:172, in BaseDecisionTree.fit(self, X, y, sample_weight, check_input) 170 check_X_params = dict(dtype=DTYPE, accept_sparse="csc") 171 check_y_params = dict(ensure_2d=False, dtype=None) --> 172 X, y = self._validate_data( 173 X, y, validate_separately=(check_X_params, check_y_params) 174 ) 175 if issparse(X): 176 X.sort_indices() File ~/miniconda3/envs/petrofit/lib/python3.10/site-packages/sklearn/base.py:591, in BaseEstimator._validate_data(self, X, y, reset, validate_separately, **check_params) 589 if "estimator" not in check_X_params: 590 check_X_params = {**default_check_params, **check_X_params} --> 591 X = check_array(X, input_name="X", **check_X_params) 592 if "estimator" not in check_y_params: 593 check_y_params = {**default_check_params, **check_y_params} File ~/miniconda3/envs/petrofit/lib/python3.10/site-packages/sklearn/utils/validation.py:899, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator, input_name) 893 raise ValueError( 894 "Found array with dim %d. %s expected <= 2." 895 % (array.ndim, estimator_name) 896 ) 898 if force_all_finite: --> 899 _assert_all_finite( 900 array, 901 input_name=input_name, 902 estimator_name=estimator_name, 903 allow_nan=force_all_finite == "allow-nan", 904 ) 906 if ensure_min_samples > 0: 907 n_samples = _num_samples(array) File ~/miniconda3/envs/petrofit/lib/python3.10/site-packages/sklearn/utils/validation.py:146, in _assert_all_finite(X, allow_nan, msg_dtype, estimator_name, input_name) 124 if ( 125 not allow_nan 126 and estimator_name (...) 130 # Improve the error message on how to handle missing values in 131 # scikit-learn. 132 msg_err += ( 133 f"\n{estimator_name} does not accept missing values" 134 " encoded as NaN natively. For supervised learning, you might want" (...) 144 "#estimators-that-handle-nan-values" 145 ) --> 146 raise ValueError(msg_err) 148 # for object dtype data, we only check for NaNs (GH-13254) 149 elif X.dtype == np.dtype("object") and not allow_nan: ValueError: Input X contains infinity or a value too large for dtype('float32').