Ubuntu14.04 build Scikit-learn Environment and Pydev

Source: Internet
Author: User
Tags gtk

Install Ubuntu
    1. To download the image file:
      Http://www.ubuntu.org.cn/download/ubuntu-kylin
    2. Find a USB drive larger than 2G to make the boot disk, the recommended use of Chinese cabbage, there is an ISO mode, select the downloaded image file Click to make the Startup disk.
      http://www.dabaicai.net.cn/
    3. Plug in the USB stick, start the computer from the USB stick, and follow the prompts next.
Installing Scikit-learn

Change Python version

I installed the Ubuntu14.04, built-in with python2.7 and python3.4, open terminal, enter

$ python

Of course, you can also enter

$ python3

You can see that the Python version is currently running.

can use

$ alias python=python3

Change the default Python version to Python3.

Installing Scikit-learn

    1. Installation dependencies:
$ sudo apt-get install build-essential\python3-dev python3-numpy\python3-setuptools python3-scipy\libatlas-dev libatlas3-base  
    1. Install PIP
$ sudo apt-get install python3-pip

After you enter your password, the installation starts automatically and you can use the following command to verify the installation.

$ pip3 list

As you can see, the previously installed NumPy, scipy are displayed in them.
3. Installing Matplotlib
It's a very handy drawing package.

$ sudo apt-get install python3-matplotlib
    1. Installing Scikit-learn
-U scikit-learn

When I install, I get a permission denied (Permission denied) error. So I added it to the appeal order sudo .
Here, the Scikit-learn is all installed. As described above, you can use $ pip3 list to see if the installation was successful.
5. Verifying the installation
In the terminal, enter:

$ python

Note To see if the Python version is python3.x.x, if not, review the previous tutorials and change the Python version to Python3 because we are all packages installed under Python3.
After entering Python, copy the following code to the command line.

 fromSklearn Import Datasets fromSklearn.cross_validation Import Cross_val_predict fromSklearn Import Linear_modelimport Matplotlib.pyplot asPLTLR = Linear_model. Linearregression () Boston = Datasets.load_boston () y = boston.target# Cross_val_predict Returns anArray  ofThe same size as' Y 'where  eachentry# isA prediction obtained byCross validated:predicted = Cross_val_predict (LR, boston.data, y, cv=Ten) FIG, ax = plt.subplots () ax.scatter (y, predicted) ax.plot ([Y.min (), Y.max ()], [Y.min (), Y.max ()],' k--', lw=4) Ax.set_xlabel (' measured ') Ax.set_ylabel (' predicted ') Plt.show ()

This is excerpted from an example from Scikit-learn's official website, which is linked as follows: http://scikit-learn.org/stable/auto_examples/plot_cv_predict.html
After you copy to the command line, click Enter to see the post-run effect

Install JDK + Eclipse + PyDev

Configuring the Java Environment

    1. Download JDK
      Download the JDK on the link below to download the Linux x86 or x64 version.
      Http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
    2. Unzip the file
      For example, after downloading the file on the desktop, file name: jdk-8u45-linux-x64.tar.gz. Follow the steps below.
      First open the terminal.
$ cd ~/Desktop/$ tar -zxvf jdk-8u45-linux-x64.tar.gz$ sudo mv jdk1.8.0_45/usr/lib/java/
    1. Configuring Environment variables
$ vim ~/.bashrc

You need to edit ~/.bashrc the file, using VI, Gedit or VIM. Copy the following to the end of the file.

export JAVA_HOME=/usr/lib/java/jdk1.8.0_45export JRE_HOME=${JAVA_HOME}/jreexport CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/libexport PATH=${JAVA_HOME}/bin:$PATH

After saving, return to terminal, source a bit:

source ~/.bashrc

The following may or may not be performed.
To configure the default JDK version:
Because Ubuntu has a default JDK version built in, we can replace the original OPENJDK after we configure the JDK.

$ sudo  update-alternatives- -install/usr/bin/java Java/usr/lib/java/jdk1. 8.0  _45/bin/java 300  $ sudo  update-alternatives--install/usr/bin/javac Javac/usr/lib/java/jdk1.8.0  _45/bin/javac 300  $  sudo  update-alternatives--install/usr/bin/javah javah/usr/lib/java/jdk1. 8.0  _45/bin/javah 300  $ sudo  update-alternatives--install/usr/bin/jar Jar/usr/lib/java/jdk1.8.0  _45/bin/jar 300  $ sudo  update-alternatives--config java$ sudo  update-alternatives--config Javac 
    1. Verifying the installation
$ java -version

The current JDK run version information is printed:

Install Eclipse

    1. Download eclipse
      To download the latest version of Eclipse, the following link is an eclipse with C + + environment, also known as CDT, which can be developed directly after decompression. Pay attention to the selection of the system, should be corresponding to choose Linux 32-bit or 64-bit. The links are as follows:
      Http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/mars2
    2. Extract to Directory
      Also by default will download the good file on the desktop, file name: eclipse-cpp-mars-r-linux-gtk-x86_64.tar.gz. To do this, execute the following command:
-zxvf eclipse-cpp-mars-R-linux-gtk-x86_64.tar../eclipse

No surprises, this time you can open eclipse normally, you can pin eclipse to the left status bar.
Configure Pydev

    1. Installing Pydev

After opening eclipse, choose: Help, Eclipse Marketplace, enter Pydev in Find and click the Go button on the right. And of course I have installed it, so hint installed.

Not installed should be in the bottom right corner prompt install, click Install will automatically download the installation, follow the prompts have been selected to determine, the next step.

    1. Configure Python
      After the installation is complete, you will be prompted to restart and re-enter eclipse after rebooting. Click: Python interpreter, interpreters, PyDev, Preferences, Window. As shown in the following:

      In the upper right corner, click New-Browser, select python3.4 in the following path. /usr/bin/python3.4

Click OK to enter the Eclipse main screen to click:
PyDev Project, File-New.

Click Finish to return to the main screen and see two project folders on the left.
In the test project click the right mouse button, new---PyDev Module, Pop-up dialog box, fill in the contents:

Both the package name and the file name can be defined by themselves. After clicking Finish, in the new py file, copy and test the contents of the code in the command line.

Click Run, and as described above on the command line to run the results, you will get a graph display.

Ubuntu14.04 build Scikit-learn Environment and Pydev

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.