DLWP Assignment 1
DLWP Assignment 1
1. Write a Python code to find the integer encoding for the given list.
fruits=[’apple’,’banana’,’orange’,’banana’,’apple’,’cherry’]
2. Write a Python code to find the one-hot encoding for the given string with and without using the
sklearn function.:
String1=’hello python’
3. Write a Python code to generate 100 data points between -20 to 20 and plot them using the sigmoid
function. Define the sigmoid function.
4. Write a Python code to find the slope and intercept for the given data points without using a built-in
function.
X=[2,4,6,8,10]
Y=[ [3,7,5,10,12]
5. Write a Python code to predict the house prices using linear regression with feature square feet. The
target value is the price and is also represented in the graph.
X=[2,4,6,8,10]
Y= [3,7,5,10,12]
6. Write a Python code to classify a house’s purchase decision based on an entity’s income using logistic
regression. Provide a graphical representation.
X(income in Rs)= [20000, 30000, 50000, 70000, 80000,100000]
Y(purchase Decision)= [0, 0, 1, 1, 1, 1]
7. The given data set predicts whether a student passes an exam based on the hours studied using logistic
regression. Find the cost for the above dataset using Python.
X=[2,4,6,8,10] Y=[0,0,1,1,1]
8. Write a Python code to find entropy and information gain for market competition and year for the
given dataset.
Year= [2018, 2019, 2020, 2021, 2022, 2023,2024]
Market Competition= [’Medium’,’High’, ’Low’, ’Medium’, ’High’, ’Low’,’High’]
Type= [’A’, ’B’, ’A’, ’B’, ’A’]
Profit Loss = [’Profit’,’Profit’, ’Loss’, ’Profit’, ’Profit’, ’Loss’]
Dataset=2, 19, 22, 27, 29, 30, 32, 35, 52, 59.
9. Write a Python code to visualize the decision tree model with criterion as Entropy with max depth 3
for the given dataset.
10. Write Python code to find the cluster allocation for the given dataset using the K means clustering
algorithm.
Student= [”A”, ”B”, ”C”, ”D”, ”E”, ”F”, ”G”, ”H”, ”I”, ”J”]
Math Marks = [85, 70, 60, 95, 55, 80, 45, 90, 78, 65]
Science Marks=[90, 75, 65, 92, 50, 85, 40, 88, 82, 60]
English =[80, 85, 70, 96, 60, 88, 50, 86, 80, 72]
1
Centre for Artificial Intelligence Machine Learning
Institute of Technical Education & Research, SOA, Deemed to be University
11. Write Python code to find the cluster allocation for the given dataset using an agglomerative clustering
algorithm.
Student= [”A”, ”B”, ”C”, ”D”, ”E”, ”F”, ”G”, ”H”, ”I”, ”J”]
Math Marks = [85, 78, 90, 65, 55, 89, 76, 92, 60, 58]
Science Marks=[80, 75, 85, 60, 50, 87, 74, 95, 55, 52]