Welcome to the Simplilearn Community

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

Sign Up

Machine Learning | Feb 3 - Feb 25 | Prashant Nair

Prashant_Nair

Well-Known Member
Simplilearn Support
Alumni
Trainer
Hello and Welcome to Machine Learning (Python) Course!
I am equally excited to deliver this course. PFB the link for downloading Anaconda Navigator which you will need to install in your machine to perform hands-on exercises

For Mac Users:
https://repo.continuum.io/archive/Anaconda3-5.0.1-MacOSX-x86_64.pkg

For Windows Users:
https://repo.continuum.io/archive/Anaconda3-5.0.1-Windows-x86_64.exe

For Linux Users:
https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh

Incase if any of the above link gets outdated you can get the new link from https://www.anaconda.com/download
 

Kulasekhar M V

Member
Alumni
Prashant when I am trying the assignment Health ( pre processing) when I am trying to execute the imputer fit transform it throws an error I double checked multiple times syantax not sure what is going wrong

code is :
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='Nan',strategy='mean',axis=0)
features[:,[1,2]] = imputer.fit_transform(features[:,[1,2]])

error I am getting for third line is :
File "C:\Users\mvenkata\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\preprocessing\imputation.py", line 29, in _get_mask
if value_to_mask == "NaN" or np.isnan(value_to_mask):
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

only thing I see difference from your class when I installed I see spyder3.6 it shows where as yours shows 3.5 hope it is not an issue. it is going to impute.py the error. help me as I strucked in this error . thanks
 

msvkrishna

Member
Alumni
Assignment Day2
=============
1. Perform Preprocessing over health.csv
2. Perform LR over Insurance.csv to predict the average claims per year


Hi Prashanth..
please find the zip files for both assignments ( it has python code, text file for steps, text file with console output)

for the second assignment : Avg Claim Quote is : 25227.495107565002
Detail :
Formula derived from the model : y= b0 + b1(x)
Avg Claim per year (y) = - 53812.13307241 + 1663.99217221 * Age (x)

AvgAge = dset.iloc[:,0].mean(axis=0)
AvgClaim = - 53812.13307241 + 1663.99217221 * AvgAge

Average Age = 47.5
Average Claim = 25227.495107565002​

thanks
Krishna
 

Attachments

  • AssgnmntDay2_HealthCSV_PreProcess.zip
    2.9 KB · Views: 12
  • AssgnmntDay2_InsuranceCSV_LR.zip
    4.2 KB · Views: 10

Prashant_Nair

Well-Known Member
Simplilearn Support
Alumni
Trainer
Prashant when I am trying the assignment Health ( pre processing) when I am trying to execute the imputer fit transform it throws an error I double checked multiple times syantax not sure what is going wrong

code is :
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='Nan',strategy='mean',axis=0)
features[:,[1,2]] = imputer.fit_transform(features[:,[1,2]])

error I am getting for third line is :
File "C:\Users\mvenkata\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\preprocessing\imputation.py", line 29, in _get_mask
if value_to_mask == "NaN" or np.isnan(value_to_mask):
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

only thing I see difference from your class when I installed I see spyder3.6 it shows where as yours shows 3.5 hope it is not an issue. it is going to impute.py the error. help me as I strucked in this error . thanks
Hi

Please try the below code:

from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='NaN',strategy='mean',axis=0)
features[:,[1,2]] = imputer.fit_transform(features[:,[1,2]])
 

Kulasekhar M V

Member
Alumni
Thread locked for this batch learners.
Please post your queries below.
Mnaoj
I am not able to upload zip files it contious throws errors. I am suppose to upload my completed assignements. what is the problem, it is not even allowing me to upload the jpeg for the error to show
 

Arun_4721

Member
Alumni
Assignment Day2
=============
1. Perform Preprocessing over health.csv
2. Perform LR over Insurance.csv to predict the average claims per year

Hi Prashant,
Attached is the Assignment project.In Addition to it I have created a sample automobile data set with more number of features in it and Predicted score.Kindly validate the steps I followed is correct.
 

Attachments

  • ML_Assignments_Arun_05Feb2018.zip
    40.4 KB · Views: 11

_21361

Member
Alumni
Hi Prashant, I am not able to execute "import numpy as ny" so as Pandas and "metlplotlib.pyplot" and even the database in console. When i click "ctrl+enter" i shows a drop down error list and does not execute in "Console". Please help as per attached png.
 

Attachments

  • Machine Learning - Ticket.PNG
    Machine Learning - Ticket.PNG
    34.7 KB · Views: 4

Kulasekhar M V

Member
Alumni
Prashant
find the assignment : Health preprossing uploaded
Mnaoj
I am not able to upload zip files it contious throws errors. I am suppose to upload my completed assignements. what is the problem, it is not even allowing me to upload the jpeg for the error to show
Mnaoj
I am not able to upload zip files it contious throws errors. I am suppose to upload my completed assignements. what is the problem, it is not even allowing me to upload the jpeg for the error to show
Manoj
I still face the same problem. Did you had a chance to check with out solving this I cannot upload assignment files. it is contiously throws error and not allowing me to upload anything. Modify to upload such a way we can upload py file directly
 

Prashant_Nair

Well-Known Member
Simplilearn Support
Alumni
Trainer
Hi Prashant, I am not able to execute "import numpy as ny" so as Pandas and "metlplotlib.pyplot" and even the database in console. When i click "ctrl+enter" i shows a drop down error list and does not execute in "Console". Please help as per attached png.
Try selecting individual lines and press Ctrl+Enter
 

K Manoj

