July 2019
Beginner to intermediate
298 pages
7h 20m
English
We can now proceed and create the ensemble. Again, we will first evaluate the ensemble on the original dataset, and then proceed to test it on the filtered dataset. The code is similar to the previous example. First, we load the libraries and data, and create train and test splits as follows:
# --- SECTION 1 ---# Libraries and data loadingimport numpy as npimport pandas as pdfrom sklearn.ensemble import VotingClassifierfrom sklearn.tree import DecisionTreeClassifierfrom sklearn.linear_model import LogisticRegressionfrom sklearn.naive_bayes import GaussianNBfrom sklearn.model_selection import train_test_splitfrom sklearn import metricsnp.random.seed(123456)data = pd.read_csv('creditcard.csv')data.Time = (data.Time-data.Time.min())/data.Time.std() ...Read now
Unlock full access