Sunday, September 26, 2021

How to do linear regression quickly with R

Check https://pythonforscientist.blogspot.com/2021/ for reference


Data set in https://cutt.ly/BEQUlnA 

>>>lin_reg <- lm(file_car$dist~file_car$speed)

#code above creates linear regression lm(y~x)





>>>lin_reg

>>> plot(file_car$speed,file_car$dist)





The plot code produces next graph that follows linear regression




To plot the line and see how it fits the values we wrote the code

>>>abline(lin_reg)




How to quickly begin with R

 go to   https://cutt.ly/BEQUlnA for downloading the csv file.  



#comments after the hash #

#Download the csv to process the data and begin with your use of R

The commands are shown after the ">>>" you do not need to wirte the ">>>" just "getwd()"

another useful command is "dir()" this shows all folders and files on the current folder


#getwd() shows where the working directory of R is located

>>>getwd()






>>>file_car <- read.csv('cars.csv')

>>> head(file_car)

  X speed dist

1 1     4    2

2 2     4   10

3 3     7    4

4 4     7   22

5 5     8   16

6 6     9   10




>>>summary(file_car)



#head shows the first entry rows and its variables 

#tail shows the last rows showing the respective columns

#summary gives a general mean and median of all data


###conclusion and Notes

"Overall R is a powerful language tailored for statisticians and data scientist you can begin with this easy blog in following projects and tutorials I will explain more to use the full capacities and uses for your application. Welcome to the R world and enjoy your journey." 


Notes the R software here is an open source that is why is very widespread and attractive

R has a more visual interface GUI that will be shown in future tutorials




Thursday, March 11, 2021

How to make a simple multilinear regresion model with R.

 We will use the dataset from https://drive.google.com/file/d/0BxQfpNgXuWoIWkl4M3dMZDFtUkU/view


Step 1

we call the dataset lungcap.csv


Step2

>>> file<-read.delim("C:/Users/Owner/Downloads/lungcap.csv", header=TRUE, sep = ',')

>>> attach(file)    # this appends the header variables like Age, Gender, ....



Step3

The model is below

>>> model1 <- lm(LungCap ~ Age + Height)

>>> summary(model1)


Saturday, March 6, 2021

 How to train your model and test the accuracy




 How to install tensorflow easily in ubuntu


Step 1

go to tensorflow install 

Type 
>>>python3 --version
# this checks the version of python
>>>pip3 --version
if not installed pip then type
sudo python install pip






Step 2


sudo apt update
sudo apt install python3-dev python3-pip python3-venv

The commands above are for Linux and they update the system and install python libraries





Step 3
Enter command 
python3 -m venv --system-site-packages ./venv
       
        #The command above installs a virtual environment




Step 4

Enter command 

# this command activates the virtual environment

source ./venv/bin/activate  # sh, bash, or zsh




Step 5


pip install --upgrade pip

pip list  # show packages installed within the virtual environment




Step 6

pip install --upgrade pip

pip list

command above update the pip package



Step 6

pip install --upgrade tensorflow


command above install tensorflow library


                        


Step 7
Congrats you installed it


Troubleshoot 

pip not found
install pip     
sudo apt install pip