Hi everybody!
This is elmazzun, Linux enthusiast.
For your own safety, do NOT clone any of my repositories as they are just a huge personal learning space where I study different topics.
Hyperparameter Tuning with Keras
Hi everybody!
This is elmazzun, Linux enthusiast.
For your own safety, do NOT clone any of my repositories as they are just a huge personal learning space where I study different topics.
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 8 17:22:19 2023
@author: gostl
"""
import numpy as np
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense, LSTM, Embedding, Bidirectional, GlobalAveragePooling1D, Dropout
from keras.preprocessing.text import Tokenizer
from tensorflow.keras.preprocessing.sequence import pad_sequences
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
import tensorflow as tf
import keras.utils as ku
data=pd.read_csv(r"C:\Users\gostl\OneDrive\Desktop\data\movie_reviews.csv")[:10000]
y=data["sentiment"]
y = np.array(list(map(lambda x: 1 if x=="positive" else 0, y))).astype("float32")
x_train,x_test,y_train,y_test=train_test_split(data["review"],y,test_size=0.3)
t=Tokenizer()
t.fit_on_texts(x_train)
x_train=t.texts_to_sequences(x_train)
x_test=t.texts_to_sequences(x_test)
voc_size=len(t.word_index)
max_words=300
x_train=pad_sequences(x_train, maxlen=max_words)
x_test=pad_sequences(x_test, maxlen=max_words)
batch_size=30
x_train2,y_train2=x_train[batch_size:],y_train[batch_size:]
x_val,y_val=x_train[:batch_size],y_train[:batch_size]
model=Sequential()
model.add(Embedding(voc_size+1, 512, input_length=max_words))
model.add(LSTM(100))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss="binary_crossentropy", metrics="accuracy")
model.fit(x_train2,y_train2, validation_data=(x_val,y_val),batch_size=batch_size, epochs=5)
y_pred=model.predict(x_test)
y_score=[1 if i>0.5 else 0 for i in y_pred]
score=model.evaluate(x_test,y_test)
print(score)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.