<jupyter_start><jupyter_text>Random Forest<jupyter_code># Random Forest

# random_forest1 = RandomForestClassifier(n_estimators=100, max_depth=5, random_state=1)
# random_forest1.fit(X_train, Y1_train)
# Y1_pred = random_forest1.predict(X_test)
# acc_random_forest1 = round(random_forest1.score(X_train, Y1_train) * 100, 2)
# acc_random_forest1
# Random Forest

# random_forest2 = RandomForestClassifier(n_estimators=100, max_depth=7, random_state=1)
# random_forest2.fit(X_train, Y2_train)
# Y2_pred = random_forest2.predict(X_test)
# acc_random_forest2 = round(random_forest2.score(X_train, Y2_train) * 100, 2)
# acc_random_forest2
# submission = pd.DataFrame({'pet_id': test_df['pet_id'],'breed_category': Y1_pred,'pet_category': Y2_pred})
# submission.to_csv('random_forest_submission.csv', index=False)<jupyter_output><empty_output><jupyter_text>SVC<jupyter_code># Support Vector Machines

# svc1 = SVC()
# svc1.fit(X_train, Y1_train)
# Y1_pred = svc1.predict(X_test)
# acc_svc1 = round(svc1.score(X_train, Y1_train) * 100, 2)
# acc_svc1
# Support Vector Machines

# svc2 = SVC()
# svc2.fit(X_train, Y2_train)
# Y2_pred = svc2.predict(X_test)
# acc_svc2 = round(svc2.score(X_train, Y2_train) * 100, 2)
# acc_svc2
# submission = pd.DataFrame({'pet_id': test_df['pet_id'],'breed_category': Y1_pred,'pet_category': Y2_pred})
# submission.to_csv('svc_submission.csv', index=False)
# param_grid = {'C': [0.1, 1, 10],  
#               'gamma': [1, 0.1, 0.01], 
#               'kernel': ['rbf','poly']}  
# svc = SVC()
# clf = GridSearchCV(estimator=svc, param_grid=param_grid, n_jobs=-1)
# clf.fit(X_train, Y2_train)
# clf.best_params_, clf.best_score_<jupyter_output><empty_output><jupyter_text>XGB<jupyter_code># param_grid = {# 'n_estimators': [300,500,800,1000],
#               'learning_rate': [0.05, 0.10, 0.15, 0.20, 0.25, 0.30 ],
#               # 'subsample': [0.3,0.6,0.9],
#               'max_depth': [3, 4, 5, 6, 7, 8, 9],
#               # 'colsample_bytree': [0.5,0.7,0.9],
#               # 'min_child_weight': [1, 2, 3, 4]
#               }
# xgb = XGBClassifier()
# clf = RandomizedSearchCV(xgb, param_grid, n_jobs=-1, random_state=42)
# clf.fit(X_train, Y1_train)
# clf.best_params_, clf.best_score_
# param_grid = {'n_estimators': [300,500,800,1000],
#               'learning_rate': [0.05, 0.10, 0.15, 0.20, 0.25, 0.30 ],
#               'subsample': [0.3,0.6,0.9],
#               'max_depth': [3, 4, 5, 6, 7, 8, 9],
#               'colsample_bytree': [0.5,0.7,0.9],
#               'min_child_weight': [1, 2, 3, 4]
#               }
# xgb = XGBClassifier()
# clf = RandomizedSearchCV(xgb, param_grid, n_jobs=-1, random_state=42)
# clf.fit(X_train, Y2_train)
# clf.best_params_, clf.best_score_
# XGBoost # colsample_bytree= 0.9,learning_rate= 0.25,max_depth= 3,min_child_weight= 2,n_estimators= 300,subsample= 0.9

xgb1 = XGBClassifier(learning_rate= 0.1, max_depth= 3, n_estimators= 300)
xgb1.fit(X_train, Y1_train)
Y1_pred = xgb1.predict(X_test)
acc_xgb1 = round(xgb1.score(X_train, Y1_train) * 100, 2)
acc_xgb1
# XGBoost # colsample_bytree= 0.9,learning_rate= 0.25,max_depth= 3,min_child_weight= 2,n_estimators= 300,subsample= 0.9

