We can write a simple Python scripts to check the current version of sklearn:
import sklearn
print('The scikit-learn version is {}.'.format(sklearn.__version__))
Ding's Programming Blog
Monday, December 14, 2015
Monday, November 2, 2015
Wednesday, October 21, 2015
Use pip to install packages for specific Python version
cd /Library/Python/2.*/site-packages/
sudo pip install -t . package_name
sudo pip install -t . package_name
Install NumPy and SciPy on Mac OS X El Capitan
Apple ships its own version of Python with OS X. However, it is recommended to install the official Python distribution.
My Macbook Pro has already got Apple Developer Tools installed, but I still need to install gfortran and Cython compiler.
To install gfortran, I tried using Homebrew (brew install gcc) but with error results because of version problem. So I installed it according to instructions here.
Thereafter I cloned NumPy and SciPy from their corresponding GitHub repo and installed following:
python setup.py build
python setup.py install
After these steps, I can import numpy and scipy module but can not run test cases. The error reported is
"ImportError: Need nose >= 0.10.0 for tests - see http://somethingaboutorange.com/mrl/projects/nose"
I tried install nose via pip, but fails (still can not import nose module afterwards, probably because I have 2 versions of Python installed). Later I tried install using easy_install, it finally succeeded.
Wednesday, October 14, 2015
Upgrade to PHP 5.6 on Ubuntu 12.04
Three lines of command solves the problem:
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install php5
sudo add-apt-repository ppa:ondrej/php5-5.6
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get install php5
Tuesday, October 6, 2015
Setting up a local web server on OS X
The guide I followed to set up my personal web server on Yosemite. Full credit to author etresoft. The original article can be found at here.
Here is my definitive guide to getting a local web server running on OS X. This is meant to be a development platform so that you can build and test your sites locally, then deploy to an internet server. This User Tip contains instructions for configuring the Apache and PHP. I have another User Tip for installing and configuring MySQL and Perl.
Note: Yosemite introduces some significant changes. Pay attention to your OS version.
Another note: These instructions apply to the client versions of OS X, not Server. Server does a few specific tricks really well and is a good choice for those. For things like database, web, and mail services, I have found it easier to just setup the client OS version manually.
Requirements:
- Basic understanding of Terminal.app and how to run command-line programs.
- Basic understanding of web servers.
- Basic usage of vi. You can substitute nano if you want.
Optional:
- Xcode is required for adding PHP modules.
Lines in bold are what you will have to type in at the Terminal.
Replace <your local host> with the name of your machine. Ideally, it should be a one-word name with no spaces or punctuation. It just makes life easier.
Replace <your short user name> with your short user name.
Here goes... Enjoy!
Lion and later versions no longer create personal web sites by default. If you already had a Sites folder in Snow Leopard, it should still be there. To create one manually, enter the following:
mkdir ~/Sites
echo "<html><body><h1>My site works</h1></body></html>" > ~/Sites/index.html.en
PHP is not enabled in recent versions of OS X. To enable it, do:
sudo vi /etc/apache2/httpd.conf
Uncomment the following line:
#LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module libexec/apache2/libphp5.so
(if you aren't familiar with vi, just press 'x' over the '#' character to delete it. Then type ':w!' to save and then 'ZZ' to quit.)
10.7 Lion - line 111
10.8 Mountain Lion - line 117
10.9 Mavericks - line 118
10.10 Yosemite - line 169
For Yosemite only, uncomment the following line at line 166:
#LoadModule userdir_module libexec/apache2/mod_userdir.so
to
LoadModule userdir_module libexec/apache2/mod_userdir.so
and do the same at line 493:
#Include /private/etc/apache2/extra/httpd-userdir.conf
to
Include /private/etc/apache2/extra/httpd-userdir.conf
Save and exit.
And again, for Yosemite only, open the file above with:
sudo vi /etc/apache2/extra/httpd-userdir.conf
and uncomment the following line at line 16:
#Include /private/etc/apache2/users/*.conf
to
Include /private/etc/apache2/users/*.conf
Save and exit.
While you are in /etc/apache2, double-check to make sure you have a user config file. It should exist at the path:/etc/apache2/users/<your short user name>.conf. That file may not be created in Lion and if you upgrade to Mountain Lion, you still won't have it. It does appear to be created when you create a new user in Mountain Lion. If that file doesn't exist, you will need to create it with:
sudo vi /etc/apache2/users/<your short user name>.conf
For all systems other than Yosemite, use the following as the content:
<Directory "/Users/<your short user name>/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from localhost
</Directory>
For Yosemite, use this content:
<Directory "/Users/<your short user name>/Sites/">
AddLanguage en .en
LanguagePriority en fr de
ForceLanguagePriority Fallback
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from localhost
Require all granted
</Directory>
In vi, press <esc> and then ZZ to save and quit.
If you want to run Perl scripts, you will have to do something similar:
Note: This section cannot be done on Yosemite. Yosemite does not include /usr/libexec/apache2/mod_perl.so. It should be possible to build your own mod_perl, but that would be outside the scope of this User Tip.
Uncomment the following line: (In Lion this is on line 110. In Mountain Lion it is on line 116. In Mavericks it is on 117.)
#LoadModule perl_module libexec/apache2/mod_perl.so
to
LoadModule perl_module libexec/apache2/mod_perl.so
Then, in /etc/apache2/users/<your short user name>.conf change the line that says:
Options Indexes MultiViews
to:
AddHandler perl-script .pl
PerlHandler ModPerl::Registry
Options Indexes MultiViews FollowSymLinks ExecCGI
Now you are ready to turn on Apache itself.
In Lion, do the following:
To turn on Apache, go to System Preferences > Sharing and enable Web Sharing.
NOTE: There appears to be a bug in Lion for which I haven't found a workaround. If web sharing doesn't start, just keep trying.
In more recent versions of OS X, the Web Sharing checkbox in System Preferences > Sharing is gone. Instead, do the following:
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
In Safari, navigate to your web site with the following address:
http://<your local host>/
It should say:
It works!
Now try your user home directory:
http://<your local host>/~<your short user name>
It should say:
My site works
Now try PHP. Create a PHP info file with:
echo "<?php echo phpinfo(); ?>" > ~/Sites/info.php
And test it by entering the following into Safari's address bar:
http://<your local host>/~<your short user name>/info.php
You should see your PHP configuration information.
If you want to setup MySQL, see my User Tip on Installing MySQL.
If you want to add modules to PHP, I suggest the following site. I can't explain it any better.
If you want to make further changes to your Apache system or user config files, you will need to restart the Apache server with:
sudo apachectl graceful
Monday, October 5, 2015
Argus Examples (ra, racount, racluster, rabins, rasort)
Argus is a data network transaction auditing tool originally developed at CERT in 1993.
This article made a brief summary for the usage of some Argus tools: ra, racount, racluster, rabins & resort, based on past experience. For more detailed documentation, please refer to http://qosient.com/argus/manuals.shtml
1. List traffic records under certain filtering condition
ra -r filename.arg - tcp //list all TCP records
2. Display records statistics
racount -r filename.arg - udp port domain //display record/packet/byte counts with DNS filtering
3. Process traffic data into structured ‘bins’ (usually time bins)
rabins -r filename.arg -M time 1h -m srcid -s load //align data into hourly bins, aggregates on srcid and display load (bps) for each hourly aggregation
4. Aggregate traffic data and sort (For example, find out what IP address is receiving the most traffic)
racluster -r filename.arg -m daddr -w - | rasort -r - -m sbytes -s daddr sbytes //use racluster tool to aggregate the records by destination address then pass the aggregated output to rasort tool to sort on the source to destination transaction bytes in descending order
Subscribe to:
Posts (Atom)