Moderator
Staff member
Simplilearn Support
Prashant
find the assignment : Health preprossing uploaded


Manoj
I still face the same problem. Did you had a chance to check with out solving this I cannot upload assignment files. it is contiously throws error and not allowing me to upload anything. Modify to upload such a way we can upload py file directly

You can only post files less than 1 mb in size. Check attachment.
 

Attachments

  • Projects.zip
    43.5 KB · Views: 10

Mukesh Kumaar Singh

Member
Alumni
Customer
Assignment Day2
=============
1. Perform Preprocessing over health.csv
2. Perform LR over Insurance.csv to predict the average claims per year

I have completed the assignment but unable to load. Can you please check with support. I am getting below error
"
There was a problem uploading your file.
Mukesh_04Feb.zip
"
 

ATHUL B KAMMATH

Member
Alumni
Sir...
i have a doubt...

from sklearn.preprocessing import OneHotEncoder
ohe = OneHotEncoder(categorical_features=[0])
features = ohe.fit_transform(features).toarray()


In the above shown code (shown in Preprocessing_dataset), what [0] represents...?
if we change to [1]... what will be output...?
please reply....
 

ATHUL B KAMMATH

Member
Alumni
Assignment Day2
=============
1. Perform Preprocessing over health.csv
2. Perform LR over Insurance.csv to predict the average claims per year


Sir..

The Assignment day 2 file is attached with this .
Also i have one doubt which i asked in #29.
Please give reply.

Thank you

ATHUL
 

Attachments

  • Athul_assingmentday2.zip
    2.1 KB · Views: 7

_20313

New Member
Alumni
Assignment Day2
=============
1. Perform Preprocessing over health.csv
2. Perform LR over Insurance.csv to predict the average claims per year

Hi Prashant,

Please find attached assignment for day 2.

Regards,
Nandita
 

Attachments

  • Machine learning_assignment_day 2_Nandita.zip
    2.2 KB · Views: 7

Ayan Ghosh_2

New Member
Alumni
Hi Prashant

Am getting this error when I try to use imputer:
from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='NaN',strategy='mean',axis=0)
features[:,[1,2]] = imputer.fit_transform(features[:,[1,2]])
Traceback (most recent call last):

File "<ipython-input-67-b9ff10a9ccc6>", line 3, in <module>
features[:,[1,2]] = imputer.fit_transform(features[:,[1,2]])

File "/Users/simplilearn/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py", line 1964, in __getitem__
return self._getitem_column(key)

File "/Users/simplilearn/anaconda3/lib/python3.6/site-packages/pandas/core/frame.py", line 1971, in _getitem_column
return self._get_item_cache(key)

File "/Users/simplilearn/anaconda3/lib/python3.6/site-packages/pandas/core/generic.py", line 1643, in _get_item_cache
res = cache.get(item)

TypeError: unhashable type: 'slice'

Below is my code till now. All the steps before the imputer section worked fine:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

dataset=pd.read_csv('Health.csv')
features=dataset.iloc[:,0:3]
label=dataset.iloc[:,[3]]


from sklearn.preprocessing import Imputer
imputer = Imputer(missing_values='NaN',strategy='mean',axis=0)
features[:,[1,2]] = imputer.fit_transform(features[:,[1,2]])
 

Priyavart Thakur

Member
Alumni
Hi Prashant,

I was practising the Simple LR example of last class in spyder but I am getting different result for
r2_score(Y_test,y_prediction)
Output coming as -754439489.202 instead of 0.981642348207(which is the result of model.score(X_test,Y_test))
Could you please help, what I am doing wrong. Attached the example file I have created
Thanks,
Priyavart
 

Attachments

  • Simple LR.zip
    1.1 KB · Views: 9

Priyavart Thakur

Member
Alumni
Hi Prashant,

I was practising the Simple LR example of last class in spyder but I am getting different result for
r2_score(Y_test,y_prediction)
Output coming as -754439489.202 instead of 0.981642348207(which is the result of model.score(X_test,Y_test))
Could you please help, what I am doing wrong. Attached the example file I have created
Thanks,
Priyavart


I found the issue and now it is working!!..
 
Last edited:

_21361

Member
Alumni
Good morning Prashant,

Please find attached, practice first run as Example. As posted by you will work on the Ist Assignment. Thanks for you help.

Regards,

Vijay Marupadi.
 

Attachments

  • Day2DayLabs.zip
    8 KB · Views: 10

Prashant_Nair

Well-Known Member
Simplilearn Support
Alumni
Trainer
Hi All

PFA Basics.py file which I missed yesterday. Also I will be uploading assignments today.

Regards
 

Attachments

  • Basics.zip
    1.1 KB · Views: 50

ATHUL B KAMMATH

Member
Alumni
I didnt saw any question in there

Sir...
i have a doubt...

from sklearn.preprocessing import OneHotEncoder
ohe = OneHotEncoder(categorical_features=[0])
features = ohe.fit_transform(features).toarray()


In the above shown code (shown in Preprocessing_dataset), what [0] represents...?
if we change [0 ]to [1] in code ...
ie instead of 0, if we give 1 in braces , what will be output...and what will be order of the column....?
please reply....
 

Prashant_Nair

Well-Known Member
Simplilearn Support
Alumni
Trainer
Hi All

PFA the Day4 Codes and Notepad

Happy Learning !!

Regards
 

Attachments

  • Day4Labs_Notepad.zip
    129.1 KB · Views: 63

ATHUL B KAMMATH

Member
Alumni
Sir..
Now we are studying only to model a systm..(using test and train)?
is it..?
So how we can give the input data to check the get the output...?
please reply...
 
Top