Skip to content

Instantly share code, notes, and snippets.

View fgiobergia's full-sized avatar

Flavio Giobergia fgiobergia

View GitHub Profile
@fgiobergia
fgiobergia / anomaly-detection.ipynb
Created November 19, 2025 14:50
Anomaly Detection notebook (DS&ML Lab)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fgiobergia
fgiobergia / Ames-Data-exploration.ipynb
Created October 15, 2025 18:14
Data exploration on the Ames housing dataset (Data Science & Machine Learning Lab course @ polito -- 8 & 13/10/2025)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@fgiobergia
fgiobergia / imdb-dsl-nov-18.ipynb
Last active November 24, 2024 20:12
IMDB classification example (DSL Lecture Nov. 18)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""
Code snippet to generate a scatter plot from a given image (mask).
"""
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
im = Image.open("image.png")
mask = (np.array(im) > 0).any(axis=2) # masking condition
"""
GPLv3 yadda yadda
Flavio Giobergia
https://gist.github.com/fgiobergia/395fb9b4727790e0a9a2d24d936526f1
"""
def _merge(a: str, b: str, elisione: bool = True, spacing: bool = False, use_e : bool = False) -> str:
"""Utility function to merge two strings, following a bunch of rules,
as explained in the documentation for int2ita
"""
@fgiobergia
fgiobergia / word_embeddings_demo.ipynb
Last active September 29, 2024 08:04
Demo for "A quick (and practical) introduction to word embeddings" (Research Bites @ Data Science Lab)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from lxml import html
import requests
import numpy
page = requests.get('https://cloud.google.com/compute/pricing')
tree = html.fromstring(page.content)
lowest = tree.xpath('//table/tbody/tr/th[text()="Preemptible price"]/../../tr/td[5]/text()')[:18]
lowest_preempt = tree.xpath('//table/tbody/tr/th[text()="Preemptible price"]/../../tr/td[8]/text()')[:18]
/* https://www.youtube.com/watch?v=7yDmGnA8Hw0 */
#include <stdio.h>
#define LEN 4
int slowest (int *p) {
return (p[0] > p[1]) ? p[0] : p[1];
}
int try (int *side1, int *side2, int index, int time) {
// using current and other for readability purposes
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define f(x,y,z) ((x&y)|(~x&z))
#define g(x,y,z) ((x&z)|(y&~z))
#define h(x,y,z) (x^y^z)
#define i(x,y,z) (y^(x|~z))
#define ror(x,c) ((x<<c)|(x>>(32-c)))
@fgiobergia
fgiobergia / hex.c
Created October 25, 2014 18:18
Hex "editor": display, search and replace patterns in binary files
/*
* Hex "editor": display, search and replace patterns in binary files
* http://fgiobergia.com
* The MIT License (MIT)
* Copyright (c) 2014 Flavio Giobergia
* http://opensource.org/licenses/MIT
*/
#include <unistd.h>
#include <fcntl.h>