This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:13-alpine | |
ENV MONGO_DB_USERNAME=admin \ | |
MONGO_DB_PWD=password | |
RUN mkdir -p /home/app | |
COPY ./app /home/app | |
# set default dir so that next commands executes in /home/app dir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
# my-app: | |
# image: ${docker-registry}/my-app:1.0 | |
# ports: | |
# - 3000:3000 | |
mongodb: | |
image: mongo | |
ports: | |
- 27017:27017 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loss, accuracy = model.evaluate(X_test,y_test) | |
print('Testing Accuracy is {} '.format(accuracy*100)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loss, accuracy = model.evaluate(X_train, y_train, verbose=1) | |
print('Training Accuracy is {}'.format(accuracy*100)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
model = Sequential() | |
model.add(Embedding(vocab_size, 8, input_length=max_length)) | |
model.add(Flatten()) | |
model.add(Dense(1, activation='sigmoid')) | |
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['acc']) | |
print(model.summary()) | |
model.fit(X_train, y_train, epochs=20, verbose=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max_length = 1719 | |
X_train = pad_sequences(X_train, maxlen=max_length, padding='pre') | |
X_test = pad_sequences(X_test, maxlen=max_length, padding='pre') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maxlen=-1 | |
for doc in X_train: | |
if(maxlen<len(doc)): | |
maxlen=len(doc) | |
print(maxlen) | |
print("The maximum number of words in any document is : ",maxlen) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(X_train.iloc[1]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = Tokenizer() | |
t.fit_on_texts(docs) | |
vocab_size = len(t.word_index) + 1 | |
# integer encode the documents | |
print(vocab_size) | |
X_train = [one_hot(d, vocab_size,filters='!"#$%&()*+,-./:;<=>?@[\]^_`{|}~',lower=True, split=' ') for d in X_train] | |
X_test = [one_hot(d, vocab_size,filters='!"#$%&()*+,-./:;<=>?@[\]^_`{|}~',lower=True, split=' ') for d in X_test] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docs = df['review'] | |
labels = array(df['sentiment']) | |
from sklearn.model_selection import train_test_split | |
X_train, X_test , y_train, y_test = train_test_split(docs, labels , test_size = 0.40) |
NewerOlder