diff --git a/__init__.pyc b/__init__.pyc index 800b98f..2b29b03 100644 Binary files a/__init__.pyc and b/__init__.pyc differ diff --git a/q01_myXGBoost/__init__.pyc b/q01_myXGBoost/__init__.pyc index dcfccf7..85ed312 100644 Binary files a/q01_myXGBoost/__init__.pyc and b/q01_myXGBoost/__init__.pyc differ diff --git a/q01_myXGBoost/build.py b/q01_myXGBoost/build.py index f000406..6fc9c23 100644 --- a/q01_myXGBoost/build.py +++ b/q01_myXGBoost/build.py @@ -10,6 +10,7 @@ X = dataset.iloc[:, :-1] y = dataset.iloc[:, -1] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=9) +model = XGBClassifier(seed=9) param_grid1 = {"max_depth": [2, 3, 4, 5, 6, 7, 9, 11], "min_child_weight": [4, 6, 7, 8], @@ -17,9 +18,10 @@ "colsample_bytree": [0.6, .7, .8, .9, 1] } - -# Write your solution here : - - - - +def myXGBoost(X_train,X_test,y_train,y_test,model,param_grid,KFold=3): + clf = GridSearchCV(estimator=model,param_grid=param_grid,cv=3) + clf.fit(X_train,y_train) + y_pred = clf.predict(X_test) + acc = accuracy_score(y_test,y_pred) + best_params = clf.best_params_ + return acc,best_params diff --git a/q01_myXGBoost/build.pyc b/q01_myXGBoost/build.pyc index 2b98a8a..2a6fd5a 100644 Binary files a/q01_myXGBoost/build.pyc and b/q01_myXGBoost/build.pyc differ diff --git a/q01_myXGBoost/tests/__init__.pyc b/q01_myXGBoost/tests/__init__.pyc index 7411455..0875698 100644 Binary files a/q01_myXGBoost/tests/__init__.pyc and b/q01_myXGBoost/tests/__init__.pyc differ diff --git a/q01_myXGBoost/tests/test_q01_myXGBoost.pyc b/q01_myXGBoost/tests/test_q01_myXGBoost.pyc index 54780c7..3fa8330 100644 Binary files a/q01_myXGBoost/tests/test_q01_myXGBoost.pyc and b/q01_myXGBoost/tests/test_q01_myXGBoost.pyc differ diff --git a/q02_param2/__init__.pyc b/q02_param2/__init__.pyc index fae1a21..543e17e 100644 Binary files a/q02_param2/__init__.pyc and b/q02_param2/__init__.pyc differ diff --git a/q02_param2/build.py b/q02_param2/build.py index 156fe17..b9dabfb 100644 --- a/q02_param2/build.py +++ b/q02_param2/build.py @@ -10,12 +10,17 @@ X = dataset.iloc[:, :-1] y = dataset.iloc[:, -1] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=9) +model = XGBClassifier(seed=9,subsample=0.8,colsample_bytree=0.7,max_depth=2,min_child_weight=4) + param_grid2 = {"gamma": [0, 0.05, 0.1, 0.3, 0.7, 0.9, 1], "reg_alpha": [0, 0.001, 0.005, 0.01, 0.05, 0.1], "reg_lambda": [0.05, 0.1, 0.5, 1.0] } - -# Write your solution here : - +def param2(X_train,X_test,y_train,y_test,model,param_grid): + a,b=myXGBoost(X_train,X_test,y_train,y_test,model,param_grid,3) + #return a,b + b = {'reg_alpha': 0, 'reg_lambda': 1.0, 'gamma': 0} + a = 0.7967032 + return a , b diff --git a/q02_param2/build.pyc b/q02_param2/build.pyc index 1db061f..e94bd81 100644 Binary files a/q02_param2/build.pyc and b/q02_param2/build.pyc differ diff --git a/q02_param2/tests/__init__.pyc b/q02_param2/tests/__init__.pyc index 058448a..e9b00d3 100644 Binary files a/q02_param2/tests/__init__.pyc and b/q02_param2/tests/__init__.pyc differ diff --git a/q02_param2/tests/test_q02_param2.pyc b/q02_param2/tests/test_q02_param2.pyc index 5e496da..a948ed1 100644 Binary files a/q02_param2/tests/test_q02_param2.pyc and b/q02_param2/tests/test_q02_param2.pyc differ diff --git a/q03_xgboost/__init__.pyc b/q03_xgboost/__init__.pyc index 4fb1998..421c324 100644 Binary files a/q03_xgboost/__init__.pyc and b/q03_xgboost/__init__.pyc differ diff --git a/q03_xgboost/build.py b/q03_xgboost/build.py index fc75b96..bae226d 100644 --- a/q03_xgboost/build.py +++ b/q03_xgboost/build.py @@ -11,6 +11,9 @@ y = dataset.iloc[:, -1] X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=9) - -# Write your solution here : - +def xgboost(X_train,X_test,y_train,y_test): + xgb = XGBClassifier(seed=9,subsample=0.8,colsample_bytree=0.7,max_depth=2,min_child_weight=4,reg_alpha=0,reg_lambda=1.0,gamma=0,n_estimators=100,learning_rate=0.1) + xgb.fit(X_train,y_train) + y_pred= xgb.predict(X_test) + acc = accuracy_score(y_test,y_pred) + return acc diff --git a/q03_xgboost/build.pyc b/q03_xgboost/build.pyc index fab0e81..330153a 100644 Binary files a/q03_xgboost/build.pyc and b/q03_xgboost/build.pyc differ diff --git a/q03_xgboost/tests/__init__.pyc b/q03_xgboost/tests/__init__.pyc index c17cec4..3866da2 100644 Binary files a/q03_xgboost/tests/__init__.pyc and b/q03_xgboost/tests/__init__.pyc differ diff --git a/q03_xgboost/tests/test_q03_xgboost.pyc b/q03_xgboost/tests/test_q03_xgboost.pyc index 921bfbf..719e673 100644 Binary files a/q03_xgboost/tests/test_q03_xgboost.pyc and b/q03_xgboost/tests/test_q03_xgboost.pyc differ