Professional Documents
Culture Documents
Experiment 1.1:
Student Name: ROSHAN M ROY
UID:22BCS10095
Branch: Computer Science & Engineering Section/Group: 203(A)
Semester:1 Date of Performance:10/10/22
Subject Name: Disruptive technologies
Subject Code: 22ECH-102
4. Code:
1. WAP to print your name two times:
#Assignment 2: WAP to add three numbers, inputs from user and print result
print("Enter the first
number:") a = int(input())
print("Enter the second number:")
b = int(input())
print("Enter the Third number:")
c = int(input())
print("Sum of the numbers is "+str(a+b+c))
#Assignment 3: WAP to concatenate three strings, inputs from user and print
University Institute of Engineering
a = input()
print("Enter the second string:") b = input()
print("Enter the Third string:") c = input()
print(a+" "+b+" "+c)
4. WAP to find max among three numbers and input from user.
#Assignment 4: WAP to find max among three numbers and input from
user print("Enter the first number:") a = int(input())
print("Enter the second number:")
b = int(input())
print("Enter the Third
number:") c = int(input())
if(a>=b):
if(a>=c):
max = a
else: max
= c
else:
if(b>=c):
max = b
else:
max = c
print("Max of the numbers is "+ str(max))
#Assignment 7: WAP to add all the numbers from 1 to n and n is given by user.
print("Enter the number :") n
University Institute of Engineering
= int(input())
sum = 0 for i in
range(n+1):
sum = sum + i
print("sum of the numbers is "
+ str(sum))
8. WAP using function that add all odd numbers from 1 to n; n given by user.
#Assignment 8: WAP using function that add all odd numbers from 1 to n; n given by user.
9. WAP using function that add all even numbers from 1 to n; n given by user.
#Assignment 9: WAP using function that add all even numbers from 1 to n; n given by
user.
print("Enter the
number :") n =
int(input()) #Defining a
function def evenSum():
sum = 0 for i in range(1
, n+1):
if(i%2==0):
sum = sum + i
return sum
print("sum of all the Even numbers are :")
print(evenSum())
10.WAP using function that adds all prime numbers from 1 to n; n given by user.
if (count == 0 and Num > 1):
sum = sum + i
return sum
print("Sum of all prime numbers are:") print(primeSum()) #Assignment 10: WAP using function that add all prime numbers from 1
to n; n given by user.
print("Enter the
University Institute of Engineering
number :")
Num = int(input())
#Declaring a function
def primeSum():
sum = 0
for i in range(2,Num+1):
(i//2 + 1)):
if(i % j == 0):
count = count + 1
break
11.WAP to create 500 txt files in a directory. Every file contains 20,000 lines and every line contains random
string of length 20 characters.
#Assignment 11: WAP to create 500 txt files in a directory. Every file contains 20,000 lines and
e very line contains random string of length 20 characters.
import
string import
random
for i in range(1 , 500): with
open("random"+str(i)+".txt", 'a') as file1:
for j in range(20000):
# initializing size of string
N = 20
# using random.choices() #
generating random strings
res = ''.join(random.choices(string.ascii_uppercase +string.digits, k=N))
file1.write(res+"\n")
print("All the files are created !")
University Institute of Engineering
5. Output:
1:
2:
3.
5:
6
University Institute of Engineering
9.
10.
University Institute of Engineering
11.
University Institute of Engineering
Experiment: 1.2
Student Name:ROSHAN M ROY UID:22BCS10095
1. Aim of the practical: To explore, visualize, transform and summarize input datasets for
building classification/regression/prediction models.
4. Code:
To install the pycaret
installed successfully")
University Institute of Engineering
version()
diabetesdataset = get_data("diabetes")
diabetesdataset.columns
diabetesdataset.describe()
diabetesdataset.head()
diabetesdataset.tail()
University Institute of of
Computer
University Institute of Engineering
Science &
Engineering
Department Science & Engineering
Experiment: 1.3
1. Aim of the practical:- Train and develop classifier models using diabetes dataset
from pycaret.
Input 1:-
Science &
Input 2:-
Output 2 :
University Institute of Engineering
Input 3 :-
Output 3:-
Input 4:-
Output 4 :-
of Engineering Science &
University Institute Department of Computer
Engineering
University Institute of Engineering
Input 5:
Output 5:
University Institute of Engineering
Written the code of python program to build a classifier model of blood dataset using
pycaret library and got the output. 6. Learning outcomes (What I have learnt):
Experiment: 1.4
1. Aim of the practical: To Build a classification model by using different machine learning algorithms.
3. Basic Concept/ Command Description: : In this program we have to install pycaret and from that
we have to import datasets on which we have to perform various operations.
4. Code:
installed successfully")
University Institute of Engineering
version()
diabetesdataset = get_data("diabetes")
cm = compare_models()
# Explore more parameters
Three line of code for model comparison for "Heart Disease" dataset
from pycaret.datasets import get_data from
pycaret.classification import *
cm = compare_models()
# No output
diabetesDataSet = get_data("diabetes") # SN is 7
# This is binary classification dataset. The values in "Class variable" have two (binary) values.
# import pandas as pd
# diabetesDataSet = pd.read_csv("myFile.csv")
cm = compare_models() #
Explore more parameters
heartDiseaseDataSet = get_data("heart_disease")
s = setup(data = heartDiseaseDataSet, target='Disease', silent=True)
cm = compare_models()
University Institute of Engineering
## Commonly used techniques: clipping, log scaling, z-score, minmax, maxabs, robust
s = setup(data=diabetesDataSet, target='Class variable', normalize = True, normalize_method = 'zscore', silent=True)
cm = compare_models()
University Institute of Engineering
6. Result and Summary: In this experiment we have Built a classification model by using different
machine learning algorithms.
Experiment: 2.1
1. Aim of the practical: Develop a prediction model based on linear / logistic Regression.
3. Basic Concept/ Command Description: In this program we have to install pycaret and from
that we have to import datasets on which we have to perform various operations.
4. Code:
installed successfully")
University Institute of Engineering
version()
bostonDataSet = get_data("boston")
cm = compare_models()
University Institute of Engineering
pycaret.regression import *
insuranceDataSet = get_data("insurance")
= compare_models()
pycaret.regression import *
houseDataSet = get_data("house")
= compare_models()
= compare_models()
cm = compare_models()
= compare_models()
cm = compare_models()
= compare_models()
s = setup(data = bostonDataSet, target = 'medv', remove_outliers = True, outliers_threshold = 0.05, normalize = True,
normalize_method = 'zscore', silent=True)
cm = compare_models()
University Institute of Engineering
s = setup(data = bostonDataSet, target = 'medv', remove_outliers = True, outliers_threshold = 0.05, normalize = True,
normalize_method = 'zscore', transformation = True, transformation_method = 'yeo-johnson', silent=True)
cm = compare_models()
bostonDataSet = get_data("boston") # SN is 46
rfModel = create_model('rf')
newDataSet = get_data("boston").iloc[:10]
plt.savefig("result-scatter-plot.jpg", dpi=300)
plt.show()
# No output
University Institute of Engineering
rf = create_model('rf')
plot_model(rf, plot='error')
plot_model(rf, plot='learning')
plot_model(rf, plot='vc')
plot_model(rfModel, plot='feature')
plot_model(etModel, plot='feature')
University Institute of Engineering
plot_model(dtModel, plot='feature')
# No output
bostonDataSet = get_data("boston") # SN is 46
# This is regression dataset. The values in medv are continuous values
University Institute of Engineering
# import pandas as pd
# bostonDataSet = pd.read_csv("myFile.csv")
cm = compare_models() #
Explore more parameters
University Institute of Engineering
sm = save_model(rfModel, 'rfModelFile')
Transformation Pipeline and Model Successfully Saved
rfModel = load_model('rfModelFile')
Transformation Pipeline and Model Successfully
Loaded
ataset
# Select top 10 rows from boston d
newDataSet = get_data("boston").iloc[:10]
University Institute of Engineering
plt.scatter(actual, predicted)
plt.xlabel('Predicted') plt.ylabel('Actual')
plt.title('Actul Vs Predicted')
plt.savefig("result-scatter-plot.jpg",
dpi=300) plt.show()
University Institute of Engineering
newPredictions.to_csv("NewPredictions.csv") #
No output
University Institute of Engineering
Department of Computer Science & Engineering
University Institute of Engineering
Department of Computer Science & Engineering
University Institute of Engineering
Department of Computer Science & Engineering
University Institute of Engineering
Department of Computer Science & Engineering
6. Result and Summary: In this experiment, we have developed a prediction model based on
linear / logistic Regression.