python
17 lines · 1 tab
Dr. Elena Vasquez
Apr 2026
1 tab
import numpy as np
features = np.array([
[120.0, 3.0, 10.0],
[90.0, 5.0, 7.0],
[150.0, 2.0, 14.0],
])
mean = features.mean(axis=0)
std = features.std(axis=0)
standardized = (features - mean) / std
weights = np.array([0.5, 1.5, 2.0])
weighted_score = standardized * weights
final_score = weighted_score.sum(axis=1)
print(final_score)
1 file · python
Explain with highlit
Good NumPy code replaces Python loops with array semantics that are easier to optimize and easier to benchmark. Broadcasting is the feature that makes those transformations elegant. I rely on it for normalization, distance calculations, and matrix-friendly preprocessing when raw speed matters.
Related snips
ruby
class Comment < ApplicationRecord
belongs_to :article
belongs_to :author, class_name: "User"
validates :body, presence: true, length: { maximum: 2_000 }
Live comments with model broadcasts + turbo_stream_from
rails
hotwire
turbo
by codesnips
4 tabs
erb
<%# private stream: turbo signs the serialized record name %>
<%= turbo_stream_from current_user %>
<section class="notifications">
<h1>Notifications</h1>
Turbo Streams + authorization: signed per-user stream name
rails
turbo
hotwire
by codesnips
3 tabs
python
import pandas as pd
from sklearn.compose import ColumnTransformer
from sklearn.impute import SimpleImputer
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import OneHotEncoder, StandardScaler
Encoding categorical variables without creating leakage
categorical-encoding
preprocessing
scikit-learn
by Dr. Elena Vasquez
1 tab
php
<?php
namespace App\Events;
use App\Models\Message;
use App\Models\User;
Laravel broadcasting with Pusher for real-time events
laravel
broadcasting
websockets
by Carlos Mendez
3 tabs
sql
WITH ordered_events AS (
SELECT
customer_id,
event_time,
revenue,
ROW_NUMBER() OVER (PARTITION BY customer_id ORDER BY event_time DESC) AS event_rank,
SQL window functions for feature extraction and behavioral ranking
sql
window-functions
feature-engineering
by Dr. Elena Vasquez
1 tab
ruby
class Document < ApplicationRecord
belongs_to :account
enum status: { pending: 0, processing: 1, ready: 2, failed: 3 }
after_create_commit :broadcast_badge
Broadcast a status badge update on background processing
rails
hotwire
turbo
by codesnips
4 tabs
Share this code
Here's the card — post it anywhere.