Popular posts from this blog
python(BI)
PRACTICAL NO.1 AIM: Perform the data classification using classification algorithm. 1A. Perform the data classification using Naïve Baye’s Algorithm. from sklearn.datasets import load_iris iris = load_iris() X = iris.data y = iris.target from sklearn.model_selection import train_test_split X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.4,random_state=1) from sklearn.naive_bayes import GaussianNB gnb=GaussianNB() gnb.fit(X_train,y_train) y_pred=gnb.predict(X_test) from sklearn import metrics print("Gaussian Naive Bayes model accuracy(in%):",metrics.accuracy_score(y_test,y_pred)*100) EXAMPLE-span.csv import numpy as np import pandas as pd from sklearn.feature_extraction.text import CountVectorizer from sklearn.naive_bayes import MultinomialNB df=pd.read_csv('/content/spam1.csv',encoding='latin-1') df=df[['Message','Category']] df.columns=['SMS','Type'] countvec=CountVectorizer(ngram_range=(1,4),stop_words='eng...
(PP-7)Create a class called Numbers, which has a single class attribute called MULTIPLIER, and a constructor which takes the parameters x and y (these should all be numbers). i. Write a method called add which returns the sum of the attributes x and y. ii. Write a class method called multiply, which takes a single number parameter a and returns the product of a and MULTIPLIER. iii. Write a static method called subtract, which takes two number parameters, b and c, and returns b - c. iv. Write a method called value which returns a tuple containing the values of x and y. Make this method into a property, and write a setter and a deleter for manipulating the values of x and y.
7A . #calculator.py class number: multiplier=3 def __init__(self,x,y): self.x=x self.y=y def add(self): return self.x+self.y def multiply(self,a): return self.multiplier*a def subtract(b,c): return b-c T=number(2,4) print(T.add()) print(T.multiply(2)) print(number.subtract(4,2)) 7B.design the class that stores the info of students and display the same class student: def __init__(self,name,roll_no,address): self.name=name self.roll_no=roll_no self.address=address s=student("Bhavesh",406,"malad") print(s.name) print(s.roll_no) print(s.address) 7C.create a module student_details with functions display_name, marks_total & create new file that imports the module and display the functions. #student_details.py def display_name(Name): print("student Name:",Name) return def marks_total(p,c,m): print("Total marks obtained by student:",p+c+m) ret...
Comments
Post a Comment