Welcome to the Simplilearn Community

Want to join the rest of our members? Sign up right away!

Sign Up

MACHINE LEARNING | MAR 10 - APR 01 | RISHI

Rishi_32

Member
Trainer
Hey Guys

The Thread is Open now. You can actually click on 'Watch Thread' and subscribe to email alerts for the same. This way we will be updated to any discussion on this portal. Attached are the screenshots for doing so.

Cheers
RishiScreen Shot 2018-03-12 at 4.24.13 AM.png Screen Shot 2018-03-12 at 4.24.57 AM.png
 

shreyasjag92

New Member
Alumni
## Importing The Libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd

## Setting The Current Working Directory
import os
print(os.getcwd())
os.chdir("C:\\Users\\zzzzz\\simplilearn")

## Importing the File
mydata=pd.read_csv("iris.csv")
iv = mydata.iloc[:,0:4].values
dv= mydata.iloc[:,-1].values
## Impute the missing values
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values="NaN",strategy="mean",axis=0)
iv[:,[1,2]]=imputer.fit_transform(iv[:,[1,2]])

## Categorical Variable Treatment
from sklearn.preprocessing import LabelEncoder , OneHotEncoder
labelencoder_dv = LabelEncoder()
dv=labelencoder_dv.fit_transform(dv)

from sklearn.model_selection import train_test_split
iv_train,iv_test,dv_train,dv_test=train_test_split(iv,dv,test_size=0.2,random_state=10)

from sklearn.linear_model import LinearRegression
reg = LinearRegression()
reg.fit(iv_train,dv_train)
trained = reg.predict(iv_train)

Is this the right way to predict the type of flower in iris.csv?
I have a feeling it isn't?!
If it is how do I convert it back to the names of the flowers?


Capture.PNG
 

dipitj1989

Member
Alumni
In the final project scaling the data will give negative values for the house rates so is scaling necessary .
 
Top