Skip to content

Instantly share code, notes, and snippets.

View andrea-dagostino's full-sized avatar

Andrea D'Agostino andrea-dagostino

View GitHub Profile
# 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)
@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
@andrea-dagostino
andrea-dagostino / tensorflow_binary_image_classfication_eng6.py
Created May 30, 2022 20:33
tensorflow_binary_image_classfication
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
# 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(
# [...]
)
# 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",