Skip to content

Instantly share code, notes, and snippets.

View andrea-dagostino's full-sized avatar

Andrea D'Agostino andrea-dagostino

View GitHub Profile
# output layer
layers.Dense(2, activation="softmax", name="output")
# output layer
layers.Dense(1, name="output")
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"),
# ...
]
)
# input layer
layers.Dense(256, input_dim=4, activation="relu", name="input")
@andrea-dagostino
andrea-dagostino / seq1.py
Created November 21, 2022 09:11
seq_model
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
model = keras.Sequential(
# [...]
)
@andrea-dagostino
andrea-dagostino / fuzzy_logic_tagging_eng3.py
Last active March 27, 2023 11:59
fuzzy_logic_tagging
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
# 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)
# 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",
from thefuzz import fuzz, process
import pandas as pd
# definiamo le categorie che vogliamo applicare
tags = [
"machine learning",
"clustering",
"carriera",
"progetto",
"consigli",
tagged_df = fuzzy_tagging(tags=tags, articles=articles)
tagged_df