Posts

Showing posts from February, 2022

Machine Learning Introduction

Image
  What is Machine Learning In the real world, we are surrounded by humans who can learn everything from their experiences with their learning capability, and we have computers or machines which work on our instructions. But can a machine also learn from experiences or past data like a human does? So here comes the role of  Machine Learning . Machine Learning is said as a subset of  artificial intelligence  that is mainly concerned with the development of algorithms which allow a computer to learn from the data and past experiences on their own. The term machine learning was first introduced by  Arthur Samuel  in  1959 . We can define it in a summarized way as: With the help of sample historical data, which is known as  training data , machine learning algorithms build a  mathematical model  that helps in making predictions or decisions without being explicitly programmed. Machine learning brings computer science and statistics toge...

How to convert matrix to list in R Programming

  Convert matrix to list in R Conversion of a matrix into a list in Column-major order The  as.list()  is an inbuilt function that takes an R language object as an argument and converts the object into a list. We have used this function to convert our matrix to a list. These objects can be Vectors, Matrices, Factors, and data frames. By default, as.list() converts the matrix to a list of lists in column-major order.  Therefore, we have to use  unlist()  function   to convert the list of lists to a single list. unlist() function in R Language is used to convert a list of lists to a single list, by preserving all the components. Syntax:  unlist(as.list(matrix)) Example: mat = matrix(1:12,nrow=3, ncol=4)   print("Sample matrix:") print(mat)   print("Matrix into a single list") unlist(as.list(mat)) Conversion of a matrix into a list in Row-major order For this approach we first have to find the transpose o...

how to count and convert charecter strings in R Programming

  Convert Character String to Variable Name in R   Method 1: Using assign() function   We can assign character string to variable name by using  assign () function. We simply have to pass the name of the variable and the value to the function. Syntax:  assign(“variable_name”,value) Parameter: ·          variable_name  is the name of the value ·          value  is the variable. # assign variable name to 3 value assign("variable_name",3)   # print variable name We can also create a vector with a group of variables and assign a single variable name. Example:   print(variable_name) # create 5 variables at a time assign("vector1",c(1,2,3,4,5))   # print variable name print(vector1)   Method 2: Using do.call() function This function allows you to  call  any  R  function. It allows using a li...