Posts

Showing posts from May, 2021

Dummy Variables & One Hot Encoding

Image
  Dummy Variables & One Hot Encoding Dummy Variables vs One Hot Encoding Dummy variable: You replace the categorical variable by different boolean variables (taking value 0 or 1) to encode whether or not the categorical value had a certain value. For encoding a categorical variable that can take k values, you only need  k-1  dummy variables. Often used in more statistical domains as it uses the “correct number of degrees of freedom”. One-hot encoding : You replace the categorical variable by a vector indicating “in which dimension” your variables lives. This vector will have  k  dimensions. Often used in CS domains. Lets code  First of all we importing Pandas library Now we read the data from csv file using read_csv method of panda library Here you can clearly see that our data set has a categorical data which is town column . so we know that  categorical  data  can not acceptable in machine learning so we have to handle this problem an...

Linear Regression With Multiple Variable

Image
  Linear Regression with Multiple Variable Here we predict the house price by its area,bedroom & age. first we import necessary library Now we read CSV file by using Pandas library's read_csv method Here you can see Nan value for bedroom so we have to fill something there . so we find the median of bedroom column and replace the Nan value with median. for fill the Nan value we use fillna method of pandas library Now we build the Linear Regression model using sklearn librabry Here we pass the independent variable area,bedroom and age by using df.drop('price') which means all column except price and then we pass dependent variable in fit method which is price column.Fit method train our linear Regression model. Lets predict the price of house. Here we predict the price of house which has a 3000 sqft area , 3 bedroom and 40  year old. You can verify your answer by simple maths equation  y = m1(coef_)+m2(coef_)+m3(coef_)+intercept   where y is dependent variable...

Linear Regression

Image
  Linear Regression Using SKlearn We will predict the hosing price here by creating Machine Learning's Linear Regression Model. let's start : First we import the necessary library  Now we import the data from csv file. You can import csv file in python using pandas library's read_csv  method. lets visualise the data using matplotlib library we have to supply X & Y variable  means independent and dependent variable in leaner model so here independent variable is area and we will here predict price of home using area so price is depend on area size so price is dependent variable. you can drop column in pandas using drop   method . here x = new_df & y = df.price Now we build a leaner regression model  here we have to pass our x & y in fit method which will train our model. Lets predict the price of house which have 5000 sqft area. Predict method always accept 2D Array thats why we use double bracket here. price of 5000 sqft area house is 85955...

Recognizing Handwritten Digits with scikit-learn

Image
Recognizing Handwritten Digits With scikit-learn First we import necessary  library  and load data   We can see this digits using matshow  Now we split over data set using sklearn library Now we train our model and fit In machine learning, the  radial basis function kernel , or  RBF kernel , is a popular  kernel  function used in various kernelized learning algorithms. In particular, it is commonly used in support vector machine classification. Now we predict the digit We Check the score of our model which means how much model is accurate