Accuracy-Score

Sat 17 May 2025

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


import numpy as np
from sklearn.metrics import accuracy_score
y_pred = [0, 2, 1, 3]
y_true = [0, 1, 2, 3]
score1 = accuracy_score(y_true, y_pred)    
print(score1)
0.5
score2 = accuracy_score(y_true, y_pred, normalize=False)
print(score2)
2


Score: 5

Category: sklearn


Decision-Tree-Graph

Sat 17 May 2025

title: "Decision Tree Graph" author: "Rj" date: 2019-04-21 description: "-" type: technical_note draft: false


import pydotplus
from sklearn.datasets import load_iris
from sklearn import tree
import collections
# Data Collection
#heigh, length of hair, voice pitch
X = [ [180, 15,0],     
      [177, 42,0],
      [136, 35,1],
      [174, 65,0],
      [141, 28,1 …

Category: sklearn

Read More

Gaussian 1

Sat 17 May 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

Sat 17 May 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

Sat 17 May 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

Sat 17 May 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

Sat 17 May 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

Grid-Search-Sample

Sat 17 May 2025

title: "Grid Search Sample" author: "Rj" date: 2019-04-20 description: "-" type: technical_note draft: false


from __future__ import print_function

from sklearn import datasets
from sklearn.model_selection import train_test_split
from sklearn.model_selection import GridSearchCV
from sklearn.metrics import classification_report
from sklearn.svm import SVC
# print(__doc__)

# Loading the Digits dataset
digits = datasets.load_digits …

Category: sklearn

Read More

Isotonic

Sat 17 May 2025

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


import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection

from sklearn.linear_model import LinearRegression
from sklearn.isotonic import IsotonicRegression
from sklearn.utils import check_random_state
n = 100
x = np.arange(n)
rs = check_random_state(0)
y …

Category: sklearn

Read More

Isotonic-1

Sat 17 May 2025

import numpy as np
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection

from sklearn.linear_model import LinearRegression
from sklearn.isotonic import IsotonicRegression
from sklearn.utils import check_random_state
n = 100
x = np.arange(n)
rs = check_random_state(0)
y = rs.randint(-50, 50, size=(n,)) + 50. * np.log(1 + np …

Category: sklearn

Read More
Page 1 of 2

Next »