예제 #1
0
import xgboost as xgb
from sklearn.model_selection import RandomizedSearchCV,GridSearchCV,ShuffleSplit
from sklearn.metrics import classification_report, confusion_matrix, accuracy_score
from dataLoader import Dataloader

import matplotlib.pyplot as plt
import seaborn as sns

#Load Data
dl = Dataloader(normalization=True, select_features=["speed_max", "speed_mean", "speed_median", "speed_std"])

X_train, y_train = dl.getTrain()

X_test, y_test = dl.getTest()

X_validate, y_validate = dl.getValidate()

print(X_train.shape)
print(y_train.shape)

classes = {
            "walk":0,
            "bike":1,
            "bus":2,
            "taxi/car": 3,
            "subway/train":4
        }

inv_map = {v: k for k, v in classes.items()}

#Base Model
예제 #2
0
    plt.axis('off')

plt.style.use('ggplot')     # if want to use the default style, set 'classic'
plt.rcParams['ytick.right']     = True
plt.rcParams['ytick.labelright']= True
plt.rcParams['ytick.left']      = False
plt.rcParams['ytick.labelleft'] = False
plt.rcParams['font.family']     = 'Arial'
modelname = 'pre-1'
seed = 7
np.random.seed(seed)

# .............................................................................
dl = Dataloader(normalization=True, noise_removal=True)
x_train, y_train = dl.getTrain()
x_val, y_val = dl.getValidate()

#enc = OneHotEncoder(categories=[classes],handle_unknown='ignore',drop=[0])
y_train = to_categorical(y_train)
y_val = to_categorical(y_val)

x_train = np.expand_dims(x_train,axis=2)
x_val = np.expand_dims(x_val,axis=2)

dat = tf.convert_to_tensor(x_train)
lbl = tf.convert_to_tensor(y_train)
ds = tf.data.Dataset.from_tensor_slices((dat, lbl))
dataset = ds.shuffle(1000).batch(1).repeat()

dat = tf.convert_to_tensor(x_val)
lbl = tf.convert_to_tensor(y_val)