Skip to content

Instantly share code, notes, and snippets.

View andreaschandra's full-sized avatar
💼
work at anywhere

Andreas Chandra andreaschandra

💼
work at anywhere
View GitHub Profile
class Classifier(nn.Module):
def __init__(self):
super(Classifier, self).__init__()
self.NeurlNet = nn.Sequential(
nn.Linear(50, 40),
nn.ReLU(),
nn.Linear(40, 30),
nn.ReLU(),
nn.Linear(30, 1)
)
cv = CountVectorizer()
X_train = cv.fit_transform(d_train.content_cleansing)
X_test = cv.transform(d_test.content_cleansing)
def cleansing(text):
word_list = word_tokenize(text)
word_list = [word for word in word_list if len(word) > 2 and word.isalnum()]
word_list = [word for word in word_list if string.punctuation not in word]
text = ' '.join(word_list)
return text
data_path = 'data'
files = glob.glob(data_path + '/*')
train = pickle.load(open(files[1], 'rb'))
test = pickle.load(open(files[0], 'rb'))
d_train = pd.DataFrame(data={'content': train[0], 'label': train[1]})
d_test = pd.DataFrame(data={'content': test[0], 'label': test[1]})
import pandas as pd
import numpy as np
import glob
import re
import pickle
import seaborn as sns
import string
from nltk.tokenize import word_tokenize
for x in test train; do
echo $x
done
if [ $1 -le 10 ]; then
echo "less than"
echo "$0"
else
echo "Too large $1"
fi
## Arithmetic Operators
## Addition
$x + $y
## Subtraction
$x - $y
## Multiplication
$x * $y
city="Jakarta"
echo $city
echo Hello world
echo "Hello"
## you can also print out the file without specifically open it
cat nama_file.txt