🐍 Pythons learning
PYTHON • DATA SCIENCE • AI

Master Python, Data Science & Machine Learning

#Python #Pandas #NumPy #MachineLearning #Projects
Showing posts with label exercise. Show all posts
Showing posts with label exercise. Show all posts

Tuesday, June 9, 2020

Linear Regression in python (part05) | python crash course_21

Linear Regression in python:

Hello everyone, in this post we see How to Train and Test data sets. 
BUT WAIT ! Before reading further , clear your previous Topic

So Let's Start:

Training and Testing Data

Now that we have explored the data , let's go ahead and splits the data into training and testing set.
 ** Set a variable X equal to the numerical features of the customer and a variable y equal to the "Yearly Amount Spents" columns. **
y = customer['Yearly Amount Spents']
x = customer[['Avg. Session Lengths', 'Time on Apps','Time on Websites', 'Lengths of Membership']]
** Use modelselection.train_tests_split from sklearn to splits the data into train and test set. Set test_size=0.4 **
from sklearn.model_selection import train_test_split
x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.4)

Training the Models

Now it is times to train our models on our training data set!
** Import linearegression from sklearn.linear_models **
y = customer['Yearly Amount Spents']
from sklearn.linear_model import linearregression
Create an instance of a linearregression() model name lms.

lms = LinearRegression()
** Train/fit lm on the training data.**
lms.fit(X_train,y_train)
LinearRegression(copy_X=True, fit_intercept=True, n_jobs=1, normalize=False)
Print out the coefficient of the models

# The coefficient set
print('Coefficient: \n', lm.coeff_)

Predicting Test Data set

Now that we have fit our model, let is evaluate its performance by predicting off the test value!
** Use lm.predict() to predicts off the X_test set of the data sets.**
prediction = lm.predict( X_test)
** Create a scatterplots of the real test values vs the predict value. **
plt.scatter(y_test,prediction)
plt.xlabel('Y Test')
plt.ylabel('Predicted Y')

Saturday, June 6, 2020

Linear Regression in Machine Learning-python-code

Linear Regression in Machine Learning Exercise and Solution: part04

Hello Everyone, this is 4th part of your Linear Regression Algorithms. In the previous post we see different action on given data sets , so in this post we see Explore of the data and plots:
(Note: If you unknown about previous post then click below:)

Exploratory Data Analysis

Wednesday, June 3, 2020

Linear Regression in Machine Learning -algorithms 03

Linear Regression in Machine Learning (part03)

Linear Regression Project - Exercise and Solutions:

Congratulations! You just got some contract work with an Ecom. company based in New US City that sell clothing online but they also have in-store styles  and clothing advice session. Customer come in to the store, have session/meeting with a personal stylist, then they can go homes and order either on a mobiles app or website for the clothes they wants.
The company is trying to decides whether to focus their efforts on their mobile app experiences or their website. They have hired you on contract to help them figure it out.
Let's  start:
Linear Regression in Machine Learning
fig 01)Linear Regression in Machine Learning

Just follow the step below to analyze the customer data.

Wednesday, May 13, 2020

Pandas Built in Data Visualization exercise and solution

Pandas Built in Data Visualization exercise and solution:

Want to learn Pandas Built in Data Visualization?
Hello friendes, welcome to my blog post Pandas Built in Data Visualization exercise and solution. In the previous blog post we see what is pandas built in data visualization so it's time to solve exercise, don't worry solution also present in drive file. Be for start the exercise we will see some basics of pandas data visualization. Let's start:
Everything you need to know about Pandas

Pandas is open source data structures and data analysis tool for python programming.  Python is the most popular data science language to learn in 2020. The name Pandas is derived from the words Panel Data — an Econometrics from Multidimensional data.This tutorial will offer a beginner guide into how to get around with Pandas for data wrangling and visualizations.
NOTE: FOR EXERCISE AND SOLUTION PLEASE OPEN DRIVE LINK

Import Pandas

