Home  >  Article  >  Backend Development  >  Is it necessary to learn both r language and python?

Is it necessary to learn both r language and python?

anonymity
anonymityOriginal
2019-06-12 14:33:447065browse

R and Python are currently the two most popular high-level programming languages ​​and are widely used in the field of data science. Both are open source and have very active communities to support them. So here comes the question: Is it necessary to learn both R language and python?

Is it necessary to learn both r language and python?

Designed in 1995 by Ross Ihaka and Robert Gentleman (named the R language because both of their names begin with the letter 'R'), it is now developed by the "R Core Development Team".

Although R is mainly used for data analysis, graphics and data mining, some people also use it for matrix calculations. Its calculation speed is comparable to the open source software GNU Octave and commercial software MATLAB dedicated to matrix calculations.

At first, R was mainly used in academic research, but in recent years it has also gained prominence in the corporate world, making R one of the world's fastest-growing statistical languages ​​used in companies. For data science tasks, R's syntax is more intuitive and intuitive

For data processing tasks, R's syntax is often simpler. The naming of functions and parameters is also better designed, making them easy to remember and use.

For example, we will use R and Python to delete two variables in the Iris data frame (since R and Python both have Iris data frames, we use this data frame).

Let’s take a look at their respective syntax:

Python

import seaborn as sns
import pandas as pd
iris = sns.load_dataset('iris')
iris.drop(['sepal_length', 'species'], axis = 1)

R

library(dplyr)
select(iris, -sepal_length, -species)

In order to delete variables, the drop function is used in Python, and in R The select function is used. Let's compare the syntax of these two functions (both in the last line of code).

Let’s talk about Python first. The drop function is well named and easy to remember. But the parameter design is very complicated.

The first parameter is a list containing the variables you want to delete. In Python, square brackets [ ] are used to represent the list. You must use square brackets here, and the variable must be quoted ' ', otherwise the code will run incorrectly.

In terms of data visualization, R is very good

Visualization is an important criterion for selecting data analysis software.

In addition to being good at data analysis, another shining point of R is its extremely strong drawing ability, which can draw almost all types of graphs. If you don't believe it, you can Google it and enter the 'R visualization' keyword.

Advantages of Python

For data science beginners, although I strongly recommend learning R, it is not the only option.

For some people, Python may be the best choice. Let’s talk about the situations in which it is better to choose Python.

If you have a foundation in software development or computer science, learn Python

If you have experience in software development or are a computer science major, I think Python will be more suitable for you. Since you already have programming experience, you will be more comfortable using Python.

If you want to develop software, learn Python

I have already said that R is better at data science. If you want to build software systems, I think Python is more suitable. The shining point of Python is writing software, which is very efficient. As some experts say, writing Python code is like writing pseudocode.

In addition, Python is a general-purpose language and can basically do anything. However, R is more specialized and is only good at statistical analysis and visualization.

I want to clarify, it is not that R cannot write software. It’s just that more people like to use Python to build product software. Therefore, as a data scientist, if you want to create a software system, I think Python is more suitable than R.

If you want to engage in machine learning, learn Python

If you want to engage in machine learning research for a long time, I suggest you learn Python.

In fact, R also has a machine learning ecosystem. In particular, R's caret package is well developed and has the ability to accomplish a variety of machine learning tasks. For example: use the caret package to build regression models, support vector machines (SVM), decision trees (including regression and classification), and perform cross validation, etc. All in all, R’s machine learning ecosystem is growing very well.

However, Python’s support for machine learning appeared earlier. To implement various machine learning methods, Python's scikit-learn library provides a more concise and readable syntax. The syntax of the caret package in R is sometimes a bit clumsy. In particular, the caret package is not very compatible with the Tidyverse package, and the output results are sometimes difficult to process. In contrast, Python's scikit-learn library integrates well with the Python ecosystem.

Many of the algorithm implementations of books on machine learning on the market are written in Python.

In conclusion, if you want to work on machine learning, I think Python will be better.

If you want to engage in deep learning, learn Python

Deep learning is one of the most popular technologies in the field of artificial intelligence, and Python is the most popular language for deep learning. .

Most deep learning frameworks have Python interfaces, such as: TensorFlow, Keras, Pytorch, Theano, MXNET, etc.

Python is very compatible with various frameworks and has a large number of contributors, search results, related books and academic articles; most of the deep learning projects on Github are written in Python. If you are new to deep learning, using Keras is a good choice.

In comparison, R does not perform well in terms of compatibility with deep learning frameworks. So if you want to focus on deep learning, Python may be more suitable.

Learn R or Python? It mainly depends on your background and your goals.

If you don’t have any programming experience, it is recommended that you learn R first; if you want to learn data visualization, I think R’s ggplot2 package is the best tool; if you want to specialize in data analysis and data mining, R Perform better.

If you want to become a machine learning expert, Python's scikit-learn library can be studied carefully; if you want to develop software systems, Python is more suitable.

As the saying goes, if you have too many skills, you won’t be overwhelmed. You have a third option: learn both R and Python. In fact, many top data scientists know both languages. But for newbies, learn one lesson at a time. Learning two subjects at the same time will make you confused, the learning cycle will be lengthened, and you will get twice the result with half the effort.

The above is the detailed content of Is it necessary to learn both r language and python?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:When did python come out?Next article:When did python come out?