Welcome to the Simplilearn Community

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

Sign Up

Machine Learning:Wajahat:Feb 8th 2021 Batch

Prema.M

Well-Known Member
Staff member
Simplilearn Support
Alumni
Hi All,

Please find the dedicated thread for discussions.

Regards,
Prema M
 

_89898

Member
import pandas as pd
data = pd.read_csv('SalaryGender.csv')
type(data)
data.head()
data.shape
data.dtypes
new_dataframe = data.describe()
data.groupby('Gender').count()
new_dataframe.to_csv('SalaryGenderStatsDescr.csv')
data_excel = pd.read_excel('SalaryGenderStatsDescr.xlsx')

Getting below error after running the last code, plz check.

---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-22-955fd1aca913> in <module>
----> 1 data_excel = pd.read_excel('SalaryGenderStatsDescr.xlsx')

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_base.py in read_excel(io, sheet_name, header, names, index_col, usecols, squeeze, dtype, engine, converters, true_values, false_values, skiprows, nrows, na_values, keep_default_na, verbose, parse_dates, date_parser, thousands, comment, skipfooter, convert_float, mangle_dupe_cols, **kwds)
302
303 if not isinstance(io, ExcelFile):
--> 304 io = ExcelFile(io, engine=engine)
305 elif engine and engine != io.engine:
306 raise ValueError(

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_base.py in __init__(self, io, engine)
822 self._io = stringify_path(io)
823
--> 824 self._reader = self._engines[engine](self._io)
825
826 def __fspath__(self):

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py in __init__(self, filepath_or_buffer)
19 err_msg = "Install xlrd >= 1.0.0 for Excel support"
20 import_optional_dependency("xlrd", extra=err_msg)
---> 21 super().__init__(filepath_or_buffer)
22
23 @property

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_base.py in __init__(self, filepath_or_buffer)
351 self.book = self.load_workbook(filepath_or_buffer)
352 elif isinstance(filepath_or_buffer, str):
--> 353 self.book = self.load_workbook(filepath_or_buffer)
354 elif isinstance(filepath_or_buffer, bytes):
355 self.book = self.load_workbook(BytesIO(filepath_or_buffer))

/usr/local/lib/python3.7/site-packages/pandas/io/excel/_xlrd.py in load_workbook(self, filepath_or_buffer)
34 return open_workbook(file_contents=data)
35 else:
---> 36 return open_workbook(filepath_or_buffer)
37
38 @property

/usr/local/lib/python3.7/site-packages/xlrd/__init__.py in open_workbook(filename, logfile, verbosity, use_mmap, file_contents, encoding_override, formatting_info, on_demand, ragged_rows)
109 else:
110 filename = os.path.expanduser(filename)
--> 111 with open(filename, "rb") as f:
112 peek = f.read(peeksz)
113 if peek == b"PK\x03\x04": # a ZIP file

FileNotFoundError: [Errno 2] No such file or directory: 'SalaryGenderStatsDescr.xlsx'
 

Anjum Rohra

Member
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
df = pd.read_csv('mtcars.csv')
df.head()
df.shape
df.info()
df['hp'].mean()
df.describe()
plt.figure(figsize=(10,10))
sns.heatmap(data = correlation, annot=True);
 
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

data = pd.read_csv('mtcars.csv')

type(data)
pandas.core.frame.DataFrame

data.shape
(32, 12)

data.corr()
data.describe()

data['hp'].mean()
146.6875

correlations = data.corr()
sns.heatmap(data=correlations, square=True, annot=True)


data.isna().any().any()
False
 
Hello,
Please find attached my assignment for Day-2.
Missing values and Outlier treatment.
Thanks.
 

Attachments

  • AssignDay2.pdf
    81.2 KB · Views: 7

_79929

Member
Assignment 1 and 2
 

Attachments

  • load_diabetes_Narender.pdf
    998 KB · Views: 6
  • mtcars_Narender_day2.pdf
    27.6 KB · Views: 4
Last edited:

Kripesh.K

Member
Please find attached my assignment for 09'th-Feb

Missing values and Outlier treatment.

Regards,
Kripesh.K
 

Attachments

  • Assignment-mtcars.zip
    52.4 KB · Views: 0
  • Assignment-diabetes.zip
    21 KB · Views: 0
day2 assignment
 

Attachments

  • mtcars.pdf
    76.9 KB · Views: 0
  • mtcars.pdf
    76.9 KB · Views: 0
  • mtcars.pdf
    76.9 KB · Views: 0
  • diabetes work.pdf
    47.8 KB · Views: 1

Kripesh.K

Member
Please find Boston house pricing assignment -MultiLinearRegression

1.Ridge
2.Lasso
3.ElasticNet

Regards,
Kripesh.K
 

Attachments

  • Copy_of_Boston_Assignment(1) - Jupyter Notebook.pdf
    805.9 KB · Views: 8

Kripesh.K

Member
My training dataset does not have any Nan where as im getting above message
while trying to fit my model


---------------------------------------------------------------------------
ValueError Traceback (most recent call last)

<ipython-input-245-f7d808fe44e8> in <module>()
----> 1 lin.fit(X_Train,Y_Train)

3 frames

/usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in _assert_all_finite(X, allow_nan, msg_dtype)
58 msg_err.format
59 (type_err,
---> 60 msg_dtype if msg_dtype is not None else X.dtype)
61 )
62 # for object dtype data, we only check for NaNs (GH-13254)

ValueError: Input contains NaN, infinity or a value too large for dtype('float64').

Attached code for reference
 

Attachments

  • B_igMart_Assignment - Jupyter Notebook.pdf
    427.8 KB · Views: 1

Kripesh.K

Member
IRIS data set
Logistic Regression
 

Attachments

  • LogisticRegression.pdf
    50.1 KB · Views: 0
  • LogisticRegression.pdf
    50.1 KB · Views: 0

Pratick Jha

New Member
MT Cars and Middle_tn_school assignements
 

Attachments

  • MTcars -Assignment.txt
    393 bytes · Views: 1
  • middle_tn_School -Assignment.txt
    406 bytes · Views: 1
Last edited:
Hello,
Please find attached my code for the insurance cost prediction.

I have used simple Linear reg, Lasso, Ridge and ElasticNet Regression.
Lasso gives the best R2 score of 77.92%

Used dabl to get a quick comparison with the other algorithms.
With dabl I get a best R2 score of 83.7% with Decision tree regressor.
Thanks.
 

Attachments

  • Insurance Cost Prediction.pdf
    299.2 KB · Views: 9
Hello,

Please find attached my code for iris data classification.
I have used Logistic regression and K-nearest neighbor classifier.
dabl was used for quick model comparison with just a few lines of code.

Thanks.
 

Attachments

  • Iris dataset classification.pdf
    529.2 KB · Views: 3
LDA on iris and digits
 

Attachments

  • iris Lda feature engg assignment.pdf
    40.3 KB · Views: 4
  • digits Lda feature engg assignment.pdf
    40.6 KB · Views: 5
Top