Skip to content

Instantly share code, notes, and snippets.

@hadifar
hadifar / dataviz.md
Created July 31, 2026 08:15
official claude dataviz.md file

Data Visualization

A chart is read by people and executed by you. This skill turns "make it look good" into a procedure with checks, so the result is right by construction rather than by taste.

The method here is design-system-agnostic. Nothing in the procedure, the form heuristic, the six checks, or the mark specs is specific to one product. A design system supplies a small set of parameters (its ramps, a categorical order, a diverging pair, a status palette, a texture, its surfaces, its filter components);

@hadifar
hadifar / settings.json
Created July 1, 2026 12:28
VS code settings for AI ML Engineers
{
// ════════════════════════════════════════════════════════════
// EDITOR — applies everywhere, then refined in the [python] scope
// ════════════════════════════════════════════════════════════
"editor.formatOnSave": true,
"editor.formatOnPaste": false, // paste-format is noisy; save-format is enough
"editor.rulers": [
88
], // visual guide at Ruff/Black default line length
"editor.tabSize": 4,
from transformers import pipeline
classifier = pipeline("text-classification", model="hadifar/xxx")
try:
while True:
user_input = input("Enter a string (Press Ctrl+C to stop): ")
if user_input:
res = classifier([user_input])
model_name = 'model/classifier'
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
tokenizer = AutoTokenizer.from_pretrained(model_name)
model.push_to_hub('hadifar/xxx')
tokenizer.push_to_hub('hadifar/xxx')
@hadifar
hadifar / classifier_1.py
Created August 19, 2023 11:26
simple classifier code
import evaluate
import numpy as np
import random
import torch
from datasets import load_dataset
from transformers import AutoTokenizer
from transformers import DataCollatorWithPadding
from transformers import AutoModelForSequenceClassification, TrainingArguments, Trainer
@hadifar
hadifar / classical_baseline.py
Created April 25, 2022 15:01
A simple example for SVM
import argparse
import os
import numpy as np
from joblib import dump, load
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics import accuracy_score
from sklearn.pipeline import Pipeline
from sklearn.svm import SVC
@hadifar
hadifar / parse.py
Last active November 20, 2021 11:49
I copy the code from this repo: https://github.com/iamrkg31/sentence-to-clauses
import re
import nltk
def get_verb_phrases(t):
verb_phrases = []
num_children = len(t)
num_VP = sum(1 if t[i].label() == "VP" else 0 for i in range(0, num_children))
import torch
from transformers import *
import sys, logging
print('cuda available? ', torch.cuda.is_available())
print('how many gpus?', torch.cuda.device_count())
logging.root.handlers = []
logging.basicConfig(level="INFO", format='%(asctime)s:%(levelname)s: %(message)s', stream=sys.stdout)
import tensorflow as tf
vocabulary_size = 10000
embedding_size = 64
rnn_size = 64
batch_size = 512
# download dataset
(train_data, train_labels), (test_data, test_labels) = tf.keras.datasets.imdb.load_data(num_words=vocabulary_size)
NUM_GPUS = 4
strategy = tf.contrib.distribute.MirroredStrategy(num_gpus=NUM_GPUS)
config = tf.estimator.RunConfig(train_distribute=strategy)
estimator = tf.estimator.Estimator(model, config=config)