# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

dataset=pd.read_csv("D:\\Machine learning\\BVM\\Day-1_16092018\\DATASET\\Data.csv")

dataset

working=dataset.iloc[:,1:3]

working

plt.plot(working.iloc[:,0],working.iloc[:,1])
plt.title("Graph of Age Vs Salary")
plt.xlabel("Age")
plt.ylabel("Salary")
plt.show()

working.iloc[:,1]

plt.bar(working.iloc[:,0],working.iloc[:,1],align='edge',width=2,alpha=0.3)
plt.xlabel("Age")
plt.ylabel("Salary")
plt.show()

working

x=working.copy()

# # Data Preprocessing

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

dataset=pd.read_csv('D:\Machine learning\BVM\Day-1_16092018\DATASET\\Data.csv')

dataset

X=dataset.iloc[:,0:3].values

X

# ### We can dalete row with nan data or we replace it with zero,mean,median or more frequent value

y=dataset.iloc[:,-1].values

y

from sklearn.preprocessing import Imputer


imputer=Imputer()
imputer=imputer.fit(X[:1,1:3])
X[:,1:3]=imputer.transform(X[:,1:3])

X

# # Encode Catagorical Data

from sklearn.preprocessing import LabelEncoder,OneHotEncoder

labelencoder_X=LabelEncoder()
X[:,0]=labelencoder_X.fit_transform(X[:,0])

X

one=OneHotEncoder(categorical_features=[0])
X=one.fit_transform(X).toarray()

X

labelencoder_y=LabelEncoder()
y=labelencoder_y.fit_transform(y)

y

from sklearn.cross_validation import train_test_split

x_train,x_test,y_train,y_test=train_test_split(X,y,test_size=0.4,random_state=1)

x_train

x_test

X

from sklearn.preprocessing import StandardScaler
sc_x=StandardScaler().fit(x_train)
x_train=sc_x.transform(x_train)

x_train



StarcoderdataJupyterScriptsDedupFiltered