From 1bd73042b5899f7f187ed7bbe8e4cccfdf7b0be5 Mon Sep 17 00:00:00 2001 From: Modassir Afzal Date: Thu, 13 Oct 2022 17:19:51 +0530 Subject: [PATCH 01/55] Fixes: #{6551} --- machine_learning/xgboostclassifier.py | 54 +++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 machine_learning/xgboostclassifier.py diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py new file mode 100644 index 000000000000..0707eb130002 --- /dev/null +++ b/machine_learning/xgboostclassifier.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +"""xgboostclassifier.ipynb + +Automatically generated by Colaboratory. + +Original file is located at + https://colab.research.google.com/drive/1UlMmSrfKLuRW9LPCz6BvDDJMPgPhO-yu +""" + +# XGBoost Classifier Example +from matplotlib import pyplot as plt +from sklearn.datasets import load_iris +from xgboost import XGBClassifier +from sklearn.metrics import plot_confusion_matrix +from sklearn.model_selection import train_test_split + + +def main(): + + """ + The Url for the algorithm + https://xgboost.readthedocs.io/en/stable/ + Iris type dataset is used to demonstrate algorithm. + """ + + # Load Iris dataset + iris = load_iris() + + # Split dataset into train and test data + x = iris["data"] # features + y = iris["target"] + x_train, x_test, y_train, y_test = train_test_split( + x, y, test_size=0.3, random_state=1 + ) + + # XGBoost Classifier + xgb = XGBClassifier() + xgb.fit(x_train, y_train) + + # Display Confusion Matrix of Classifier + plot_confusion_matrix( + xgb, + x_test, + y_test, + display_labels=iris["target_names"], + cmap="Blues", + normalize="true", + ) + plt.title("Normalized Confusion Matrix - IRIS Dataset") + plt.show() + + +if __name__ == "__main__": + main() \ No newline at end of file From 89906411eedef25ff9b4d066ed590becfb1093d3 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:23:19 +0530 Subject: [PATCH 02/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 0707eb130002..dfd502b99e6c 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,12 +1,3 @@ -# -*- coding: utf-8 -*- -"""xgboostclassifier.ipynb - -Automatically generated by Colaboratory. - -Original file is located at - https://colab.research.google.com/drive/1UlMmSrfKLuRW9LPCz6BvDDJMPgPhO-yu -""" - # XGBoost Classifier Example from matplotlib import pyplot as plt from sklearn.datasets import load_iris @@ -51,4 +42,4 @@ def main(): if __name__ == "__main__": - main() \ No newline at end of file + main() From 5feb35b2a42cd139e4904a210640acd75a328b8e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 11:54:45 +0000 Subject: [PATCH 03/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index dfd502b99e6c..27e2e9c0bbeb 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,9 +1,9 @@ # XGBoost Classifier Example from matplotlib import pyplot as plt from sklearn.datasets import load_iris -from xgboost import XGBClassifier from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split +from xgboost import XGBClassifier def main(): From a927e9719448d3f6eac20cb6c6502d8a3a0a24f1 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:29:20 +0530 Subject: [PATCH 04/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 27e2e9c0bbeb..bc04edb6dab7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -29,6 +29,7 @@ def main(): xgb.fit(x_train, y_train) # Display Confusion Matrix of Classifier + #with both train and test sets plot_confusion_matrix( xgb, x_test, @@ -39,6 +40,8 @@ def main(): ) plt.title("Normalized Confusion Matrix - IRIS Dataset") plt.show() + + return None if __name__ == "__main__": From aaaf39807b7b0ace65775be5ae346bd8c1dc0d5c Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:30:39 +0530 Subject: [PATCH 05/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index bc04edb6dab7..7151db11928b 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def main(): +def main(): -> None: """ The Url for the algorithm @@ -40,8 +40,7 @@ def main(): ) plt.title("Normalized Confusion Matrix - IRIS Dataset") plt.show() - - return None + if __name__ == "__main__": From 06a9025e021cae2b0c51b8bccc64f72ce1d7c2c2 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:31:42 +0530 Subject: [PATCH 06/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 7151db11928b..e9c50bb3e6c7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def main(): -> None: +def main() -> None: """ The Url for the algorithm From 0decdf8b4df1d9ed2454170bb836ead509b8e969 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 12:05:04 +0000 Subject: [PATCH 07/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index e9c50bb3e6c7..12dbff53d64e 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -29,7 +29,7 @@ def main() -> None: xgb.fit(x_train, y_train) # Display Confusion Matrix of Classifier - #with both train and test sets + # with both train and test sets plot_confusion_matrix( xgb, x_test, @@ -40,7 +40,6 @@ def main() -> None: ) plt.title("Normalized Confusion Matrix - IRIS Dataset") plt.show() - if __name__ == "__main__": From d795ac42af4e9e01c3efd1e29ac1103cbb68d620 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 13 Oct 2022 17:59:35 +0530 Subject: [PATCH 08/55] Fixes: #{6551} --- machine_learning/xgboostclassifier.py | 1 - 1 file changed, 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 12dbff53d64e..04e4318757e8 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -23,7 +23,6 @@ def main() -> None: x_train, x_test, y_train, y_test = train_test_split( x, y, test_size=0.3, random_state=1 ) - # XGBoost Classifier xgb = XGBClassifier() xgb.fit(x_train, y_train) From e16b32bd1638ac5422f3f2894a232f73ca31c806 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:55:54 +0530 Subject: [PATCH 09/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 04e4318757e8..c98d29d9d710 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -5,6 +5,18 @@ from sklearn.model_selection import train_test_split from xgboost import XGBClassifier +def data_handling(): + iris=load_iris() + # Split dataset into train and test data + x = iris["data"] # features + y = iris["target"] + return x,y + +def XGBoost(features,target): + classifier=XGBClassifier() + classifier.fit(features,target) + return classifier + def main() -> None: @@ -15,17 +27,14 @@ def main() -> None: """ # Load Iris dataset - iris = load_iris() - - # Split dataset into train and test data - x = iris["data"] # features - y = iris["target"] + features,target = data_handling() x_train, x_test, y_train, y_test = train_test_split( - x, y, test_size=0.3, random_state=1 + features, target, test_size=0.25, random_state=1 ) + + # XGBoost Classifier - xgb = XGBClassifier() - xgb.fit(x_train, y_train) + xgb = XGBoost(x_train, y_train) # Display Confusion Matrix of Classifier # with both train and test sets From f797b34d624269bcb9974c42e0f7b0245f195089 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:26:56 +0000 Subject: [PATCH 10/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index c98d29d9d710..84e6a9df5e69 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -5,18 +5,20 @@ from sklearn.model_selection import train_test_split from xgboost import XGBClassifier + def data_handling(): - iris=load_iris() + iris = load_iris() # Split dataset into train and test data x = iris["data"] # features y = iris["target"] - return x,y - -def XGBoost(features,target): - classifier=XGBClassifier() - classifier.fit(features,target) + return x, y + + +def XGBoost(features, target): + classifier = XGBClassifier() + classifier.fit(features, target) return classifier - + def main() -> None: @@ -27,12 +29,11 @@ def main() -> None: """ # Load Iris dataset - features,target = data_handling() + features, target = data_handling() x_train, x_test, y_train, y_test = train_test_split( features, target, test_size=0.25, random_state=1 ) - # XGBoost Classifier xgb = XGBoost(x_train, y_train) From bd88865dcaddcdec96629a97ff4df0dd77914930 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:03:45 +0530 Subject: [PATCH 11/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 84e6a9df5e69..74187a49e4d8 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,15 +6,14 @@ from xgboost import XGBClassifier -def data_handling(): - iris = load_iris() +def data_handling(data): # Split dataset into train and test data - x = iris["data"] # features - y = iris["target"] + x = data["data"] # features + y = data["target"] return x, y -def XGBoost(features, target): +def xgboost(features, target): classifier = XGBClassifier() classifier.fit(features, target) return classifier @@ -29,13 +28,14 @@ def main() -> None: """ # Load Iris dataset - features, target = data_handling() + iris=load_iris() + features, target = data_handling(iris) x_train, x_test, y_train, y_test = train_test_split( features, target, test_size=0.25, random_state=1 ) # XGBoost Classifier - xgb = XGBoost(x_train, y_train) + xgb = xgboost(x_train, y_train) # Display Confusion Matrix of Classifier # with both train and test sets From 3cbd77bf640f473dba7655b08d477fc32efa31be Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:34:41 +0000 Subject: [PATCH 12/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 74187a49e4d8..a7094c79f19f 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -28,7 +28,7 @@ def main() -> None: """ # Load Iris dataset - iris=load_iris() + iris = load_iris() features, target = data_handling(iris) x_train, x_test, y_train, y_test = train_test_split( features, target, test_size=0.25, random_state=1 From 06b698112a824dbd5e8c1cca49dbe433cec92c87 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:18:13 +0530 Subject: [PATCH 13/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index a7094c79f19f..1e9a4bb6b5cf 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -4,9 +4,10 @@ from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier +from doctest import testmod -def data_handling(data): +def data_handling(data) -> list: # Split dataset into train and test data x = data["data"] # features y = data["target"] @@ -52,4 +53,4 @@ def main() -> None: if __name__ == "__main__": - main() + testmod(name ='main', verbose = True) From 051981420ece472fbf3ac0edf53c83749bf66f6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 15:50:20 +0000 Subject: [PATCH 14/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 1e9a4bb6b5cf..fcfd1dd52eb2 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,10 +1,11 @@ # XGBoost Classifier Example +from doctest import testmod + from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier -from doctest import testmod def data_handling(data) -> list: @@ -53,4 +54,4 @@ def main() -> None: if __name__ == "__main__": - testmod(name ='main', verbose = True) + testmod(name="main", verbose=True) From bc690ddb2b9921ab7e2c2f2ea6c3abd29b47c8d6 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 21:30:35 +0530 Subject: [PATCH 15/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index fcfd1dd52eb2..f6e71483d0f7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,6 +1,4 @@ # XGBoost Classifier Example -from doctest import testmod - from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix @@ -8,14 +6,14 @@ from xgboost import XGBClassifier -def data_handling(data) -> list: +def data_handling(data: list) -> tuple: # Split dataset into train and test data x = data["data"] # features y = data["target"] return x, y -def xgboost(features, target): +def xgboost(features: list, target: list): classifier = XGBClassifier() classifier.fit(features, target) return classifier @@ -54,4 +52,4 @@ def main() -> None: if __name__ == "__main__": - testmod(name="main", verbose=True) + main() From 3b899b102bfc8358a48dc123e347c1ffa34fdde5 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:02:31 +0530 Subject: [PATCH 16/55] Fixes : #6551 --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index f6e71483d0f7..9225cf2546aa 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple: +def data_handling(data: list) -> tuple[int,str]: # Split dataset into train and test data x = data["data"] # features y = data["target"] From 8c111ca313a4969d09b825da1692de1bfcc7cf74 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 16:33:46 +0000 Subject: [PATCH 17/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 9225cf2546aa..ce2c1ea78d94 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple[int,str]: +def data_handling(data: list) -> tuple[int, str]: # Split dataset into train and test data x = data["data"] # features y = data["target"] From 08cf249c120df8829e07847a9781973f2b0a615c Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:09:33 +0530 Subject: [PATCH 18/55] Fixes : #6551 --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index ce2c1ea78d94..307bf04d33d4 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple[int, str]: +def data_handling(data: list) -> tuple[list, list]: # Split dataset into train and test data x = data["data"] # features y = data["target"] From c282905ff9e1f3616eabb987f5d43527c66afd68 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:13:33 +0530 Subject: [PATCH 19/55] Fixes : #6551 --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 307bf04d33d4..f6e71483d0f7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple[list, list]: +def data_handling(data: list) -> tuple: # Split dataset into train and test data x = data["data"] # features y = data["target"] From 776162d7ce58c8981f77ca4cbcd89c9d8b24467a Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 14 Oct 2022 22:48:31 +0530 Subject: [PATCH 20/55] Fixes: #6551 --- machine_learning/xgboostclassifier.py | 46 ++++++++++++--------------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index f6e71483d0f7..4b33cfe923bc 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,18 +6,27 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple: +def data_handling(data: list) -> tuple[list,list,list]: # Split dataset into train and test data - x = data["data"] # features - y = data["target"] - return x, y + x=(data["data"],data["target"],data['target_names']) #data is features + return x -def xgboost(features: list, target: list): +def xgboost(features: list, target: list,test_features: list,test_targets: list,namesofflowers: list) -> None: classifier = XGBClassifier() classifier.fit(features, target) - return classifier - + # Display Confusion Matrix of Classifier + # with both train and test sets + plot_confusion_matrix( + classifier, + test_features, + test_targets, + display_labels=namesofflowers, + cmap="Blues", + normalize="true", + ) + plt.title("Normalized Confusion Matrix - IRIS Dataset") + plt.show() def main() -> None: @@ -29,27 +38,14 @@ def main() -> None: # Load Iris dataset iris = load_iris() - features, target = data_handling(iris) + + features, target, names = data_handling(iris) + x_train, x_test, y_train, y_test = train_test_split( - features, target, test_size=0.25, random_state=1 - ) + features, target, test_size=0.25) # XGBoost Classifier - xgb = xgboost(x_train, y_train) - - # Display Confusion Matrix of Classifier - # with both train and test sets - plot_confusion_matrix( - xgb, - x_test, - y_test, - display_labels=iris["target_names"], - cmap="Blues", - normalize="true", - ) - plt.title("Normalized Confusion Matrix - IRIS Dataset") - plt.show() - + xgboost(x_train, y_train,x_test,y_test,names) if __name__ == "__main__": main() From 93f1c64d0be45b0ecb38760555a1886a0364e72d Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 17:19:34 +0000 Subject: [PATCH 21/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 4b33cfe923bc..9d21aa78c396 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,13 +6,19 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple[list,list,list]: +def data_handling(data: list) -> tuple[list, list, list]: # Split dataset into train and test data - x=(data["data"],data["target"],data['target_names']) #data is features + x = (data["data"], data["target"], data["target_names"]) # data is features return x -def xgboost(features: list, target: list,test_features: list,test_targets: list,namesofflowers: list) -> None: +def xgboost( + features: list, + target: list, + test_features: list, + test_targets: list, + namesofflowers: list, +) -> None: classifier = XGBClassifier() classifier.fit(features, target) # Display Confusion Matrix of Classifier @@ -28,6 +34,7 @@ def xgboost(features: list, target: list,test_features: list,test_targets: list, plt.title("Normalized Confusion Matrix - IRIS Dataset") plt.show() + def main() -> None: """ @@ -38,14 +45,16 @@ def main() -> None: # Load Iris dataset iris = load_iris() - + features, target, names = data_handling(iris) - + x_train, x_test, y_train, y_test = train_test_split( - features, target, test_size=0.25) + features, target, test_size=0.25 + ) # XGBoost Classifier - xgboost(x_train, y_train,x_test,y_test,names) + xgboost(x_train, y_train, x_test, y_test, names) + if __name__ == "__main__": main() From 49a6223410aecbcce858f54532c013916422ef36 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:13:19 +0530 Subject: [PATCH 22/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 9d21aa78c396..151f72c3d711 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple[list, list, list]: +def data_handling(data: list) -> tuple: # Split dataset into train and test data x = (data["data"], data["target"], data["target_names"]) # data is features return x From 147bfd4aaef023edf59da1bcb8c139e463b8967e Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:17:55 +0530 Subject: [PATCH 23/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 151f72c3d711..cbe17e718e7c 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -6,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: list) -> tuple: +def data_handling(data) -> tuple: # Split dataset into train and test data x = (data["data"], data["target"], data["target_names"]) # data is features return x From 44516837faea77e2e37dc4a6229bf5e9af6fe493 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:33:56 +0530 Subject: [PATCH 24/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index cbe17e718e7c..abf39097a406 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -4,9 +4,10 @@ from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier +from doctest import testmod -def data_handling(data) -> tuple: +def data_handling(data : dict) -> tuple[array,array,array]: # Split dataset into train and test data x = (data["data"], data["target"], data["target_names"]) # data is features return x @@ -57,4 +58,6 @@ def main() -> None: if __name__ == "__main__": + testmod(name ='main', verbose = True) + testmod(name ='xgboost', verbose = True) main() From 489822d24c544264154fa6a54d63bd4a40a79e80 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 19:06:07 +0000 Subject: [PATCH 25/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index abf39097a406..7c939cff43d2 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,13 +1,14 @@ # XGBoost Classifier Example +from doctest import testmod + from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier -from doctest import testmod -def data_handling(data : dict) -> tuple[array,array,array]: +def data_handling(data: dict) -> tuple[array, array, array]: # Split dataset into train and test data x = (data["data"], data["target"], data["target_names"]) # data is features return x @@ -58,6 +59,6 @@ def main() -> None: if __name__ == "__main__": - testmod(name ='main', verbose = True) - testmod(name ='xgboost', verbose = True) + testmod(name="main", verbose=True) + testmod(name="xgboost", verbose=True) main() From 844b4be23e27ae655bf5ab4a8873998d1aef7c4d Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:41:31 +0530 Subject: [PATCH 26/55] Fixes: #6551 --- machine_learning/xgboostclassifier.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 7c939cff43d2..cbfe8d13ed9f 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,6 +1,4 @@ # XGBoost Classifier Example -from doctest import testmod - from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix @@ -8,7 +6,7 @@ from xgboost import XGBClassifier -def data_handling(data: dict) -> tuple[array, array, array]: +def data_handling(data: dict) -> tuple: # Split dataset into train and test data x = (data["data"], data["target"], data["target_names"]) # data is features return x @@ -59,6 +57,7 @@ def main() -> None: if __name__ == "__main__": - testmod(name="main", verbose=True) - testmod(name="xgboost", verbose=True) + doctest.testmod(name="main", verbose=True) + doctest.testmod(name="xgboost", verbose=True) + doctest.testmod(name="data_handling", verbose=True) main() From 79603f77b2937677ddac54e094541f1b7ddd6893 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:45:30 +0530 Subject: [PATCH 27/55] Fixes #6551 --- machine_learning/xgboostclassifier.py | 1 + 1 file changed, 1 insertion(+) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index cbfe8d13ed9f..35a8d90eb244 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -4,6 +4,7 @@ from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier +import doctest def data_handling(data: dict) -> tuple: From 5751029f023e9ab0227599db24d0e73ab401b50e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 19:16:24 +0000 Subject: [PATCH 28/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 35a8d90eb244..150b3ab1680b 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,10 +1,11 @@ # XGBoost Classifier Example +import doctest + from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier -import doctest def data_handling(data: dict) -> tuple: From 9e77f6433284813e2240b66c6eb9ed1728a4c25b Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 00:52:14 +0530 Subject: [PATCH 29/55] Fixes: {#6551} --- machine_learning/xgboostclassifier.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 150b3ab1680b..c434f3715e67 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,6 +1,4 @@ # XGBoost Classifier Example -import doctest - from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix @@ -59,7 +57,8 @@ def main() -> None: if __name__ == "__main__": + import doctest doctest.testmod(name="main", verbose=True) doctest.testmod(name="xgboost", verbose=True) doctest.testmod(name="data_handling", verbose=True) - main() + #main() From 0ccc63fe11e28450187515c3661114194643957b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 19:23:10 +0000 Subject: [PATCH 30/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index c434f3715e67..263f5cfb65a6 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -58,7 +58,8 @@ def main() -> None: if __name__ == "__main__": import doctest + doctest.testmod(name="main", verbose=True) doctest.testmod(name="xgboost", verbose=True) doctest.testmod(name="data_handling", verbose=True) - #main() + # main() From f44646b2b7dadbb7f6a519baf7584a8ee212b3b1 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 01:33:59 +0530 Subject: [PATCH 31/55] Fixes: {#6551} --- machine_learning/xgboostclassifier.py | 41 ++++++++++++--------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 263f5cfb65a6..fe2df38753fb 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -12,29 +12,11 @@ def data_handling(data: dict) -> tuple: return x -def xgboost( - features: list, - target: list, - test_features: list, - test_targets: list, - namesofflowers: list, -) -> None: +def xgboost(features: list,target: list) # -> returns a trained model: classifier = XGBClassifier() classifier.fit(features, target) - # Display Confusion Matrix of Classifier - # with both train and test sets - plot_confusion_matrix( - classifier, - test_features, - test_targets, - display_labels=namesofflowers, - cmap="Blues", - normalize="true", - ) - plt.title("Normalized Confusion Matrix - IRIS Dataset") - plt.show() - - + return classifier + def main() -> None: """ @@ -53,7 +35,20 @@ def main() -> None: ) # XGBoost Classifier - xgboost(x_train, y_train, x_test, y_test, names) + xgb=xgboost(x_train, y_train) + + # Display Confusion Matrix of Classifier + # with both train and test sets + plot_confusion_matrix( + classifier, + x_test, + y_test, + display_labels=names, + cmap="Blues", + normalize="true", + ) + plt.title("Normalized Confusion Matrix - IRIS Dataset") + plt.show() if __name__ == "__main__": @@ -62,4 +57,4 @@ def main() -> None: doctest.testmod(name="main", verbose=True) doctest.testmod(name="xgboost", verbose=True) doctest.testmod(name="data_handling", verbose=True) - # main() + #main() From ccf61cdcc89690d0325e38fba2e346c295e3f45a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:04:54 +0000 Subject: [PATCH 32/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index fe2df38753fb..0b8ba07a74a8 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -16,7 +16,7 @@ def xgboost(features: list,target: list) # -> returns a trained model: classifier = XGBClassifier() classifier.fit(features, target) return classifier - + def main() -> None: """ @@ -36,7 +36,7 @@ def main() -> None: # XGBoost Classifier xgb=xgboost(x_train, y_train) - + # Display Confusion Matrix of Classifier # with both train and test sets plot_confusion_matrix( From 9c0bbff8e86ac4b474992fbc61ec17eae8007ff8 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 01:36:18 +0530 Subject: [PATCH 33/55] Fixes: #6551 --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 0b8ba07a74a8..5045827c12d5 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -12,7 +12,7 @@ def data_handling(data: dict) -> tuple: return x -def xgboost(features: list,target: list) # -> returns a trained model: +def xgboost(features: list,target: list) :# -> returns a trained model: classifier = XGBClassifier() classifier.fit(features, target) return classifier From 34d7dc333a34ca6864860ac3ae3da5e5d7de1e6b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Oct 2022 20:07:13 +0000 Subject: [PATCH 34/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 5045827c12d5..146aedb20678 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -12,11 +12,12 @@ def data_handling(data: dict) -> tuple: return x -def xgboost(features: list,target: list) :# -> returns a trained model: +def xgboost(features: list, target: list): # -> returns a trained model: classifier = XGBClassifier() classifier.fit(features, target) return classifier + def main() -> None: """ @@ -35,7 +36,7 @@ def main() -> None: ) # XGBoost Classifier - xgb=xgboost(x_train, y_train) + xgb = xgboost(x_train, y_train) # Display Confusion Matrix of Classifier # with both train and test sets @@ -57,4 +58,4 @@ def main() -> None: doctest.testmod(name="main", verbose=True) doctest.testmod(name="xgboost", verbose=True) doctest.testmod(name="data_handling", verbose=True) - #main() + # main() From 6d134592beba9e95f3f3466be91e1b6325e3a5ab Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Sat, 15 Oct 2022 01:41:54 +0530 Subject: [PATCH 35/55] FIXES: {#6551} --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 146aedb20678..1b72fd5df41b 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -41,7 +41,7 @@ def main() -> None: # Display Confusion Matrix of Classifier # with both train and test sets plot_confusion_matrix( - classifier, + xgb, x_test, y_test, display_labels=names, From 80d86c1524834ab132fa3cb8f3c426749fe34003 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 20 Oct 2022 00:35:31 +0530 Subject: [PATCH 36/55] Fixes : { #6551} --- machine_learning/xgboostclassifier.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 1b72fd5df41b..e27825f84ad9 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -8,7 +8,9 @@ def data_handling(data: dict) -> tuple: # Split dataset into train and test data - x = (data["data"], data["target"], data["target_names"]) # data is features + features = data["data"] # data is features + target = data["target"] + x=(train_test_split(features, target, test_size=0.25)) return x @@ -29,11 +31,9 @@ def main() -> None: # Load Iris dataset iris = load_iris() - features, target, names = data_handling(iris) + names = iris["target_names"] - x_train, x_test, y_train, y_test = train_test_split( - features, target, test_size=0.25 - ) + x_train, x_test, y_train, y_test = data_handling(iris) # XGBoost Classifier xgb = xgboost(x_train, y_train) @@ -58,4 +58,4 @@ def main() -> None: doctest.testmod(name="main", verbose=True) doctest.testmod(name="xgboost", verbose=True) doctest.testmod(name="data_handling", verbose=True) - # main() + main() From 5f9cae84af0eb38b6141bcb2f52bcde7ec246506 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 19:07:39 +0000 Subject: [PATCH 37/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index e27825f84ad9..5df7bd3a15d2 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -8,9 +8,9 @@ def data_handling(data: dict) -> tuple: # Split dataset into train and test data - features = data["data"] # data is features + features = data["data"] # data is features target = data["target"] - x=(train_test_split(features, target, test_size=0.25)) + x = train_test_split(features, target, test_size=0.25) return x @@ -33,7 +33,7 @@ def main() -> None: names = iris["target_names"] - x_train, x_test, y_train, y_test = data_handling(iris) + x_train, x_test, y_train, y_test = data_handling(iris) # XGBoost Classifier xgb = xgboost(x_train, y_train) From 22d8913364e248d3b99c175e4df38f5c462278a9 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 20 Oct 2022 04:30:50 +0530 Subject: [PATCH 38/55] Fixes : { #6551} --- machine_learning/xgboostclassifier.py | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 5df7bd3a15d2..4f136472f3dc 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -4,17 +4,27 @@ from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier +import numpy as np def data_handling(data: dict) -> tuple: # Split dataset into train and test data - features = data["data"] # data is features - target = data["target"] - x = train_test_split(features, target, test_size=0.25) + # data is features + """ + >>> data_handling(({'data':'[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]','target':([0,1])})) + ('[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]', [0, 1]) + >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2],[5. , 3.6, 1.4, 0.2],[5.4, 3.9, 1.7, 0.4]','target':([0,0, 0, 0, 0])}) + ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2],[5. , 3.6, 1.4, 0.2],[5.4, 3.9, 1.7, 0.4]', [0, 0, 0, 0, 0]) + """ + x = (data["data"],data["target"]) return x -def xgboost(features: list, target: list): # -> returns a trained model: +def xgboost(features: np.ndarray, target: np.ndarray): -> XGBClassifier: + """ + >>> xgboost(np.array([[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]]), np.array([1,2])) + XGBClassifier() + """ classifier = XGBClassifier() classifier.fit(features, target) return classifier @@ -23,6 +33,8 @@ def xgboost(features: list, target: list): # -> returns a trained model: def main() -> None: """ + >>> main() + The Url for the algorithm https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm. @@ -30,10 +42,11 @@ def main() -> None: # Load Iris dataset iris = load_iris() + features,targets= data_handling(iris) + x_train, x_test, y_train, y_test=train_test_split(features, targets, test_size=0.25) names = iris["target_names"] - x_train, x_test, y_train, y_test = data_handling(iris) # XGBoost Classifier xgb = xgboost(x_train, y_train) From 3f369875ba709313309e62b51805ee6e70f8a7bf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 23:02:26 +0000 Subject: [PATCH 39/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 4f136472f3dc..21399ad936fd 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -1,10 +1,10 @@ # XGBoost Classifier Example +import numpy as np from matplotlib import pyplot as plt from sklearn.datasets import load_iris from sklearn.metrics import plot_confusion_matrix from sklearn.model_selection import train_test_split from xgboost import XGBClassifier -import numpy as np def data_handling(data: dict) -> tuple: From a357282d613a72692b217ed9158b18b22010fafb Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 20 Oct 2022 04:34:51 +0530 Subject: [PATCH 40/55] Fixes: { #6551] --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 21399ad936fd..25ab08febc33 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -20,7 +20,7 @@ def data_handling(data: dict) -> tuple: return x -def xgboost(features: np.ndarray, target: np.ndarray): -> XGBClassifier: +def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: """ >>> xgboost(np.array([[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]]), np.array([1,2])) XGBClassifier() From ae11a525e307ea98e859f32cd704cd635c6b7ef2 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 19 Oct 2022 23:07:06 +0000 Subject: [PATCH 41/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 25ab08febc33..e796c1f36e7d 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -16,7 +16,7 @@ def data_handling(data: dict) -> tuple: >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2],[5. , 3.6, 1.4, 0.2],[5.4, 3.9, 1.7, 0.4]','target':([0,0, 0, 0, 0])}) ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2],[5. , 3.6, 1.4, 0.2],[5.4, 3.9, 1.7, 0.4]', [0, 0, 0, 0, 0]) """ - x = (data["data"],data["target"]) + x = (data["data"], data["target"]) return x @@ -42,12 +42,13 @@ def main() -> None: # Load Iris dataset iris = load_iris() - features,targets= data_handling(iris) - x_train, x_test, y_train, y_test=train_test_split(features, targets, test_size=0.25) + features, targets = data_handling(iris) + x_train, x_test, y_train, y_test = train_test_split( + features, targets, test_size=0.25 + ) names = iris["target_names"] - # XGBoost Classifier xgb = xgboost(x_train, y_train) From 8a423299413dac5c2c70d668b10f30813d166b42 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 20 Oct 2022 04:45:43 +0530 Subject: [PATCH 42/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index e796c1f36e7d..0fc9def48b21 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -11,10 +11,10 @@ def data_handling(data: dict) -> tuple: # Split dataset into train and test data # data is features """ - >>> data_handling(({'data':'[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]','target':([0,1])})) + >>> data_handling(({'data':'[5.1, 3.5, 1.4, 0.2]','target':([0])})) ('[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]', [0, 1]) - >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2],[5. , 3.6, 1.4, 0.2],[5.4, 3.9, 1.7, 0.4]','target':([0,0, 0, 0, 0])}) - ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2],[5. , 3.6, 1.4, 0.2],[5.4, 3.9, 1.7, 0.4]', [0, 0, 0, 0, 0]) + >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2]','target':([0,0, 0])}) + ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2]', [0, 0, 0]) """ x = (data["data"], data["target"]) return x @@ -22,7 +22,7 @@ def data_handling(data: dict) -> tuple: def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: """ - >>> xgboost(np.array([[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]]), np.array([1,2])) + >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2],[4.6, 3.4, 1.4, 0.7]]), np.array([1,2])) XGBClassifier() """ classifier = XGBClassifier() From d9cded2fe6da8758ee341e908a25d94217d20152 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Thu, 20 Oct 2022 04:56:34 +0530 Subject: [PATCH 43/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 0fc9def48b21..b8de930e75b2 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -12,8 +12,8 @@ def data_handling(data: dict) -> tuple: # data is features """ >>> data_handling(({'data':'[5.1, 3.5, 1.4, 0.2]','target':([0])})) - ('[5.1, 3.5, 1.4, 0.2],[4.6, 3.4, 1.4, 0.3]', [0, 1]) - >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2]','target':([0,0, 0])}) + ('[5.1, 3.5, 1.4, 0.2]', [0]) + >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2]','target':([0, 0])}) ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2]', [0, 0, 0]) """ x = (data["data"], data["target"]) From 682943f84a7164b3c51839226b2d1559ae877d5e Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 08:48:49 +0200 Subject: [PATCH 44/55] Apply suggestions from code review --- machine_learning/xgboostclassifier.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index b8de930e75b2..606ee67873cf 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -13,11 +13,12 @@ def data_handling(data: dict) -> tuple: """ >>> data_handling(({'data':'[5.1, 3.5, 1.4, 0.2]','target':([0])})) ('[5.1, 3.5, 1.4, 0.2]', [0]) - >>> data_handling({'data':'[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2]','target':([0, 0])}) + >>> data_handling( + ... {'data': '[4.9, 3.0, 1.4, 0.2], [4.7, 3.2, 1.3, 0.2]', 'target': ([0, 0])} + ... ) ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2]', [0, 0, 0]) """ - x = (data["data"], data["target"]) - return x + return (data["data"], data["target"]) def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: @@ -33,9 +34,7 @@ def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: def main() -> None: """ - >>> main() - - The Url for the algorithm + Url for the algorithm: https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm. """ @@ -49,13 +48,12 @@ def main() -> None: names = iris["target_names"] - # XGBoost Classifier - xgb = xgboost(x_train, y_train) + # Create an XGBoost Classifier from the training data + xgboost_classifier = xgboost(x_train, y_train) - # Display Confusion Matrix of Classifier - # with both train and test sets + # Display the confusion matrix of the classifier with both the training and test sets plot_confusion_matrix( - xgb, + xgboost_classifier, x_test, y_test, display_labels=names, @@ -69,7 +67,5 @@ def main() -> None: if __name__ == "__main__": import doctest - doctest.testmod(name="main", verbose=True) - doctest.testmod(name="xgboost", verbose=True) - doctest.testmod(name="data_handling", verbose=True) + doctest.testmod(verbose=True) main() From 0de2c82d82bbbc80c81c1d456e8359d67b96eba5 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 08:52:33 +0200 Subject: [PATCH 45/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 606ee67873cf..c7a94258def7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -16,7 +16,7 @@ def data_handling(data: dict) -> tuple: >>> data_handling( ... {'data': '[4.9, 3.0, 1.4, 0.2], [4.7, 3.2, 1.3, 0.2]', 'target': ([0, 0])} ... ) - ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2],[4.6, 3.1, 1.5, 0.2]', [0, 0, 0]) + ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2]', [0, 0]) """ return (data["data"], data["target"]) @@ -51,7 +51,7 @@ def main() -> None: # Create an XGBoost Classifier from the training data xgboost_classifier = xgboost(x_train, y_train) - # Display the confusion matrix of the classifier with both the training and test sets + # Display the confusion matrix of the classifier with both training and test sets plot_confusion_matrix( xgboost_classifier, x_test, From d04fd286336cc43ad3a3fd803cf7a91c5aa39021 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Thu, 20 Oct 2022 08:59:06 +0200 Subject: [PATCH 46/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index c7a94258def7..fd4965631c3c 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -16,7 +16,7 @@ def data_handling(data: dict) -> tuple: >>> data_handling( ... {'data': '[4.9, 3.0, 1.4, 0.2], [4.7, 3.2, 1.3, 0.2]', 'target': ([0, 0])} ... ) - ('[4.9, 3. , 1.4, 0.2],[4.7, 3.2, 1.3, 0.2]', [0, 0]) + ('[4.9, 3.0, 1.4, 0.2], [4.7, 3.2, 1.3, 0.2]', [0, 0]) """ return (data["data"], data["target"]) From 2c7f99cc0e7b59b3ce8d8ab6743f70e00e86d539 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 00:24:36 +0530 Subject: [PATCH 47/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index fd4965631c3c..b46b1eeaeb2c 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -34,6 +34,8 @@ def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: def main() -> None: """ + >>> main() + Url for the algorithm: https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm. From 1f3affb18f95f620f79936088079bab03248c65a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 18:57:05 +0000 Subject: [PATCH 48/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index b46b1eeaeb2c..b3ce85adf202 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -35,7 +35,7 @@ def main() -> None: """ >>> main() - + Url for the algorithm: https://xgboost.readthedocs.io/en/stable/ Iris type dataset is used to demonstrate algorithm. From 307122fb00cf301d68493f722bbad0343797e94c Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 00:42:08 +0530 Subject: [PATCH 49/55] Fixes: { #6551} --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index b3ce85adf202..c20da75593b6 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -23,7 +23,7 @@ def data_handling(data: dict) -> tuple: def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: """ - >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2],[4.6, 3.4, 1.4, 0.7]]), np.array([1,2])) + >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2],[4.6, 3.4, 1.4, 0.7]]), np.array([0,1])) XGBClassifier() """ classifier = XGBClassifier() From 7d42c2e74d884c24484552fb0533172313844e05 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 01:19:35 +0530 Subject: [PATCH 50/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index c20da75593b6..e9f70f2240eb 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -23,7 +23,7 @@ def data_handling(data: dict) -> tuple: def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: """ - >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2],[4.6, 3.4, 1.4, 0.7]]), np.array([0,1])) + >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2]]), np.array([1])) XGBClassifier() """ classifier = XGBClassifier() From 32a5206f5bf56708569ae307908c4fcf047e81b5 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 02:02:45 +0530 Subject: [PATCH 51/55] Fixes: { #6551} --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index e9f70f2240eb..ac0167447e83 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -23,7 +23,7 @@ def data_handling(data: dict) -> tuple: def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: """ - >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2]]), np.array([1])) + >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2]]), np.array([0])) XGBClassifier() """ classifier = XGBClassifier() From 32091d3955012553b734066adc589717533e812d Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 02:12:07 +0530 Subject: [PATCH 52/55] Update xgboostclassifier.py --- machine_learning/xgboostclassifier.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index ac0167447e83..25113f7356b7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -24,7 +24,16 @@ def data_handling(data: dict) -> tuple: def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: """ >>> xgboost(np.array([[5.1, 3.6, 1.4, 0.2]]), np.array([0])) - XGBClassifier() + XGBClassifier(base_score=0.5, booster='gbtree', callbacks=None, + colsample_bylevel=1, colsample_bynode=1, colsample_bytree=1, + early_stopping_rounds=None, enable_categorical=False, + eval_metric=None, gamma=0, gpu_id=-1, grow_policy='depthwise', + importance_type=None, interaction_constraints='', + learning_rate=0.300000012, max_bin=256, max_cat_to_onehot=4, + max_delta_step=0, max_depth=6, max_leaves=0, min_child_weight=1, + missing=nan, monotone_constraints='()', n_estimators=100, + n_jobs=0, num_parallel_tree=1, predictor='auto', random_state=0, + reg_alpha=0, reg_lambda=1) """ classifier = XGBClassifier() classifier.fit(features, target) From 98dc0091e35a9baea0732584a8c6311cd234c3e2 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 02:23:36 +0530 Subject: [PATCH 53/55] Fixes: ( #6551) --- machine_learning/xgboostclassifier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 25113f7356b7..c672df46d2b7 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -33,7 +33,8 @@ def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: max_delta_step=0, max_depth=6, max_leaves=0, min_child_weight=1, missing=nan, monotone_constraints='()', n_estimators=100, n_jobs=0, num_parallel_tree=1, predictor='auto', random_state=0, - reg_alpha=0, reg_lambda=1) + reg_alpha=0, reg_lambda=1,scale_pos_weight: 1, seed: None, + silent: None, subsample: 1, verbosity: 1) """ classifier = XGBClassifier() classifier.fit(features, target) From 6496c2c6c9e97febae22d07d53d7b8284f1ab2a7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 20 Oct 2022 20:56:40 +0000 Subject: [PATCH 54/55] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- machine_learning/xgboostclassifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index c672df46d2b7..00f93179a702 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -33,7 +33,7 @@ def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: max_delta_step=0, max_depth=6, max_leaves=0, min_child_weight=1, missing=nan, monotone_constraints='()', n_estimators=100, n_jobs=0, num_parallel_tree=1, predictor='auto', random_state=0, - reg_alpha=0, reg_lambda=1,scale_pos_weight: 1, seed: None, + reg_alpha=0, reg_lambda=1,scale_pos_weight: 1, seed: None, silent: None, subsample: 1, verbosity: 1) """ classifier = XGBClassifier() From c78ede94889238850fdad242e96e58dc0cacb4c5 Mon Sep 17 00:00:00 2001 From: Modassir Afzal <60973906+Moddy2024@users.noreply.github.com> Date: Fri, 21 Oct 2022 02:32:56 +0530 Subject: [PATCH 55/55] Fixes: { #6551} --- machine_learning/xgboostclassifier.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/machine_learning/xgboostclassifier.py b/machine_learning/xgboostclassifier.py index 00f93179a702..bb5b48b7ab23 100644 --- a/machine_learning/xgboostclassifier.py +++ b/machine_learning/xgboostclassifier.py @@ -8,7 +8,7 @@ def data_handling(data: dict) -> tuple: - # Split dataset into train and test data + # Split dataset into features and target # data is features """ >>> data_handling(({'data':'[5.1, 3.5, 1.4, 0.2]','target':([0])})) @@ -33,8 +33,7 @@ def xgboost(features: np.ndarray, target: np.ndarray) -> XGBClassifier: max_delta_step=0, max_depth=6, max_leaves=0, min_child_weight=1, missing=nan, monotone_constraints='()', n_estimators=100, n_jobs=0, num_parallel_tree=1, predictor='auto', random_state=0, - reg_alpha=0, reg_lambda=1,scale_pos_weight: 1, seed: None, - silent: None, subsample: 1, verbosity: 1) + reg_alpha=0, reg_lambda=1, ...) """ classifier = XGBClassifier() classifier.fit(features, target)