xgb2 = XGBClassifier(learning_rate= 0.1, max_depth= 4, n_estimators= 300)
xgb2.fit(X_train, Y2_train)
Y2_pred = xgb2.predict(X_test)
acc_xgb2 = round(xgb2.score(X_train, Y2_train) * 100, 2)
acc_xgb2
# submission = pd.DataFrame({'pet_id': test_df['pet_id'],'breed_category': Y1_pred,'pet_category': Y2_pred})
# submission.to_csv('xgb_submission.csv', index=False)<jupyter_output><empty_output><jupyter_text>LGBM<jupyter_code># param_grid ={'num_leaves': [2,5,10,15,30,45],
#              'min_child_samples': [2,5,7,10,15], 
#              'min_child_weight': [1e-3, 1e-2, 1e-1, 1, 1e1, 1e2],
#              'learning_rate': [0.001,0.01,0.1,1,10],
#              'min_data_in_leaf': [5,10,20,30,40,50,60],
#             #  'subsample': uniform(loc=0.2, scale=0.8), 
#             #  'colsample_bytree': uniform(loc=0.4, scale=0.6),
#              'reg_alpha': [0.01,0.1,0,1,10],
#              'reg_lambda': [0.01,0.1,0,1,10],
#              'max_depth': [1,3,5,10,15,20,25,-1]
#              }
# lgbm = LGBMClassifier()
# clf = RandomizedSearchCV(lgbm, param_grid, n_jobs=-1, random_state=42)
# clf.fit(X_train, Y1_train)
# clf.best_params_, clf.best_score_
# param_grid ={'num_leaves': [6,15,30,45,60,75,90],
#              'min_child_samples': [2,5,7,10,15], 
#              'min_child_weight': [1e-3, 1e-2, 1e-1, 1, 1e1, 1e2],
#              'learning_rate': [0.001,0.01,0.1,1,10],
#              'min_data_in_leaf': [5,10,20,30,40],
#             #  'subsample': uniform(loc=0.2, scale=0.8), 
#             #  'colsample_bytree': uniform(loc=0.4, scale=0.6),
#              'reg_alpha': [0.01,0.1,0,1,10],
#              'reg_lambda': [0.01,0.1,0,1,10],
#              'max_depth': [1,3,5,10,15,20,-1]
#              }
# lgbm = LGBMClassifier()
# clf = RandomizedSearchCV(lgbm, param_grid, n_jobs=-1, random_state=42)
# clf.fit(X_train, Y2_train)
# clf.best_params_, clf.best_score_
# LGBM # min_child_samples= 20, min_child_weight= 0.01, reg_alpha= 0.1, reg_lambda= 0.01
# learning_rate= 0.1, max_depth= 6, min_data_in_leaf= 20, num_leaves= 45

lgbm1 = LGBMClassifier(learning_rate= 0.1, max_depth= 6, min_data_in_leaf= 20, num_leaves= 45)
lgbm1.fit(X_train, Y1_train)
Y1_pred = lgbm1.predict(X_test)
acc_lgbm1 = round(lgbm1.score(X_train, Y1_train) * 100, 2)
acc_lgbm1
# LGBM # min_child_samples= 20, min_child_weight= 1, num_leaves= 80
# learning_rate= 0.1, max_depth= 8, min_data_in_leaf= 20, num_leaves= 150

lgbm2 = LGBMClassifier(learning_rate= 0.1, max_depth= 8, min_data_in_leaf= 20, num_leaves= 150)
lgbm2.fit(X_train, Y2_train)
Y2_pred = lgbm2.predict(X_test)
acc_lgbm2 = round(lgbm2.score(X_train, Y2_train) * 100, 2)
acc_lgbm2
# submission = pd.DataFrame({'pet_id': test_df['pet_id'],'breed_category': Y1_pred,'pet_category': Y2_pred})
# submission.to_csv('lgbm_submission.csv', index=False)<jupyter_output><empty_output><jupyter_text>KNN<jupyter_code># KNN or k-Nearest Neighbors

# knn1 = KNeighborsClassifier(n_neighbors=7)
# knn1.fit(X_train, Y1_train)
# Y1_pred = knn1.predict(X_test)
# acc_knn1 = round(knn1.score(X_train, Y1_train) * 100, 2)
# acc_knn1
# KNN or k-Nearest Neighbors

# knn2 = KNeighborsClassifier(n_neighbors=7)
# knn2.fit(X_train, Y2_train)
# Y2_pred = knn2.predict(X_test)
# acc_knn2 = round(knn2.score(X_train, Y2_train) * 100, 2)
# acc_knn2
# submission = pd.DataFrame({'pet_id': test_df['pet_id'],'breed_category': Y1_pred,'pet_category': Y2_pred})
# submission.to_csv('knn_submission.csv', index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16900135562584725, 'fraction_numerical': 0.08269317668323543, 'mean_word_length': 4.433715220949264, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '322964', 'license': 'MIT', 'n_tokens_mistral': 3209, 'n_tokens_neox': 2944, 'n_words': 426, 'path': 'Pet_Adoption_Prediction.ipynb', 'repo_name': 'parthjalan37/HackerEarth-Machine-Learning-challenge-Adopt-a-buddy', 'size': '6639'}