<jupyter_start><jupyter_text>Data<jupyter_code>train = pd.read_csv("location_train.csv")
test = pd.read_csv("location_test.csv")
train.info()
train.head()
test.info()
test.head()
X_train = train.drop(["ID", "class"], axis=1)
y_train = train["class"]

X_test = test.drop(["ID"], axis=1)<jupyter_output><empty_output><jupyter_text>Model selection<jupyter_code># Grid Search

cv = 10         # number of folds
verbose = 3     # information shown during training<jupyter_output><empty_output><jupyter_text>Decision Tree<jupyter_code>parameters = {
    "criterion":["gini", "entropy"],
    "splitter":["best", "random"], 
    "max_depth":["None", 100, 500, 1000],
    "max_features":["auto", "sqrt", "log2"]}    
model = GridSearchCV(DecisionTreeClassifier(), parameters, cv=cv, verbose=verbose, scoring="accuracy")
model.fit(X_train, y_train)

results = pd.DataFrame(model.cv_results_)
results = results[["param_criterion", "param_splitter", "param_max_depth", "param_max_features", "mean_test_score"]]
results.sort_values(["mean_test_score"], ascending=False).head(10)<jupyter_output>Fitting 10 folds for each of 48 candidates, totalling 480 fits
[CV 1/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 2/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 3/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 4/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 5/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 6/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 7/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 8/10] END criterion=gini, max_depth=None, max_features=auto, splitter=best;, score=nan total time=   0.0s
[CV 9/10] END criterion=gini, max_depth=None, max_feature[...]<jupyter_text>Final model<jupyter_code>best_model = model.best_estimator_
best_model.fit(X_train, y_train)
predictions = pd.DataFrame(test["ID"])
predictions["class"] = best_model.predict(X_test)
predictions.to_csv("submission.csv", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15120711562897077, 'fraction_numerical': 0.028801355357899194, 'mean_word_length': 7.287719298245614, 'pattern_counts': {'":': 4, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '170833', 'license': 'MIT', 'n_tokens_mistral': 930, 'n_tokens_neox': 852, 'n_words': 175, 'path': 'kaggle_location/location_dt.ipynb', 'repo_name': 'hoverslam/ml-projects', 'size': '2361'}