You are on page 1of 14

Project 1:

To represents a matplotlib as railway gauges file.

import pandas as pd

import matplotlib.pyplot as plt

df=pd.read_csv("railway_gauges.csv")

print(df.head(10))

df=df.drop('Total',axis=1)

ax=df.plot(x='Year',kind="bar")

plt.xticks(rotation=80)

plt.xlabel('Year')

plt.ylabel('Total')

plt.title('gauges:Number of raileway tracks installed per year')

plt.savefig('railway_gauges.png')

plt.show()
Project2:
To represents a reviews of score in pandas module

import pandas as pd

df=pd.read_csv('ign.csv')

print(df.head(3))

print(df.shape)

print(df.iloc[:5,:])

print(df.index)

print(df.loc[:4,"platform"])

print(df.loc[:5,["score","release_year"]])

type(df["score"])

type(df["title"])

print(df["title"].head(3))

print(df["score"].mean())

print(df["score"]/3)
score_filter=df["score"]>9

filtered_df=df[score_filter]

filtered_df.head(3)

ipad_filter=(df["score"]>9)&(df["platform"]=="ipad")

filtered_df=df[ipad_filter]

filtered_df.head()

Project3:
To represents a scatter
A:
import pandas as pd

import matplotlib.pyplot as plt


dataframe = pd.read_csv("scottish_hills.csv")

x = dataframe.Height

y = dataframe.Latitude

plt.scatter(x,y)

plt.show()

B:
import pandas as pd

import matplotlib.pyplot as plt

from scipy.stats import linregress


dataframe = pd.read_csv("scottish_hills.csv")

x = dataframe.Height

y = dataframe.Latitude

stats = linregress(x, y)

m = stats.slope

b = stats.intercept

plt.figure(figsize=(10,10))

plt.scatter(x,y,marker='x')

plt.plot(x,m * x + b, color="red", linewidth=3)

plt.xlabel("Height (m)",fontsize=20)

plt.ylabel("Latitude",fontsize=20)

plt.xticks(fontsize=10)
plt.yticks(fontsize=10)

plt.savefig("python-linear-reg-custom.png")

Project4:
To represents a bedrooms in matplotlib
import numpy as np

import pandas as pd

import matplotlib.pyplot as plt

import seaborn as sns

import mpl_toolkits

dt=pd.read_csv("kc_house_data.csv")

dt.head()

dt.describe()

dt['bedrooms'].value_counts().plot(kind='bar')

plt.title('number of bedrooms')

plt.xlabel('Bedrooms')

plt.ylabel('Count')

sns.despine

plt.figure(figsize=(10,10))

sns.jointplot(x=dt.lat.values,y=dt.long.values,size=10)
plt.ylabel('Longitude',fontsize=10)

plt.xlabel('Longitude',fontsize=10)

plt.show()

sns.despine

plt.scatter(dt.price,dt.sqft_living)

plt.title("price vs square feet")

plt.scatter(dt.price,dt.long)

plt.title("price vs location of the area")

plt.scatter(dt.bedrooms,dt.price)

plt.title("bedrooms and price")

plt.xlabel("bedrooms")

plt.ylabel("price")

plt.show()

sns.despine
Project5:
Test the mathematical equation (7a+3b+4c+9d) and display
output along with any graph with these equation.
from random import randint

from sklearn.linear_model import LinearRegression

from matplotlib import pyplot as plt

TRAIN_SET_LIMIT=1000

TRAIN_SET_COUNT=100

TRAIN_INPUT=list()

TRAIN_OUTPUT=list()
for i in range(TRAIN_SET_COUNT):

a = randint(0,TRAIN_SET_LIMIT)

b = randint(0,TRAIN_SET_LIMIT)

c = randint(0,TRAIN_SET_LIMIT)

d = randint(0,TRAIN_SET_LIMIT)

op = (7*a)+(3*b)+(4*c)+(9*d)

TRAIN_INPUT.append([a,b,c,d])

TRAIN_OUTPUT.append(op)

predictor=LinearRegression(n_jobs=-1)

predictor.fit(X=TRAIN_INPUT,y=TRAIN_OUTPUT)

X = [[]]

for i in range(4):

n = input('enter n value:')

X.append(n)

X_TEST = [[a,b,c,d]]

outcome = predictor.predict(X_TEST)
coefficients = predictor.coef_

print('outcome{} \n coefficients{}'.format(outcome,coefficients))

plt.bar([a,b,c,d],width=50,height=100)

plt.xlabel('coefficients')

plt.ylabel('outcomes')

plt.title('Suppervised machine learn equation')

plt.show()

You might also like