Skip to content

Instantly share code, notes, and snippets.

View thuwarakeshm's full-sized avatar

Thuwarakesh Murallie thuwarakeshm

View GitHub Profile
@thuwarakeshm
thuwarakeshm / k-means-3-var-3-cluster.py
Last active July 3, 2021 06:33
K means clustering for election campaigns
# Performing K-Means to find 3 clusters using the three variables
kmeans = KMeans(n_clusters=3, random_state=0).fit(df[["Age", "Income", "Debt"]])
# FastETL configuration file
# created 2019-02-17 16:45:09.940033 UTC
tuplex:
- allowUndefinedBehavior: false
- autoUpcast: false
- csv:
- comments: ["#", "~"]
- generateParser: true
- maxDetectionMemory: 256KB
- maxDetectionRows: 100
import cProfile
...
def fib(n):
return n if n < 2 else fib(n - 1) + fib(n - 2)
cProfile.run("fib(20)")
@thuwarakeshm
thuwarakeshm / typer-doc.py
Last active July 27, 2021 13:23
Introduction to Typer
@app.command()
def elbow(file_path: str, max_clusters: int = 10):
"""
This command will run K-Means algorithm many times and print the inertia values to the console.
"""
...
@thuwarakeshm
thuwarakeshm / app.js
Last active July 30, 2021 16:21
PyJS Comparison
const express = require("express");
const app = express();
const port = 5000;
const fib = (n) => {
if (n < 2) return n;
return fib(n - 1) + fib(n - 2);
};
app.get("/", (req, res) => {
@thuwarakeshm
thuwarakeshm / crun.py
Last active July 2, 2023 03:57
CPython Challenge
import cProfile
from fib import fib as fibc
cProfile.run("fibc(35)")
@thuwarakeshm
thuwarakeshm / ccounter.py
Last active May 27, 2022 01:11
Challanging Cython
def count_primes(n: int) -> int:
"""Returns how many prime numbers are there less than n"""
count = 0
primes = [False for i in range(n + 1)]
for i in range(2, n):
if primes[i] == False:
count += 1
j = 2
while j * i < n:
@thuwarakeshm
thuwarakeshm / app.py
Last active August 7, 2021 18:30
Massive Computation
from celery import Celery
from flask import Flask
import time
# 1. A function to create Celery object.
def make_celery(app):
celery = Celery(
app.import_name,
backend=app.config["CELERY_RESULT_BACKEND"],
broker=app.config["CELERY_BROKER_URL"],
@thuwarakeshm
thuwarakeshm / compare_with_target.py
Last active August 14, 2021 10:26
Analysis in a blink
@app.command()
def compare_with_target(input1: str, input2: str, target: str):
# Read CSVs from arguments
df1, df2 = pd.read_csv(input1), pd.read_csv(input2)
# Generate a comparison report against the target variable
report = sv.compare(df1, df2, target)
# Render HTML report in your default browser
@thuwarakeshm
thuwarakeshm / config.toml
Last active August 15, 2021 14:11
ETL with Prefect
[context.secrets]
EMAIL_USERNAME = "<Your email id>"
EMAIL_PASSWORD = "<your email password>"