Euclidean-Distance
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 …
Read More
Euclidean-Distance-Vanilla
title: "Euclidean Distance Vanilla"
author: "Rj"
date: 2019-04-20
description: "-"
type: technical_note
draft: false
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)
Score: 5
Read More
Euclidean-Simple
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 …
Read More
Even-Rows-And-First-3-Columns
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')
Read More
Execution-Time-Calculator
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 …
Read More
Extract Names
from constants import OPENAI_API_KEY
!pip show langchain-openai | grep "Version:"
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 …
Read More
Feed Dictionary
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 …
Read More
Feeli-Song-Csv
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 …
Read More
Fetch-Titanic-Dataset
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]'
# Load the Titanic dataset
url = 'https://raw.githubusercontent.com/datasciencedojo/datasets/master/titanic.csv'
data = pd.read_csv …
Read More
Fetching-Variable-State
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 …
Read More