python

python
from sklearn.decomposition import PCA
from sklearn.manifold import TSNE
from sklearn.preprocessing import StandardScaler

X_scaled = StandardScaler().fit_transform(X)

PCA and t-SNE for dimensionality reduction and inspection

pca tsne dimensionality-reduction
by Dr. Elena Vasquez 1 tab
python
import great_expectations as gx

context = gx.get_context()
data_source = context.data_sources.add_pandas(name='training_data')
asset = data_source.add_dataframe_asset(name='churn_asset')
batch_definition = asset.add_batch_definition_whole_dataframe('full_dataframe')

Great Expectations checks for dataset health before retraining

great-expectations data-quality mlops
by Dr. Elena Vasquez 1 tab
python
import time
import requests
from bs4 import BeautifulSoup

session = requests.Session()
session.headers.update({'User-Agent': 'research-bot/1.0'})

Web scraping pipelines with requests and BeautifulSoup

web-scraping beautifulsoup requests
by Dr. Elena Vasquez 1 tab
python
import enum
import datetime as dt

from sqlalchemy import Column, Integer, String, BigInteger, Enum, DateTime
from sqlalchemy.orm import declarative_base

Streaming FastAPI File Uploads with a Background Validation Task

fastapi uploads background-tasks
by codesnips 3 tabs
python
from sklearn.ensemble import RandomForestClassifier, HistGradientBoostingClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
from sklearn.pipeline import Pipeline
from sklearn.impute import SimpleImputer

Baseline classifiers in scikit-learn for fast benchmark setting

scikit-learn classification baselines
by Dr. Elena Vasquez 1 tab
sql
CREATE TABLE events (
    id          bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    source      text        NOT NULL,
    external_id text        NOT NULL,
    payload     jsonb       NOT NULL,
    occurred_at timestamptz NOT NULL,

Batched writes with COPY (conceptual)

postgres performance sql
by codesnips 3 tabs
python
import factory
from factory.django import DjangoModelFactory
from factory import Faker, SubFactory, post_generation
from blog.models import Post, Comment, Tag
from django.contrib.auth import get_user_model

Django test fixtures with factory_boy

django python testing
by Priya Sharma 1 tab
python
import torch

device = 'cuda' if torch.cuda.is_available() else 'cpu'
features = torch.tensor([[1.0, 2.0], [3.0, 4.0]], requires_grad=True, device=device)
weights = torch.tensor([[0.2], [0.8]], requires_grad=True, device=device)

PyTorch tensor basics and automatic differentiation

pytorch tensors autograd
by Dr. Elena Vasquez 1 tab
python
from django.contrib.auth import views as auth_views
from django.urls import path

app_name = 'accounts'

urlpatterns = [

Django password reset flow with email

django python authentication
by Priya Sharma 2 tabs
python
import hmac
import hashlib
import time
from fastapi import Request, HTTPException, status

Verifying Stripe Webhook Signatures With a Reusable FastAPI Dependency

fastapi webhooks security
by codesnips 3 tabs
python
from celery import shared_task
from django.core.mail import send_mail
from django.contrib.auth import get_user_model

User = get_user_model()

Django celery task for async email sending

django python celery
by Priya Sharma 2 tabs
python
from django.conf import settings
from datetime import datetime


def site_settings(request):
    """Add site-wide settings to template context."""

Django context processors for global template variables

django python templates
by Priya Sharma 2 tabs