# Load Data dataset = load_iris() # X, Y import pandas as pd X = pd.DataFrame(dataset.data, columns=dataset.feature_names) Y = pd.DataFrame(dataset.target, columns=["Iris_Type"]) Y_name = dataset.target_names.tolist() # Load HappyML from HappyML.preprocessor import KBestSelector import HappyML.preprocessor as pp # Feature Selection selector = KBestSelector(best_k=2) X = selector.fit(x_ary=X, y_ary=Y, verbose=True, sort=True).transform(x_ary=X) # Split Training / TEsting Set X_train, X_test, Y_train, Y_test = pp.split_train_test(x_ary=X, y_ary=Y) # Feature Scaling X_train, X_test = pp.feature_scaling(fit_ary=X_train, transform_arys=(X_train, X_test)) # In[] Comparison: Naive Bayes from HappyML.classification import NaiveBayesClassifier clr_bayes = NaiveBayesClassifier() Y_pred_bayes = clr_bayes.fit(X_train, Y_train).predict(X_test)
# Load Data dataset = load_iris() # X, Y import pandas as pd X = pd.DataFrame(dataset.data, columns=dataset.feature_names) Y = pd.DataFrame(dataset.target, columns=["Iris_Type"]) Y_name = dataset.target_names.tolist() # One_hot incoder for Y Y = pp.onehot_encoder(ary=Y, columns=[0]) # Feature Selection from HappyML.preprocessor import KBestSelector selector = KBestSelector(best_k="auto") X = selector.fit(x_ary=X, y_ary=Y, auto=False, verbose=True, sort=True).transform(x_ary=X) # Split Training / Testing Set X_train, X_test, Y_train, Y_test = pp.split_train_test(x_ary=X, y_ary=Y) # Feature Scaling X_train, X_test = pp.feature_scaling(fit_ary=X_train, transform_arys=(X_train, X_test)) # In[] Neural Networks without HappyML's Class from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense # Initialize the whole Neural Networks