guide to Anaconda Python

Python and R programmers can use Anaconda’s data science and machine learning platform. It is accessible on Linux, Windows, and OS X and is made to make the process of building and delivering projects simple, stable, and reproducible across systems. The famous data science packages pandas, scikit-learn, scipy, numpy, and Google’s TensorFlow are all curated by the Python-based platform anaconda.

Conda, an install tool similar to pip, Anaconda Navigator, a GUI interface, and Spyder, an IDE, is included in the bundle. You will learn the fundamentals of Anaconda, conda, and Spyder for the Python programming language in this lesson and the ideas you need to start working on your projects.

It becomes comparatively advantageous for any programmer to work on Anaconda for data science, given the availability of more than 300 libraries for data science. Anaconda aids in streamlining deployment and package management. The extensive range of tools included with Anaconda makes it simple to gather data from numerous sources using machine learning and AI methods. Further, it assists in setting up an environment that is simple to administer and allows for the quick deployment of any project.

Why the Anaconda?

For beginners learning Python, Anaconda is the ideal option for several reasons:

A total solution — Unlike other Python IDEs (Pycharm, Pydev, Spyder), Anaconda provides an intuitive programming environment and streamlines processes like managing packages and virtual environments.

Pre-installed Packages — Over the years, the community has created thousands of packages that give Python its power. Pip (Python’s de-facto standard Package Management System) is required to install all third-party Python packages when using a standard Python installation. Anaconda eliminates this hassle because it already has loaded the most popular Python packages.

Simple GUIs — Jupyter Notebook, the subject of this lesson, and Spyder, the two most approachable Python IDEs, are pre-installed on the Anaconda package.

After learning what Anaconda is, let’s try to comprehend how to install it and create a workspace for our systems.

Anaconda Python Installation

Before beginning any installation tasks in Ubuntu, packages are updated. The various functional capabilities of Anaconda stand out, including managing system packages, computing and processing massive amounts of data, impacting predictive analytics, and Python programming. Anaconda is a platform specifically designed to achieve machine learning, to put it broadly. While navigator is built on a graphical user interface, Anaconda acts as a command-line program (GUI). The Mac, Windows, and Linux operating systems are also compatible with Anaconda. The navigator is one of Anaconda’s two most well-known depository tools. Any open-source server you wish to install on Linux should always have the most recent version installed. You may learn how to install Anaconda on your Ubuntu 20.04 system from this post.

Requirements

The user must sign in either as a root or another account to install Anaconda on Ubuntu 20.04. The prerequisites for installation are the current version of Anaconda information and access to the terminal or command line. The following link will take you to a web source where you may learn more about the most recent Anaconda version.

Process of Installation

Five primary procedural phases make up the complete installation of an anaconda.

Step 1: update the APT package.

Step 2: Downloading the Most Recent Anaconda Version

Step 3: Verification of Data Integrity in Step Three

Step 4: Package Installation

Step 5: Anaconda Packages Installation Verification

updating the APT package

On Linux, updating the system packages is the first and most important step in installing any program. Use the following command to update your current system packages:

$ sudo apt update && upgrade

If curl is not already installed on your Ubuntu machine, download it now. The commands for installing Anaconda are implemented with the aid of Curl. To install curl on your PC, run this command.

$ sudo apt install curl

Download Anaconda’s most recent version

After switching to the temporary repository, you can use the curl tool in the system command line to download the Anaconda installation.

$ cd /tmp
$ curl https://repo.anaconda.com/archive/Anaconda3-2020.02-Linux-x86_64.sh
 --output anaconda.sh

Remember that Python 3.7 is the only version of 2020.02 that is compatible with the command above. Use the link provided above to locate the Anaconda version that is compatible with your Python 2.7 version if you are using the 2.7 version of Python.

Verification of Data Integrity

You can use the following command to check the data integrity of the Anaconda version you downloaded.

$ sha256sum Anaconda3–2020.02–Linux–x86_64.sh

Then, contrast the code on your output screen with the page’s hash code using the Anaconda version. Both codes must match for the tool to work correctly; otherwise, you are not using the Anaconda version that is compatible with your Python version.

Package Installation

It would be best if you executed the bash script to continue with the installation process.

$ bash anaconda.sh

Note the version number if you are using a different version of Anaconda. A license agreement will appear on your output screen once the program has been implemented correctly. To continue the procedure and grant authorization, hit enter and input “yes.” The default location is retained. Your output screen will display a description of the completed installation as soon as you enter the window. By pressing the Enter key after accepting each agreement, you may now activate your installer.

Anaconda Packages Installation Verification

Use the conda command to display the verification information and check that your package is successfully installed.

$ conda info

You can get all the details about your installed Anaconda package on the output screen.

Hopefully, this step-by-step guide made installing Anaconda on Ubuntu 20.04 easier for you. Don’t forget to choose the Anaconda compatible version with your Python version. Additionally, keep the version in mind whenever you issue a command on your terminal system. It will guarantee that Anaconda runs appropriately in Ubuntu 20.04.

