Skip to content

Instantly share code, notes, and snippets.

View Kautenja's full-sized avatar
:octocat:
$(git status)

Christian Kauten Kautenja

:octocat:
$(git status)
View GitHub Profile
@Kautenja
Kautenja / realtime_plot.py
Last active June 9, 2018 01:17
A class for plotting a single discrete line in realtime using Matplotlib
"""An object to show a realtime plot of the value of a discrete line."""
from matplotlib import pyplot as plt
from matplotlib.ticker import MaxNLocator
class RealtimePlot(object):
"""A simple realtime plot to show the value of a discrete line."""
def __init__(self, figsize: tuple=(4, 4)) -> None:
"""
@Kautenja
Kautenja / heatmap.py
Last active December 2, 2020 21:55
A quick method to generate a matplotlib heatmap from a pandas.DataFrame
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
def heatmap(data,
size_scale:int = 100,
figsize: tuple = (15, 12),
x_rotation: int = 270,
@Kautenja
Kautenja / confusion_dataframe.py
Created March 9, 2018 02:36
a pandas wrapper for the sklearn confusion_matrix method
"""A simple method wrapping around `confusion_matrix`."""
def confusion_dataframe(*args, **kwargs):
"""
Generate an sklearn confusion matrix as a DataFrame.
Args:
*args: positional args for `confusion_matrix`
**kwargs: keyword args for `confusion_matrix`
@Kautenja
Kautenja / tpfp.py
Last active November 16, 2022 09:23
A Python method for calculating accuracy, true positives/negatives, and false positives/negatives from prediction and ground truth arrays.
"""A method to calculate the number of True/False Positive/Negative guesses."""
import numpy as np
def tpfp(predictions: np.ndarray,
ground_truth: np.ndarray,
negative: int=0.0,
positive: int=1.0,
normalize: bool=True) -> dict:
"""
@Kautenja
Kautenja / array.py
Created February 19, 2018 20:23
A simple conversion of a Python list to an array indexed from 1 for algorithm analysis
class Array(object):
"""A list that indexes like an array [1...n] (for algorithm analysis)."""
def __init__(self, items: list) -> None:
"""Create a new array from a list."""
self.items = items
def __repr__(self) -> str:
"""Return an executable string represention of `self`."""
return '{}({})'.format(self.__class__.__name__, self.items)
@Kautenja
Kautenja / count_words.py
Last active January 5, 2018 19:51
A Python3 script to count the words in a Markdown document with inline LaTeX.
"""This Python script counts words in a Markdown / LaTeX document(s).
Usage:
python3 count_words.py <filename or directory>
It will ignore ATX headers, LaTeX & Markdown comments, and LaTeX markup tags.
TODO: inline HTML, Markdown images & tables
"""
@Kautenja
Kautenja / Distance Functions.ipynb
Created September 25, 2017 23:41
Implementations of different distance functions in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kautenja
Kautenja / Visualizing Spotify Related Artists With Gephi.ipynb
Last active January 2, 2021 06:47
Visualizing Spotify related artist networks using Gephi.
@Kautenja
Kautenja / Dijkstras Algorithm.ipynb
Last active September 11, 2017 02:04
Dijkstra's Algorithm in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Kautenja
Kautenja / LogicalCalculator-DeepNet.ipynb
Last active September 4, 2017 15:38
Solving all binary logic gate functions with one deep net
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.