KEMBAR78
ML Lab 02.ipynb - Colab | PDF | Statistical Analysis | Teaching Mathematics
0% found this document useful (0 votes)
23 views2 pages

ML Lab 02.ipynb - Colab

Uploaded by

Saptarshi Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

ML Lab 02.ipynb - Colab

Uploaded by

Saptarshi Das
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

8/28/25, 1:19 mL lab 02.

ipynb -
PM Colab

Double-click (or enter) to edit

a program to find the sum of two numbers using class and

objects saptarshi das- 2447028

class calculator:
def init (self,num1,num2):
self.num1=num1
self.num2=num2
def calc(self):
return self.num1+self.num2
inst= calculator(1,2)
res=inst.calc()
print(res)

Double-click (or enter) to

edit using numpy

module

import numpy as np
arr=np.array([[1,2,3],[4,5,6]])
print(f"type : {type(arr)}")
print(f"{arr.ndim}")
print(f"shape: {arr.shape}")
print(f"data type: {arr.dtype}")

type : <class
'numpy.ndarray'> 2
shape: (2, 3)
data type: int64

using statistic module

import statistics
data=[1,2,3,4,5,6,7,8,9]
print(f"mean of data: {statistics.harmonic_mean(data)}")
print(f"mode of data: {statistics.mode(data)}")
print(f"standard deviation: {statistics.stdev(data)}")
print(f"variance of data: {statistics.variance(data)}")

mean of data: 3.1813718614111375


mode of data: 1
standard deviation:
2.7386127875258306 variance of
data: 7.5

import pandas as pd
s=pd.Series([1,2,3,4])
df=pd.DataFrame(s)
print(df)
s1=df.squeeze()
s1

https://colab.research.google.com/drive/ 1/
1qe8ukIOpUlR3lVTkiPkWqOILchFJftJm#scrollTo=Jjh6v5HtJFhi&printMode=true 2
8/28/25, 1:19 mL lab 02.ipynb -
PM Colab
0
0 1
1 2
2 3
3 4
0

0 1

1 2

2 3

3 4

dtype: int64

import pandas as pd
df1=pd.DataFrame({'a':[1,2,3,4],'b':[5,6,7,8]})
df1.describe()
df1['c']=[10,11,12,13]
df1.describe()
df1.drop('c',axis=1,inplace=True
) df1.describe()

a b

count 4.000000 4.000000

mean 2.500000 6.500000

std 1.290994 1.290994

min 1.000000 5.000000

25% 1.750000 5.750000

50% 2.500000 6.500000

75% 3.250000 7.250000

max 4.000000 8.000000

https://colab.research.google.com/drive/ 2/
1qe8ukIOpUlR3lVTkiPkWqOILchFJftJm#scrollTo=Jjh6v5HtJFhi&printMode=true 2

You might also like