Euclidean-Distance

Fri 14 November 2025

title: "Euclidean Distance" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


def euclidean_distance(p, q):

    #make sure both array are in the same dimension
    assert len(p) == len(q)  

    return max([abs(x-y) for x,y in zip(p,q)])
acb = euclidean_distance([1,2,3],[1 …

Category: basics

Read More

Euclidean-Distance-Vanilla

Fri 14 November 2025

title: "Euclidean Distance Vanilla" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import numpy
def dist(x,y):   
    return numpy.sqrt(numpy.sum((x-y)**2))
a = numpy.array((1,2,3))
b = numpy.array((4,5,6))
dist_a_b = dist(a,b)
print(dist_a_b)
5.196152422706632


Score: 5

Category: basics

Read More

Euclidean-Simple

Fri 14 November 2025

title: "Euclidean Simple" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


import math
import numpy
from random import uniform
def fastest_calc_dist(p1,p2):
    return math.sqrt((p2[0] - p1[0]) ** 2 +
                     (p2[1] - p1[1]) ** 2 +
                     (p2[2] - p1[2]) ** 2)    

def math_calc_dist(p1,p2):
    return math.sqrt(math …

Category: basics

Read More

Even-Rows-And-First-3-Columns

Fri 14 November 2025

title: "Even Rows and 3 Columns" author: "Rj" date: 2019-04-22 description: "-" type: technical_note draft: false


import numpy as np
import pandas as pd
df = pd.read_csv('abc.csv', sep=',', encoding='utf-8')
df

Category: data-wrangling

Read More

Execution-Time-Calculator

Fri 14 November 2025

title: "Execution Time Calculator" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


import random
import time
# PythonDecorators/entry_exit_class.py
class execution_time_calculator(object):

    def __init__(self, f):
        self.f = f

    def __call__(self):
        start = int(round(time.time() * 1000))
        print("Entering", self.f.__name__)
        self.f()
        end = int …

Category: basics

Read More

Extract Names

Fri 14 November 2025
from constants import OPENAI_API_KEY
!pip show langchain-openai | grep "Version:"
Version: 0.2.9
import os
os.environ["OPENAI_API_KEY"] = OPENAI_API_KEY
from langchain_openai import ChatOpenAI

model = ChatOpenAI(model="gpt-4o-mini")
from langchain_core.output_parsers import (
    JsonOutputParser,
)


# A function that operates on finalized inputs
# rather than on an input_stream
def _extract_country_names(inputs):
    """A function …

Category: langchain

Read More

Feed Dictionary

Fri 14 November 2025

title: "Feed Dictionary" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf
import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
c = tf.multiply(a, b)

with tf …

Category: tensorflow-work

Read More

Feeli-Song-Csv

Fri 14 November 2025

title: "Feeli Song Collection" author: "Raja CSP Raman" date: 2019-04-20 description: "-" type: technical_note draft: false


from io import BytesIO
import requests
import pandas as pd
filename = 'https://docs.google.com/spreadsheet/ccc?key=1EfyD7A4YcdAzTfUO0t3yQ0HawetVF5pefS5pPyGVX4g&output=csv'

r = requests.get(filename)
data = r.content
df = pd.read_csv(BytesIO(data), index_col=0 …

Category: basics

Read More

Fetch-Titanic-Dataset

Fri 14 November 2025

import pyutil as pyu
pyu.get_local_pyinfo()
'conda env: ml312-2024; pyv: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:27:36) [GCC 11.2.0]'

import pandas as pd
# Load the Titanic dataset
url = 'https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv'
data = pd.read_csv …

Category: mlbasics

Read More

Fetching-Variable-State

Fri 14 November 2025

title: "Template" author: "Raja CSP Raman" date: 2019-05-07 description: "-" type: technical_note draft: false


import tensorflow as tf

import os

# Just disables the warning, doesn't enable AVX/FMA
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
a = tf.constant(2)
b = tf.constant(3)

c = tf.add(a, b)
d = tf.multiply(a, b …

Category: tensorflow-work

Read More
Page 100 of 146

« Prev Next »