Conda fundamentals

The central component of Anaconda is the Conda package management and environment utility. Except for being made to operate with Python, C, and R package management, it is similar to pip. Identical to how virtualenv handles virtual environments, Conda does the same.

Verify the installation

Verify your system’s installation and version as the initial step. The commands below will verify Anaconda’s installation and output its version to the terminal.

$ conda –version

Results should resemble those shown below. Version 4.4.7 is the one we’re using right now.

Newest Version

Using the update parameter provided by conda, as seen below, conda can be updated.

$ conda update conda

Conda will be updated to the most recent release with this command. We can see that our version is upgraded to 4.4.8, the most recent release of the utility, by running the version parameter once more.

New Environment Creation

Run the sequence of commands shown below to build a new virtual environment.

$ conda create -n tutsConda python=3

$ Proceed ([y]/n)? y

The packages that have been installed in your new environment are listed below.

Activation

You must activate your newly generated environment, just like with virtualenv. On Linux, the command shown below will activate your environment.

$ source activate tutsConda

Installation of Packages

The packages currently installed on your project are listed using the conda list command. Using the install command, you can include other packages and their dependencies.

$ conda list

You should run the shell command below to install pandas in the current environment.

$ conda install pandas

It will download and set up the necessary dependencies and packages.

We can observe the new packages installed in our virtual environment by running the list command once more.

You can use the standard pip commands to install packages not included in the Anaconda repository. Since most Python users are already familiar with the commands, we won’t review them here.

Installation of Anaconda on Windows

Open the installer — Setting up Anaconda on Windows is as easy as setting up any other program. Start the installer, then click Next, and following. The installer will ask for your preferences in a few locations. We advise sticking with the installer’s suggested settings and making no changes. Within 8 to 10 minutes, the installation is finished.

Launching the Anaconda Prompt—Python and other related software are installed by default on the Anaconda distribution. These programs are located in the Anaconda folder, accessible from the Windows start menu. Open the Anaconda Prompt Python application to start it.

Introducing Python Enter “python” into the Prompt field. Standard text and the Python version number will appear on the screen. In addition, the Prompt will now have three angular brackets (“>>>”) instead of two. You can now begin creating your Python code. Type exit() and hit enter to leave the Python environment.

Anaconda’s Navigator

Anaconda’s navigation program with a GUI is included to simplify life for developers. It comes with preloaded projects for the Spyder IDE and Jupyter notebook. As a result, you may rapidly launch a project from your GUI desktop environment.

Anaconda’s Navigator
Anaconda’s Navigator

We must choose our environment from the toolbar on the left before we can start working in the newly formed environment from the navigator.

choosing our working environment

choosing our working environment

The tools that we want to use must then be installed. It is specifically spyder IDE for me. That is where we perform most of my data science work, and in my opinion, this Python IDE is effective and productive. You only need to click the install button on the spyder dock tile. The rest is up to Navigator.

The IDE is launched from the same dock tile after installation. With this, Spyder will start running in your desktop environment.

The default IDE for Anaconda is Spyder, which is adequate for every day and data science tasks in Python. The spyder IDE has a code editor window, a console window, and an integrated IPython notebook.

Spyder also has standard debugging tools and a variable explorer when anything doesn’t go according to plan.

For example, we’ve included a tiny SKLearn application that utilizes random forrest regression to forecast stock prices. We’ve also provided some of the IPython Notebook output to show how handy the tool is.

If you want to keep learning about data science, we’ve listed some exciting tutorials below. Most of these were written using Anaconda and Spyder, and they ought to function correctly in the surroundings.

Improved user interface

In the previous phase, we examined the Anaconda prompt, which served as Python’s command-line interface. A GUI-based IDE called Jupyter Notebook is included with Anaconda. We may also run it from a folder on the Windows start menu. Since the application launches in a web browser, users with access to more than one browser might anticipate a prompt asking for their preferred browser option.

Making a new Notebook: Jupyter notebooks are a one-stop-shop for writing markdown documents, visualizations, and Python code. Click on Python 3 from the new drop-down menu in the top right corner of the home screen to start a new Notebook.

Using the Jupyter notebook’s shortcuts, each cell can be in edit mode (with a blinking cursor and the Cell highlighted in green) or select mode (without a cursor and the Cell highlighted in blue). Each provides a few shortcuts to make navigating the notebook quick and straightforward.

Data Types and Variables

Any programming language’s foundation is made up of variables and data types. There are six different data types in Python, each with other properties. The collection data types in the Python programming language are list, dictionary, set, and tuple.

The example that follows demonstrates how variables and data types are used in Python.

# the declaration of  variables
var_name = "Codeunderscored"
year_started = 2020
print("python was founded in"  , year_started)
#data types
var_a = [1,2,3,4,5,6,7]
var_b = {1 : 'edureka' , 2: 'python'}
var_c = (1,2,3,4,5)
var_d = {1,2,3,4,5}

