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
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
# 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", |
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 thefuzz import fuzz, process | |
import pandas as pd | |
# definiamo le categorie che vogliamo applicare | |
tags = [ | |
"machine learning", | |
"clustering", | |
"carriera", | |
"progetto", | |
"consigli", |
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
tagged_df = fuzzy_tagging(tags=tags, articles=articles) | |
tagged_df |
NewerOlder