B-56 Sanket Jambhulkar MLA-1
B-56 Sanket Jambhulkar MLA-1
B-56 Sanket Jambhulkar MLA-1
ipynb - Colaboratory
Date:19/01/2024
Practical Details: Practical No. 1
Student Details:
Roll Number 56
Name sanket jambhulkar
Semester 6th
Section B
Branch CSE
Subject Machine learning and algorithm
● if True:
● print("Hello, World!")
2. Data Types:
● Common data types include integers, floats, strings, lists, tuples, and dictionaries.
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 1/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
● num = 10
● pi = 3.14
● name = "John"
● my_list = [1, 2, 3]
3. Control Flow:
● Python supports conditional statements (if, else, elif) and loops (for, while)
● for i in range(5):
● print(i)
● if x > 0:
● print("Positive")
● elif x < 0:
● print("Negative")
● else:
● print("Zero")
4. Functions:
● Functions are defined using the def keyword.
● # Example of a function
● def greet(name):
● print(greet("Alice"))
● import numpy as np
2. Pandas:
● Pandas is used for data manipulation and analysis. It provides data structures like DataFrames, which are
especially useful for handling structured data.
● import pandas as pd
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 2/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
4. Scikit-Learn:
● Scikit-Learn is a machine learning library that provides simple and efficient tools for data mining and data
analysis. It includes various algorithms for classification, regression, clustering, and more.
● import tensorflow as tf
● import torch
6. Keras:
● Keras is a high-level neural networks API, often used in conjunction with
TensorFlow. It simplifies the process of building and training neural
networks.
python
data = {
'Roll No': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, None],
'NAME': ['Deep', 'Jayesh', 'Yash', 'Sara', 'Gita', 'Jinal', 'Kavita', 'Minal', 'Naresh', 'Rima', None],
'SUB 1': [30, 40, 45, 48, 35, 32, 36, 23, 43, 37, 369],
'SUB 2': [30, 40, 36, 32, 32, 31, 28, 25, 27, 44, 325],
'SUB 3': [30, 40, 47, 50, 43, 37, 38, 40, 50, 46, 421],
'Total': [90, 120, 128, 130, 110, 100, 102, 88, 120, 127, 1115]
} df =
pd.DataFrame(data)
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 3/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
features = df.drop(['Roll No', 'NAME', 'Total'], axis=1)
labels = df['Total']
regression_model = LinearRegression()
regression_model.fit(X_train, y_train)
y_pred_regression = regression_model.predict(X_test)
import pandas as pd
data = {
'Roll No': [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, None],
'NAME': ['Deep', 'Jayesh', 'Yash', 'Sara', 'Gita', 'Jinal', 'Kavita', 'Minal', 'Naresh', 'Rima', None],
'SUB 1': [30, 40, 45, 48, 35, 32, 36, 23, 43, 37, 369],
'SUB 2': [30, 40, 36, 32, 32, 31, 28, 25, 27, 44, 325],
'SUB 3': [30, 40, 47, 50, 43, 37, 38, 40, 50, 46, 421],
'Total': [90, 120, 128, 130, 110, 100, 102, 88, 120, 127, 1115]
}
df = pd.DataFrame(data)
print(df)
Roll No NAME SUB 1 SUB 2 SUB 3 Total
0 1.0 Deep 30 30 30 90
1 2.0 Jayesh 40 40 40 120
2 3.0 Yash 45 36 47 128
3 4.0 Sara 48 32 50 130
4 5.0 Gita 35 32 43 110
5 6.0 Jinal 32 31 37 100
6 7.0 Kavita 36 28 38 102
7 8.0 Minal 23 25 40 88
8 9.0 Naresh 43 27 50 120
9 10.0 Rima 37 44 46 127
10 NaN None 369 325 421 1115
import pandas as pd df =
pd.read_excel('/content/drive/MyDrive/sameer.xlsx')
df.iloc[0:5,0:4]
0 1.0 Dee 30 30
p
1 2.0 Jayes 40 40
h
2 3.0 Ya 45 36
sh
3 4.0 Sar 48 32
a
4 5.0 Gita 35 32
import pandas as pd df =
pd.read_excel('/content/drive/MyDrive/sameer.xlsx')
df.iloc[0:-1,0:-1]
0 1.0 Deep 30 30 30
1 2.0 Jayesh 40 40 40
2 3.0 Yash 45 36 47
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 4/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
3 4.0 Sara 48 32 50
4 5.0 Gita 35 32 43
5 6.0 Jinal 32 31 37
6 7.0 Kavita 36 28 38
7 8.0 Minal 23 25 40
8 9.0 Naresh 43 27 50
9 10.0 Rima 37 44 46
len(df)
df.describe()
0 1. De 3 3 3 90
0 ep 0 0 0
1 2. Jaye 4 4 4 12
0 sh 0 0 0 0
2 3. Ya 4 3 4 12
0 sh 5 6 7 8
df.tail(4)
7 8 Mina 23 25 40 88
. l
0
8 9 Nar 43 27 50 120
. esh
0
9 1 Rim 37 44 46 127
0. a
0
10 N NaN 369 325 421 111
a 5
N
df.sample
()
Roll NA SUB SUB SUB Tot
No ME 1 2 3 al
df.size
66
df1=sum(df.Total)
print(df1)
2230
df.drop
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 5/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
<bound method DataFrame.drop of Roll No NAME SUB 1 SUB 2 SUB 3 Total
0 1.0 Deep 30 30 30 90
1 2.0 Jayesh 40 40 40 120
2 3.0 Yash 45 36 47 128
3 4.0 Sara 48 32 50 130
4 5.0 Gita 35 32 43 110
5 6.0 Jinal 32 31 37 100
6 7.0 Kavita 36 28 38 102
7 8.0 Minal 23 25 40 88
8 9.0 Naresh 43 27 50 120
9 10.0 Rima 37 44 46 127
10 NaN NaN 369 325 421 1115>
import numpy as np
a = np.array([1, 2, 3, 4, 5]) b =
np.array([[10, 11, 12], [6, 7, 8]])
print(a.ndim)
print(b.ndim)
1
2
import numpy as np
a = np.array([1, 2, 3, 4, 5]) b =
np.array([[10, 11, 12], [6, 7, 8]],
ndmin=3)
print(a.ndim)
print(b.ndim)
1
3
import matplotlib.pyplot as plt
import pandas as pd
# Your data
data = {
'Roll No': [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
'NAME': ['Deep', 'Jayesh', 'Yash', 'Sara', 'Gita', 'Jinal', 'Kavita', 'Minal', 'Naresh', 'Rima'],
'SUB 1': [30, 40, 45, 48, 35, 32, 36, 23, 43, 37],
'SUB 2': [30, 40, 36, 32, 32, 31, 28, 25, 27, 44],
'SUB 3': [30, 40, 47, 50, 43, 37, 38, 40, 50, 46],
'Total': [90, 120, 128, 130, 110, 100, 102, 88, 120, 127]
}
# Creating a DataFrame
df =
pd.DataFrame(data)
# Plotting fig, ax =
plt.subplots(figsize=(10, 6))
# Adding legend
ax.legend()
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 6/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
# Your data
data = {
'Roll No': [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
'NAME': ['Deep', 'Jayesh', 'Yash', 'Sara', 'Gita', 'Jinal', 'Kavita', 'Minal', 'Naresh', 'Rima'],
'SUB 1': [30, 40, 45, 48, 35, 32, 36, 23, 43, 37],
'SUB 2': [30, 40, 36, 32, 32, 31, 28, 25, 27, 44],
'SUB 3': [30, 40, 47, 50, 43, 37, 38, 40, 50, 46],
'Total': [90, 120, 128, 130, 110, 100, 102, 88, 120, 127]
}
# Creating a DataFrame
df =
pd.DataFrame(data)
# Adding legend
ax.legend()
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 7/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
# Creating a DataFrame
df =
pd.DataFrame(data)
# Data for the pie chart subject_marks = student_data[['SUB 1', 'SUB 2',
'SUB 3', 'Total']].values.flatten() subject_labels = ['SUB 1', 'SUB 2',
'SUB 3', 'Total']
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 8/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
# Your data
data = {
'Roll No': [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
'NAME': ['Deep', 'Jayesh', 'Yash', 'Sara', 'Gita', 'Jinal', 'Kavita', 'Minal', 'Naresh', 'Rima'],
'SUB 1': [30, 40, 45, 48, 35, 32, 36, 23, 43, 37],
'SUB 2': [30, 40, 36, 32, 32, 31, 28, 25, 27, 44],
'SUB 3': [30, 40, 47, 50, 43, 37, 38, 40, 50, 46],
'Total': [90, 120, 128, 130, 110, 100, 102, 88, 120, 127]
}
# Creating a DataFrame
df =
pd.DataFrame(data)
ax.bar(df['NAME'], df['Total'],
color='skyblue')
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 9/10
1/19/24, 2:39 PM Untitled8.ipynb - Colaboratory
https://colab.research.google.com/drive/1XXnJqjEYBzg03yoTRUyHPPq9BkC2JTUQ#scrollTo=9tHj6NLy-M3M&printMode=true 10/10