Function-Caching

Fri 14 November 2025

title: "Function Caching" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from functools import lru_cache
@lru_cache(maxsize=10)
def add(a, b):
    print('add method called')
    return a+b
print(add(7, 4))
add method called
11
print(add(7, 4))
11
print(add(5, 2))
add method called …

Category: basics

Read More

Function With Return Type

Fri 14 November 2025

title: "Function With Return Type" author: "Rj" date: 2019-04-20 description: "List Test" type: technical_note draft: false


def square(a):
    return a * a
print(square(5))
25
def square(a:int) -> int:
    return a * a
print(square(4))
16
def square_1(a:int) -> str:
    return a * a
print(square_1(15))
225 …

Category: basics

Read More

Fuzzy-String-Ratio

Fri 14 November 2025

title: "Fuzzy String Ratio" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from fuzzywuzzy import fuzz
print(fuzz.ratio("this is a test", "this is a test!"))
97
print(fuzz.ratio("this is a cup", "this is a world cup"))
81

Score: 0

Category: basics

Read More

Gaussian 1

Fri 14 November 2025

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


from sklearn.naive_bayes import GaussianNB
import numpy as np
#assigning predictor and target variables
x= np.array([[-3,7],[1,5], [1,2], [-2,0], [2,3], [-4,0], [-1,1], [1,1], [-2,2], [2,7], [-4,1 …

Category: sklearn

Read More

Gaussian-Analysis

Fri 14 November 2025

from sklearn.naive_bayes import GaussianNB
import numpy as np
#assigning predictor and target variables
x= np.array([[-3,7],[1,5], [1,2], [-2,0], [2,3], [-4,0], [-1,1], [1,1], [-2,2], [2,7], [-4,1], [-2,7]])
y = np.array([3, 3, 3, 3, 4, 3 …

Category: sklearn

Read More

Gaussian-Breast-Cancer

Fri 14 November 2025
!python --version
Python 3.12.4
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score
# Load dataset
data = load_breast_cancer()
type(data)
sklearn.utils._bunch.Bunch
# Organize our data
label_names = data['target_names']
labels = data['target']
feature_names = data['feature_names']
features = data …

Category: sklearn

Read More

Gaussian-Breast-Cancer-Prediction

Fri 14 November 2025

title: "Gaussian Breast Cancer Prediction" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import accuracy_score
# Load dataset
data = load_breast_cancer()
type(data)
sklearn.utils.Bunch
# Organize our data
label_names = data['target_names']
labels …

Category: sklearn

Read More

Gaussian-Nb-Simple

Fri 14 November 2025

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


from sklearn import datasets
from sklearn.naive_bayes import GaussianNB
iris = datasets.load_iris()
gnb = GaussianNB()
y_pred = gnb.fit(iris.data, iris.target).predict(iris.data)
print("Number of mislabeled points out of a total %d points : %d" % (iris …

Category: sklearn

Read More

Generate-News

Fri 14 November 2025

title: "generate news" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


import nltk
tokenizer = nltk.tokenize.RegexpTokenizer(r'\w+|[^\w\s]+')

content_text = """They’re interested in local government, free TV licences, pension credits and child 
trust fund, Carrousel Capital, run by local Liberal Democrats. TV Exclusive Trouser 
Clegg Nick …

Category: textprocessing

Read More

Generator-Expressions

Fri 14 November 2025

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


abc = [6, 8, 23, 2, 19]
abc
[6, 8, 23, 2, 19]
result = [x for x in abc if(x > 6)]
result
[8, 23, 19]
square = [x*x for x in result]
square
[64, 529, 361]
# More …

Category: basics

Read More
Page 104 of 146

« Prev Next »