This file contains 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
def train(df: pd.DataFrame, ycol: str, event_id: str) -> tuple[CatBoostClassifier, TrainTestTargetDistribution]: | |
df = get_quantile_binned_target(df, ycol) | |
# oversample the minority class by simple duplication | |
# we do this for stratified train test split strategy | |
df = df.append(df[df.groupby(ycol)[ycol].transform("count") == 1]) | |
X: pd.DataFrame = df.drop(columns=[ycol]) | |
y: pd.Series = df[ycol] | |
# boosters like catboost and xgboost need categorical variables to be encoded | |
# catboost can do this automatically |
This file contains 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 'dart:typed_data'; | |
import 'package:firebase_core/firebase_core.dart'; | |
import 'package:cloud_firestore/cloud_firestore.dart'; | |
import 'package:flutter/material.dart'; | |
import 'dart:convert'; | |
import 'package:intl/intl.dart'; | |
class ArticleModel { | |
String title; | |
String body; |
This file contains 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
// MIT | |
// Suhas Guruprasad, jargnar@gmail.com | |
const puppeteer = require("puppeteer"); | |
const fetch = require("node-fetch"); | |
const imagemin = require("imagemin"); | |
const imageminMozjpeg = require("imagemin-mozjpeg"); | |
const fs = require("fs").promises; | |
This file contains 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
use std::collections::HashMap; | |
use std::cmp::min; | |
impl Solution { | |
pub fn min_distance(word1: String, word2: String) -> i32 { | |
let mut D: HashMap<(i32, i32), i32> = HashMap::new(); | |
let m = word1.len() as i32; | |
let n = word2.len() as i32; | |
let w1: Vec<char> = word1.chars().collect(); |
This file contains 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
use std::collections::HashMap; | |
impl Solution { | |
pub fn fib(n: i32, cache: &mut HashMap<i32, i32>) -> i32 { | |
if n <= 2 { return n; } | |
else if !cache.contains_key(&(n-1)) && !cache.contains_key(&(n-2)) { | |
let a = Self::fib(n - 1, cache); | |
let b = Self::fib(n - 2, cache); | |
cache.insert(n - 1, a); |
This file contains 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
""" | |
The naive/stupid version where I actually created a tree... for unique paths... | |
<https://leetcode.com/problems/unique-paths> | |
before I realised we could just do simple DP of: #paths(i, j) = #paths(i, j + 1) + #paths(i + 1, j) | |
ouch. | |
""" | |
This file contains 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
s0, r0, g0, p0, n0 = :C3, :D3, :E3, :G3, :B3 | |
s, r, g, p, n = :C4, :D4, :E4, :G4, :B4 | |
s2, r2, g2, p2, n2 = :C5, :D5, :E5, :G5, :B5 | |
define :maya do | |
sleep 3 | |
play_pattern_timed [s, s, r, s, r, s, r, r], 0.75, release: 3 | |
sleep 3 | |
play_pattern_timed [s, r, g, s, r, s, r, r], 0.75, release: 3 |
This file contains 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
package main | |
import ( | |
"bufio" | |
"fmt" | |
"os" | |
"strconv" | |
"github.com/AndreasBriese/bbloom" | |
) |
This file contains 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
#lang racket | |
(define (mysqrt x) | |
;; a procedure to calculate square root of a number | |
;; starts with a guess and improves it until it is good enough | |
;; a guess can be improved by averaging itself with x/guess | |
(define (avg a b) (/ (+ a b) 2.0)) | |
(define (improve-guess guess x) (avg guess (/ x guess))) |
This file contains 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
bucket="SOME_BUCKET_NAME" | |
prefix="SOME_PREFIX" | |
objects="[" | |
printf "\n\n>>> SALVAGING LOST DATA NOW\n\n" | |
while : | |
do | |
count=0 |
NewerOlder