0% found this document useful (0 votes)
25 views5 pages

Python Lab File-2

Lab pdf

Uploaded by

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

Python Lab File-2

Lab pdf

Uploaded by

kunal kalra
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 5
NAVNEET KAUR 2821319 PROGRAM 9: Write a program to implement different visualization techniques on the sample data set. MATPLOTLIB: Scatter Plot import matplotlib pyplot as plt 8, pit scatter(x,y) pltshow(), OUTPUT: NAVNEET KAUR Line plotting Code pit plot(x.y) plt.show() OUTP' Histogram # importing packages import seaborn as sns import matplotlib.pyplot as plt import pandas as pd # reading the database data = pd.read_csv("tips.csv") sns.histplot(x='total_bill’, data=data, kde=True, hue='sex') plt.show() OUTPUT: FY total bit 23[ Page 2821319 NAVNEET KAUR 2821319 PROGRAM - 10: Write a program to implement different hypothesis tests on sample datasets, T-test (One-sample t-test) you have 10 ages, and you are checking whether the average age is 30 or not. (Check the code below for that using Python) from scipy.stats import ttest_lsamp import numpy as np ages = [32,34,29,29,22,39,38,37,36,30,26,22,22 print(ages) ages_mean = np.mean(ages) print(ages_mean) tset, pval = ttest_1samp(ages, 30) print("p-values" pval) if pval < 0.05: # alpha value is 0.05 or 5% print (" we are rejecting null hypothesis") else print ("we are accepting null hypothesis") OUTPUT [32, 34, 29, 29, 22, 39, 38, 37, 36, 30, 26, 22, 22] 30.46153846153846 p-values 0.7920561355855448 we are accepting null hypothesis NAVNEET KAUR 2821319 Z test For example, again we are using a z-test for blood pressure with some mean like 156 (python code is below for same) one-sample Z test. 1. One-sample Z test import pandas as pd from scipy import stats df= pd.read_csv("blood_pressure.csv") from statsmodels.stats import weightstats as stests zAest .pval = stests.ztest(dt]'bp_before'), x2=None, value=156) print(float(pval)) if pval<0.05 print ("reject the null hypothesis") else print ("accept null hypothesis") OUTPUT @.6651614730255063 accept null hypothesis NAVNEET KAUR 2821319 2. Two-sample Z test HO: mean of the two groups is 0 HI: mean of the two groups is not 0 Example: we are checking in blood data after blood and before blood data.(code in python below) atest, pvall = stests.ztest(dif'bp_before'], x2=di]'bp_after'], value=0.alternative='two- sided’) print(float(pval 1) if pval<0,05 print ("reject null hypothesis") else print ("accept null hypothesis") OUTPUT @.002162306611369422 accept null hypothesis

You might also like