Coder Social home page Coder Social logo

ex02-outlier's Introduction

Ex02-Outlier

You are given bhp.csv which contains property prices in the city of banglore, India. You need to examine price_per_sqft column and do following,

(1) Remove outliers using IQR

(2) After removing outliers in step 1, you get a new dataframe.

(3) use zscore of 3 to remove outliers. This is quite similar to IQR and you will get exact same result

(4) for the data set height_weight.csv find the following

(i) Using IQR detect weight outliers and print them

(ii) Using IQR, detect height outliers and print them

AIM:

To detect and remove the outlier in the given dataset and save the final

CODE


import pandas as pd
import numpy as np
import seaborn as sns
df=pd.read_csv("bhp.csv")
df
df.head
df.info()
df.describe()
df.isnull().sum()
df.shape
sns.boxplot(x="price_per_sqft",data=df)
q1=df['price_per_sqft'].quantile(0.25)
q3=df['price_per_sqft'].quantile(0.75)
print("First Quantile=",q1,"\nSecond Quantile=",q3)
IQR=q3-q1
u1=q3+1.5*IQR
ll=q1-1.5*IQR
df1=df[((df['price_per_sqft']>=ll)&(df['price_per_sqft']<=u1))]
df1
df1.shape
sns.boxplot(x="price_per_sqft",data=df1)
from scipy import stats
z=np.abs(stats.zscore(df['price_per_sqft']))
df2=df[(z<3)]
df2
sns.boxplot(x="price_per_sqft",data=df2)
df3=pd.read_csv("height_weight.csv")
df3
df3.head()
df3.info()
df3.describe()
df3.isnull.sum()
df3.shape
q1 = df3['weight'].quantile(0.25)
q3 = df3['weight'].quantile(0.75)
print("First Quantile =",q1,"\nSecond Quantile =",q3)
IQR = q3-q1
ul = q3+1.5*IQR
ll = q1-1.5*IQR
df4 =df3[((df3['weight']>=ll)&(df3['weight']<=ul))]
df4
df4.shape

sns.boxplot(x="weight",data=df4)
sns.boxplot(x="height",data=df3)

q1 = df3['height'].quantile(0.25)
q3 = df3['height'].quantile(0.75)
print("First Quantile =",q1,"\nSecond Quantile =",q3)

IQR = q3-q1
ul = q3+1.5*IQR
ll = q1-1.5*IQR
df5 =df3[((df3['height']>=ll)&(df3['height']<=ul))]
df5
df5.shape
sns.boxplot(x="height",data=df5)

OUTPUT

GITHUB

HEAD

GITHUB

INFO

GITHUB

DESCRIBE

GITHUB

ISNULL()SUM()

GITHUB

SHAPE

GITHUB

BOXPLOT

GITHUB

QUANTILE

GITHUB

IQR

GITHUB

SHAPE

GITHUB

BOXPLOT

GITHUB

ZSCORE

GITHUB

BOXPLOT

GITHUB

READ

GITHUB

HEAD

GITHUB

INFO

GITHUB

DESCRIBE

GITHUB

NULL

GITHUB

SHAPE

GITHUB

BOXPLOT

GITHUB

QUANTILE

GITHUB

IQR

GITHUB

BOXPLOT WEIGHT

GITHUB

BOXPLOT HEIGHT

GITHUB

QUANTILE

GITHUB

IQR

GITHUB

SHAPE

GITHUB

BOXPLOT

GITHUB

RESULT

Hence the outlier is detected and reduced the error successfully.

ex02-outlier's People

Contributors

karthi-govindharaju-ai avatar ashikajubi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.