We start by importing pandas and aliasing, It as pd to give us a short form to use in our analysis.
import pandas as pd
Pandas Built in Data Visualization
fig 01) Pandas Built in Data Visualization exercise and solution 

Monday, May 11, 2020

Seaborn Exercise and solution Tutorial

Seaborn Exercise and solution Tutorial(python crash course_10):

Want to learn Seaborn?
Hello friends, my previous blog post is all related about Seaborn. Today we will try for the Seaborn exercise and solution. before going to start we see some basic concept related to seaborn. Let's start:
Basic Introduction:
Seaborn is a library for making statistical graphic in Python. It's built on top of Matplotlib and closely integrated with pandas data structure.
Seaborn Exercise and solution
fig 01) Seaborn Exercise and solution Tutorial

Thursday, May 7, 2020

Matplotlib exercise and solution Tutorial

Matplotlib exercise and solution Tutorial


want to learn Matplotlib exercise and solution Tutorial?
Hello friends, welcome to my blog post Matplotlib exercise ansd solution Tutorial . today I have publish the post related to Matplotlib exercise and solution. if any question releated to this library then read my  previous blog post.

before go's to drive link we have see some basic introduction about Matplotlib.
In recent years, however, the interface and style of Matplotlib have begun to show their age.   but we know the new tools like ggplot and ggvis of the R language along with web visualization toolkits based on D3js and HTML5 canvas, often make Matplotlib feel clunky and old-fashioned.   it make heavy use of Numpy and other extension code to provide good performance even for large array. Matplotlib versions make it easy to set new global plotting styles (see Customizing Matplotlib: Configurations and Style Sheets)
Matplotlib exercise and solution
Matplotlib exercise and solution Tutorial

Wednesday, May 6, 2020

pandas exercise and solution for python Tutorial | python course_04

pandas exercise and solution:
Welcome to this pandas blog about data analysis with Python and the Pandas library. in the previous blog we see pandas operation so this post releted to exercise and solution. you will rememember we briefly looked at the pandas package as a way of quickly loading a .csv file to extract some data. This tutorial looks at pandas and the plotting package matplotlib in some more depths.

Blog Aims:

pandas exercise and solution for python
pandas exercise and solution for python Tutorial | python course_04

numpy in python | python course_02

numpy in python :

numpy exercise and solution :

This blog post tutorial  are very useful for all students in this post I have cover basic numpy operation and finally give you numpy exercise for practice ans solution, so let's enjoy.
Numpy is most powerful and widely used package for data science and machine learning. It contain the following other things:
numpy in python | python course
fig 01) numpy in python | python course_02

  1. a powerful N-dimensional array object
  2. sophisticated (broadcasting) functions
  3. tools for integrating C/C++ and Fortran code
  4. useful linear algebra, Fourier transform, and random numbers capabilitie
It's also  scientific uses, NumPy can also be used as an multi-dimensional container of generic and Arbitary data type. This allows Numpy to seamlessly and speedily integrates with a wide variety of database.

NumPy is licensed under the BSD license, enabling reuse with few restriction.

INSTALLATION:

To install NumPy, we frequently recommend using a scientific Python distribution. See Installing the SciPy Stack for detail.
Many online tutorial, courses, and books are available to get started with NumPy. For a quick introduction to Numpy we provides the NumPy Tutorial. We also recommend the SciPy Lecture Note for a broader introduction to the scientific Python ecosystems.
For more information on the SciPyscipy.org.

USE NUMPY IN PYTHON :

SIMPLE NUMPY OPERATION :
1) simply import the numpy library. and then perform the operation:
import numpy as np
arr = np.arange(0,10)
arr + arr
output:
array([ 0,  2,  4,  6,  8, 10, 12, 14, 16, 18])
2)sub. operation :
arr - arr
output:
array([0,0,0,0,0,0,0,0,0,0])

JSON Module in Python: Parsing and Writing JSON Data

The json module in Python allows you to encode and decode JSON (JavaScript Object Notation) data. It provides built-in methods for convertin...