Cara menggunakan deep-translator python

Python itself must be installed first and then there are many packages to install, and it can be confusing for beginners.

In this tutorial, you will discover how to set up a Python machine learning development environment using Anaconda.

After completing this tutorial, you will have a working Python environment to begin learning, practicing, and developing machine learning and deep learning software.

These instructions are suitable for Windows, Mac OS X, and Linux platforms. I will demonstrate them on OS X, so you may see some mac dialogs and file extensions.

Kick-start your project with my new book Machine Learning Mastery With Python, including step-by-step tutorials and the Python source code files for all examples.

Let’s get started.

  • Update Mar/2017: Added note that you only need one of Theano or TensorFlow to use Keras for Deep Learning.

How to Setup a Python Environment for Machine Learning and Deep Learning with Anaconda

Overview

In this tutorial, we will cover the following steps:

  1. Download Anaconda
  2. Install Anaconda
  3. Start and Update Anaconda
  4. Update scikit-learn Library
  5. Install Deep Learning Libraries

1. Download Anaconda

In this step, we will download the Anaconda Python package for your platform.

Anaconda is a free and easy-to-use environment for scientific Python.

  • 1. Visit the Anaconda homepage.
  • 2. Click “Anaconda” from the menu and click “Download” to go to the download page.

Click Anaconda and Download

  • 3. Choose the download suitable for your platform [Windows, OSX, or Linux]:
    • Choose Python 3.5
    • Choose the Graphical Installer

Choose Anaconda Download for Your Platform

This will download the Anaconda Python package to your workstation.

I’m on OS X, so I chose the OS X version. The file is about 426 MB.

You should have a file with a name like:

1

Anaconda3-4.2.0-MacOSX-x86_64.pkg

2. Install Anaconda

In this step, we will install the Anaconda Python software on your system.

This step assumes you have sufficient administrative privileges to install software on your system.

  • 1. Double click the downloaded file.
  • 2. Follow the installation wizard.

Anaconda Python Installation Wizard

Installation is quick and painless.

There should be no tricky questions or sticking points.

Anaconda Python Installation Wizard Writing Files

The installation should take less than 10 minutes and take up a little more than 1 GB of space on your hard drive.

3. Start and Update Anaconda

In this step, we will confirm that your Anaconda Python environment is up to date.

Anaconda comes with a suite of graphical tools called Anaconda Navigator. You can start Anaconda Navigator by opening it from your application launcher.

Anaconda Navigator GUI

You can learn all about the Anaconda Navigator here.

You can use the Anaconda Navigator and graphical development environments later; for now, I recommend starting with the Anaconda command line environment called conda.

Conda is fast, simple, it’s hard for error messages to hide, and you can quickly confirm your environment is installed and working correctly.

  • 1. Open a terminal [command line window].
  • 2. Confirm conda is installed correctly, by typing:

1

conda -V

You should see the following [or something similar]:

1

conda 4.2.9

  • 3. Confirm Python is installed correctly by typing:

1

python -V

You should see the following [or something similar]:

1

Python 3.5.2 :: Anaconda 4.2.0 [x86_64]

Confirm Conda and Python are Installed

If the commands do not work or have an error, please check the documentation for help for your platform.

See some of the resources in the “Further Reading” section.

  • 4. Confirm your conda environment is up-to-date, type:

1

2

conda update conda

conda update anaconda

You may need to install some packages and confirm the updates.

  • 5. Confirm your SciPy environment.

The script below will print the version number of the key SciPy libraries you require for machine learning development, specifically: SciPy, NumPy, Matplotlib, Pandas, Statsmodels, and Scikit-learn.

You can type “python” and type the commands in directly. Alternatively, I recommend opening a text editor and copy-pasting the script into your editor.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

# scipy

import scipy

print['scipy: %s' % scipy.__version__]

# numpy

import numpy

print['numpy: %s' % numpy.__version__]

# matplotlib

import matplotlib

print['matplotlib: %s' % matplotlib.__version__]

# pandas

import pandas

print['pandas: %s' % pandas.__version__]

# statsmodels

import statsmodels

print['statsmodels: %s' % statsmodels.__version__]

# scikit-learn

import sklearn

print['sklearn: %s' % sklearn.__version__]

Save the script as a file with the name: versions.py.

On the command line, change your directory to where you saved the script and type:

1

python versions.py

You should see output like the following:

1

2

3

4

5

6

scipy: 0.18.1

numpy: 1.11.1

matplotlib: 1.5.3

pandas: 0.18.1

statsmodels: 0.6.1

sklearn: 0.17.1

What versions did you get?
Paste the output in the comments below.

Confirm Anaconda SciPy environment

4. Update scikit-learn Library

In this step, we will update the main library used for machine learning in Python called scikit-learn.

  • 1. Update scikit-learn to the latest version.

At the time of writing, the version of scikit-learn shipped with Anaconda is out of date [0.17.1 instead of 0.18.1]. You can update a specific library using the conda command; below is an example of updating scikit-learn to the latest version.

At the terminal, type:

1

conda update scikit-learn

Update scikit-learn in Anaconda

Alternatively, you can update a library to a specific version by typing:

1

conda install -c anaconda scikit-learn=0.18.1

Confirm the installation was successful and scikit-learn was updated by re-running the versions.py script by typing:

1

python versions.py

You should see output like the following:

1

2

3

4

5

6

scipy: 0.18.1

numpy: 1.11.3

matplotlib: 1.5.3

pandas: 0.18.1

statsmodels: 0.6.1

sklearn: 0.18.1

What versions did you get?
Paste the output in the comments below.

You can use these commands to update machine learning and SciPy libraries as needed.

Try a scikit-learn tutorial, such as:

  • Your First Machine Learning Project in Python Step-By-Step

5. Install Deep Learning Libraries

In this step, we will install Python libraries used for deep learning, specifically: Theano, TensorFlow, and Keras.

NOTE: I recommend using Keras for deep learning and Keras only requires one of Theano or TensorFlow to be installed. You do not need both! There may be problems installing TensorFlow on some Windows machines.

  • 1. Install the Theano deep learning library by typing:

1

conda install theano

  • 2. Install the TensorFlow deep learning library [all except Windows] by typing:

1

conda install -c conda-forge tensorflow

Alternatively, you may choose to install using pip and a specific version of tensorflow for your platform.

See the .

  • 3. Install Keras by typing:

1

pip install keras

  • 4. Confirm your deep learning environment is installed and working correctly.

Create a script that prints the version numbers of each library, as we did before for the SciPy environment.

1

2

3

4

5

6

7

8

9

# theano

import theano

print['theano: %s' % theano.__version__]

# tensorflow

import tensorflow

print['tensorflow: %s' % tensorflow.__version__]

# keras

import keras

print['keras: %s' % keras.__version__]

Save the script to a file deep_versions.py. Run the script by typing:

1

python deep_versions.py

You should see output like:

1

2

3

4

theano: 0.8.2.dev-901275534cbfe3fbbe290ce85d1abf8bb9a5b203

tensorflow: 0.12.1

Using TensorFlow backend.

keras: 1.2.1

Anaconda Confirm Deep Learning Libraries

What versions did you get?
Paste your output in the comments below.

Try a Keras deep learning tutorial, such as:

  • Develop Your First Neural Network in Python With Keras Step-By-Step

Further Reading

This section provides some links for further reading.

  • Anaconda Documentation
  • Anaconda Documentation: Installation
  • Conda
  • Using conda
  • Anaconda Navigator
  • Installing Theano

Summary

Congratulations, you now have a working Python development environment for machine learning and deep learning.

Bài mới nhất

Chủ Đề