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
# let's create the dataset with time windows | |
dataset = windowed_dataset(series_train) | |
# we divide into training and validation set | |
time_train, series_train, time_valid, series_valid = train_val_split(G.TIME, G.SERIES) |
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
def fuzzy_tagging(tags, articles): | |
""" | |
This function receives as input a list of predefined tags and the list of textual content to be tagged. | |
Returns a Pandas dataframe with the articles tagged | |
""" | |
results = [] | |
# iterate through tags | |
for i, tag in enumerate(tags): | |
d = {} | |
ranking = process.extract(tag, articles, limit=4) # extract the tag, ranking the 4 articles most representative |
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
import numpy as np | |
from google.colab import files | |
from keras.preprocessing import image | |
uploaded = files.upload() | |
for fn in uploaded.keys(): | |
# prediction on the uploaded image |
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
# output layer | |
layers.Dense(2, activation="softmax", name="output") |
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
# output layer | |
layers.Dense(1, name="output") |
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 = keras.Sequential( | |
[ | |
layers.Dense(256, input_dim=4, activation="relu", name="input") | |
layers.Dense(128, activation="relu", name="layer1"), | |
layers.Dense(64, activation="relu", name="layer2"), | |
# ... | |
] | |
) |
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
# input layer | |
layers.Dense(256, input_dim=4, activation="relu", name="input") |
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
import tensorflow as tf | |
from tensorflow import keras | |
from tensorflow.keras import layers | |
model = keras.Sequential( | |
# [...] | |
) |
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
# upload the dataset and isolate posts | |
df = pd.read_csv('dataset.csv') | |
posts = df[df.url.str.contains('post')] | |
posts.reset_index(inplace=True, drop=True) | |
articles = list(posts.article) |
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
# these are the tags we want to apply to our documents. | |
# change this list at your discretion | |
tags = [ | |
"machine learning", | |
"clustering", | |
"carriera", # "career" in ita | |
"progetto", # "project" in ita | |
"consigli", # "tips" in ita | |
"analytics", | |
"deep learning", |
NewerOlder