Beispiel #1
0
from src import dataModifier as DM
from keras.preprocessing.text import Tokenizer

dataJS = DM.json_load("data/train.json/train.json")

TextTypes = ["description"]
AnswerTypes = ["interest_level"]

tupeConvert = {"interest_level": {"low": 0, "medium": 1, "high": 2}}

TextData = np.asarray(DM.get_arr(dataJS, TextTypes))
AnswerData = np.array(
    DM.get_arr(DM.modifier_fiches_type(dataJS, tupeConvert), AnswerTypes))

X = TextData
Y = DM.to_one_hot(AnswerData)

#нормализация
np.random.seed(2)

indices = DM.mixedIndex(X)
X = X[indices]
Y = Y[indices]

val_split = int(X.shape[0] * 0.6)

X_train = X[:val_split]
X_val = X[val_split:]
Y_train = Y[:val_split]
Y_val = Y[val_split:]
Beispiel #2
0
Time = DM.time_to_HMS(DM.fullData_to_time(FullTimeData))
X = np.column_stack((DigitData, Data, Time))

X = np.asarray(X).astype('float32')
Y = np.asarray(Y).astype('int')

#нормализация
np.random.seed(2)

indices = DM.mixedIndex(X)
X = X[indices]
Y = Y[indices]

#нормализация
X = DM.normalization(X)
Y = DM.to_one_hot(Y)

from keras import models
from keras import layers
from keras import regularizers
from keras.optimizers import RMSprop

model = models.Sequential()
model.add(layers.Dense(32, activation='relu', input_shape=(X.shape[1], )))
model.add(layers.Dropout(0.15))
model.add(layers.Dense(32, activation='relu'))
model.add(layers.Dropout(0.02))
#model.add(layers.Dense(32,activation='relu'))
#model.add(layers.Dense(16,activation='relu'))
model.add(layers.Dense(3, activation='softmax'))