Skip to main content

Exp 11

11. Write a program for Naive Bayesian Classification in Python import pandas as pd import numpy as np from sklearn import datasets iris = datasets.load_iris() # importing the dataset iris.data # showing the iris data X=iris.data #assign the data to the X y=iris.target #assign the target/flower type to the y print (X.shape) print (y.shape) fromsklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2,random_state=9) fromsklearn.naive_bayes import GaussianNB nv = GaussianNB() # create a classifier nv.fit(X_train,y_train) # fitting the data fromsklearn.metrics import accuracy_score y_pred = nv.predict(X_test) # store the prediction data accuracy_score(y_test,y_pred) # calculate the accuracy

Comments

Popular posts from this blog

DWDM (Basic statistical description of data)

Data structures: Introduction to Trees

Tree: The data in a tree are not stored in a sequential manner i.e., they are not stored linearly. Instead, they are arranged on multiple levels or we can say it is a hierarchical structure. For this reason, the tree is considered to be a non-linear data structure. KeyConcepts : Nodes : Individual units within the tree, each storing data and potentially linking to other nodes. Edges : Connections between nodes, representing relationships (parent-child, sibling, etc.). Root : The topmost node in the tree, from which all other nodes originate. Parent : A node that has one or more child nodes. Child : A node connected to a parent node. Leaf : A node with no children. Subtree : A portion of a tree that is itself a tree. Representation of tree: Binary search tree :

Hashing and hash functions

Types of hash functions