print("In Python the list is" , var_a)
print("In Python the dictionary is" , var_b)
print("In Python the tuple is" , var_c)
print("In Python the set is " , var_d)

Operators

In Python, operators are used to performing operations on values or variables. Python has seven different types of operators.

  • Arithmetic Operator
  • Assignment Operator
  • Logical Operator
  • Membership Operator
  • Identity Operator
  • Comparison Operator
  • Bit-wise Operator

The sample that follows makes use of a few Python operations.

var_a = 10
var_b = 15
#the operator for arithmetic
print(var_a + var_b)
print(var_a - var_b)
print(var_a * var_b)

#the operator for assignment
var_a += 10
print(var_a)

#operator for comparison
#var_a != 10
#var_b == var_a
#logical operator
var_a > var_b and var_a > 10

#if both claims are valid, this will return true.

Regulatory Statements

To obtain control over the execution and ensure the best outcomes, statements like if, else, break, and continue are utilized as control statements. These commands are used in different Python loops to control the result. The example that follows will demonstrate how to use control and conditional statements.

var_name = 'codeunderscored'
for item in var_name:
     if item == 'a':
         break
     else:
         print(item)

Functions

Python functions offer effective code reuse, allowing us to create the logic for a problem statement and run a few arguments to find the best answers. The example that follows shows how to use functions in Python.

def new_func(var_a):
      return var_a ** var_a
var_result = new_func(137)
print(var_result)

Objects and Classes

Python allows for object-oriented programming. Thus working with classes and objects is also an option. The example that follows shows how to use classes and objects in Python.

class code_parent:
      def par_func(self):
            print('parent class definition')
 
class code_child(code_parent):
      def ch_func(self):
           print('function in  child class definition')
 
ob = new code_child()
ob.par_func()

To start with, here are some basic ideas in Python. We can work with many libraries thanks to Anaconda’s broader package support. Let’s see how Python Anaconda is used for data analytics.

Analytics Case Study

These are some of the steps in data analysis. Let’s see how Anaconda handles data analysis and some of its libraries.

Gathering data

Gathering data is as easy as importing a CSV file into the software. Then, we can use the pertinent data to examine specific occurrences or items. The code to load the CSV data into the application is provided below.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
 
data_frame  = pd.read_csv('code_filename.csv')
print(data_frame.head(5))

Making Slices and Dice

After loading the data set into the software, we must make a few adjustments to the data, such as removing any null values and extra fields that can create confusion during analysis. The following example shows how to filter the data according to the needs.

print(data_frame.isnull().sum())
#This will display the dataset's total number of null values.
data_frame_one = data_frame.dropna(axis=0 , how= 'any')
#the null values in the rows will be removed.

data_frame.isnull().sum()

We can also remove the null values.

data_frame_one =data_frame.dropna()
data_frame_one.isnull().sum()

BoxPlot

sns.boxplot(x=data_frame['Range(Salary) From'])
sns.boxplot(x=data_frame['Range (Salary) To'])

ScatterPlot

import matplotlib.pyplot as plt
fig, ax = plt.subplots(figsize=(16,8))
ax.scatter(data_frame[''Range(Salary) From''] , data_frame['Range (Salary) To'])
ax.set_xlabel(''Range(Salary) From'')
ax.set_ylabel('Range (Salary) To')
plt.show()

Visualization

Analyzing the data is necessary once we have altered it to meet the requirements. Visualizing the outcomes is one approach to doing this. A more effective data prediction study is achieved with better visual representation. Here is an illustration of how to display the data.

sns.countplot(x= "Indicator for Full-Time/Part-Time" , data= data_frame)
sns.countplot(x="Indicator for Full-Time/Part-Time" , hue="The frequency of salary " , data= data_frame)
sns.countplot(hue="Indicator for Full-Time/Part-Time", x="The type of Posting" ,data=data_frame)
data_frame["Salary Range From"].plot.hist()
data_frame["Salary Range To"].plot.hist()


import matplotlib.pyplot as plt
fig = plt.figure(figsize = (10,10))
ax = fig.gca()
sns.heatmap(data_frame_one.corr(), annot=True, fmt=".2f")
plt.title("Correlation",fontsize=5)
plt.show()

Analysis

We can analyze visualization by examining the various plots and graphs. The number of jobs in a specific domain is determined by the visual representation of a particular position in a region where we deal with job data.

With the help of use cases covering the principles of Python, data analysis, and machine learning, we have learned how to set up Anaconda for Python. Anaconda’s 300 data science packages offer the best assistance and productive outcomes.

Conclusion

For Python data science and machine learning, Anaconda is a great environment. It includes a repository of carefully chosen packages that are made to operate together to create a strong, reliable, and reproducible data science platform. It enables developers to share their work and guarantee that it will function identically on all platforms and operating systems. It has built-in convenience features, including the Navigator, making it simple to build projects and change environments. It is where we turn to build financial analysis projects and develop algorithms.

Because we are accustomed to the environment, we even discovered that we use it for most of our Python projects. Anaconda is a good option if you’re seeking to start with Python and data science.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *