def balance_class_balance(path="images/class_balance.png"): data = load_game() y = data["outcome"] oz = ClassBalance(labels=["draw", "loss", "win"]) oz.fit(y) return oz.poof(outpath=path)
def compare_class_balance(path="images/class_balance_compare.png"): data = load_occupancy() features = ["temperature", "relative_humidity", "light", "C02", "humidity"] classes = ['unoccupied', 'occupied'] # Extract the numpy arrays from the data frame X = data[features] y = data["occupancy"] # Create the train and test data _, _, y_train, y_test = train_test_split(X, y, test_size=0.2) # Instantiate the classification model and visualizer visualizer = ClassBalance(labels=classes) visualizer.fit(y_train, y_test) return visualizer.poof(outpath=path)
else: o[(index * n_ngrams) + i] = features bs = bs[~np.all(bs == 0, axis=1)] o = o[~np.all(o == 0, axis=1)] binding_sites = bs other = o binding_sites_labels = np.ones(binding_sites.shape[0], dtype=np.uint8) other_labels = np.zeros(other.shape[0], dtype=np.uint8) X = np.concatenate((binding_sites, other)) y = np.concatenate((binding_sites_labels, other_labels)) # %% visualizer = ClassBalance(labels=class_names) visualizer.fit(y) visualizer.poof() # %% visualizer = ParallelCoordinates() visualizer.fit_transform(X, y) visualizer.poof() # %% visualizer = Rank1D() visualizer.fit(X, y) visualizer.transform(X) visualizer.poof() # %% visualizer = Rank2D() visualizer.fit_transform(X)
def visualizeClassImbalance(labels_train, lables_test=None): visualizer = ClassBalance(labels=["boring", "interesting"]) visualizer.fit(labels_train, lables_test) visualizer.poof()
def class_balance(classes, y): from yellowbrick.target import ClassBalance visualizer = ClassBalance(labels=classes) visualizer.fit(y) visualizer.poof()
min_impurity_decrease=0.0, min_impurity_split=None, min_samples_leaf=1, min_samples_split=2, min_weight_fraction_leaf=0.0, presort='deprecated', random_state=0, splitter='best') viz = FeatureImportances(dt) viz.fit(X_train, y_train) viz.show(); from yellowbrick.classifier import ROCAUC visualizer = ROCAUC(rf, classes = ['stayed','quit']) visualizer.fit(X_train, y_train) visualizer.score(X_test, y_test) visualizer.poof(); from yellowbrick.classifier import ROCAUC visualizer = ROCAUC(dt, classes = ['stayed','quit']) visualizer.fit(X_train, y_train) visualizer.score(X_test, y_test) visualizer.poof(); """### So, I can sayb the Random Forest Classifier performed better in this dataset. Thanks for Checking this out! ---
def draw_class_balance(self): visualizer = ClassBalance(labels=self.le.classes_) visualizer.fit(self.training_labels) visualizer.poof()