Skip to content

Commit 1f011a4

Browse files
committed
with_id option
1 parent bddf10a commit 1f011a4

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

nyaggle/experiment/gbdt.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ def experiment_gbdt(model_params: Dict[str, Any],
126126
with_mlflow: bool = False,
127127
mlflow_experiment_id: Optional[Union[int, str]] = None,
128128
mlflow_run_name: Optional[str] = None,
129-
mlflow_tracking_uri: Optional[str] = None
129+
mlflow_tracking_uri: Optional[str] = None,
130+
with_id = True
130131
):
131132
"""
132133
Evaluate metrics by cross-validation and stores result
@@ -248,6 +249,7 @@ def experiment_gbdt(model_params: Dict[str, Any],
248249

249250
if feature_list:
250251
X = pd.concat([X_train, X_test]) if X_test is not None else X_train
252+
X.reset_index(drop=True, inplace=True)
251253
X = load_features(X, feature_list, directory=feature_directory, ignore_columns=ignore_columns)
252254
ntrain = len(X_train)
253255
X_train, X_test = X.iloc[:ntrain, :], X.iloc[ntrain:, :].reset_index(drop=True)
@@ -342,6 +344,9 @@ def experiment_gbdt(model_params: Dict[str, Any],
342344
if submission_filename is None:
343345
submission_filename = os.path.basename(logging_directory)
344346

347+
if not with_id:
348+
submit_df.drop(submit_df.columns[0], axis=1, inplace=True)
349+
345350
exp.log_dataframe(submission_filename, submit_df, 'csv')
346351

347352
elapsed_time = time.time() - start_time
@@ -403,7 +408,7 @@ def autoprep_gbdt(X_train: pd.DataFrame, X_test: Optional[pd.DataFrame],
403408

404409
if gbdt_type == 'cat' and len(categorical_feature) > 0:
405410
X_train = X_train.copy()
406-
X_all = X_train if X_test is None else pd.concat([X_train, X_test])
411+
X_all = X_train if X_test is None else pd.concat([X_train, X_test]).copy()
407412

408413
# https://catboost.ai/docs/concepts/faq.html#why-float-and-nan-values-are-forbidden-for-cat-features
409414
for c in categorical_feature:

0 commit comments

Comments
 (0)