This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import statistics | |
| import timeit | |
| import csv | |
| import pandas as pd | |
| import numpy as np | |
| import polars as pl | |
| def measure_performance(func, n_runs=50): | |
| times = timeit.repeat(func, repeat=n_runs, number=1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import asyncio | |
| import json | |
| import time | |
| from typing import Optional, List | |
| from pydantic import BaseModel, Field | |
| from starlette.responses import StreamingResponse | |
| from fastapi import FastAPI, HTTPException, Request |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from numpy import genfromtxt | |
| from sklearn.preprocessing import MinMaxScaler | |
| from sklearn.cluster import KMeans | |
| import matplotlib.pyplot as plt | |
| ## Data preprocessing | |
| # Load csv dataset into a numpy array | |
| X = genfromtxt('/path/to/dataset', delimiter=',') | |
| # Use MinMaxScaler to scale the data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| local cnt = redis.call('INCR', KEYS[1]) | |
| if cnt > tonumber(ARGV[1]) | |
| then | |
| return redis.call('PTTL', KEYS[1]) | |
| end | |
| if cnt == 1 | |
| then | |
| redis.call('PEXPIRE', KEYS[1], ARGV[2]) | |
| end | |
| return 0 |