When I am training a xgboost and used AUC as metric to evaluate the performance, I notice first several rounds' AUC score is always 0.5. Basically it means the first several trees did not learn anything:
Multiple eval metrics have been passed: 'eval-auc' will be used for early stopping.
Will train until eval-auc hasn't improved in 20 rounds.
[0] train-auc:0.5 eval-auc:0.5
[1] train-auc:0.5 eval-auc:0.5
[2] train-auc:0.5 eval-auc:0.5
[3] train-auc:0.5 eval-auc:0.5
[4] train-auc:0.5 eval-auc:0.5
[5] train-auc:0.5 eval-auc:0.5
[6] train-auc:0.5 eval-auc:0.5
[7] train-auc:0.5 eval-auc:0.5
[8] train-auc:0.5 eval-auc:0.5
[9] train-auc:0.5 eval-auc:0.5
[10] train-auc:0.5 eval-auc:0.5
[11] train-auc:0.5 eval-auc:0.5
[12] train-auc:0.5 eval-auc:0.5
[13] train-auc:0.5 eval-auc:0.5
[14] train-auc:0.537714 eval-auc:0.51776
[15] train-auc:0.541722 eval-auc:0.521087
[16] train-auc:0.555587 eval-auc:0.527019
[17] train-auc:0.669665 eval-auc:0.632106
[18] train-auc:0.6996 eval-auc:0.651677
[19] train-auc:0.721472 eval-auc:0.680481
[20] train-auc:0.722052 eval-auc:0.684549
[21] train-auc:0.736386 eval-auc:0.690942
As you can see, the first 13 rounds did not learn anything.
The parameter I used:
param = {'max_depth':6, 'eta':0.3, 'silent':1, 'objective':'binary:logistic'}
using xgboost 0.8
Is there anyway to prevent this?
Thanks
AUC equal 0.5 during the first several rounds does not mean that XGBoost does not learn. Check if your dataset is balanced. If not, all instances (they of target=1 and target=0) try to go from default 0.5 to the target mean, e.g. 0.17 (logloss improves, learning is going on), and then reach the region where improving logloss improves AUC. IF you want to help the algorithm to reach this region, change the default value of the parameter base_score=0.5 to the target mean.
https://xgboost.readthedocs.io/en/latest/parameter.html
Related
I have the following simple code:
a = tf.constant([7, 6, 7, 4, 5, 4], dtype=tf.float32)
e = tf.constant(5.2, dtype = tf.float32)
with tf.Session() as sess:
print(sess.run(a - e))
the outcome of this subtraction is
[ 1.8000002 0.8000002 1.8000002 -1.1999998 -0.19999981 -1.1999998 ]
instead of
[ 1.8 0.8 1.8 -1.2 -0.2 -1.2 ]
that is very weird. What is possibly the problem?
In a simple way the resaon is that 5.2 does not have a terminating binary representation. So, if you know how 1/3 looks in decimal, then just imagine the same situation in 5.2. Always remember the following point :
A decimal number will have a terminating binary representation if and
only if, the decimal written in its simplest fraction form, has a
denominator which is a power of 2.
If you think of 5.2, then it is 52/10 or 26/5, and 5 is not a power of 2. Now in float32 (double precision arithmetic), one has only 32 bits to represent it. So, of course, it ends up representing a number which is quite close to 5.2 but not quite exactly the same as it.
So, TensorFlow on computing the subtraction, gives you a slight difference.
If you however convert the numbers to tf.float64 you will see the error getting disappeared, although the representation is still not exact. This is just a genuine effort of Print function making your life simpler. It is not showing you the full view. This is because in 64-bit arithmetic, the difference between true value and internally represented value is much smaller than 32-bit arithmetic. So, the Print function sees a continuous stream of zeros, which it truncates.
But if you use something like Print('%.60f'% <YOUR RESULT>) you will see something like
with tf.Session() as sess:
...: for i in range(10):
...: c = sess.run(a - e)
...:
2018-09-09 18:50:42.209402: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1471] Adding visible gpu devices: 0
2018-09-09 18:50:42.209464: I tensorflow/core/common_runtime/gpu/gpu_device.cc:952] Device interconnect StreamExecutor with strength 1 edge matrix:
2018-09-09 18:50:42.209475: I tensorflow/core/common_runtime/gpu/gpu_device.cc:958] 0
2018-09-09 18:50:42.209484: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: N
2018-09-09 18:50:42.209635: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1084] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 10397 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:02:00.0, compute capability: 6.1)
for item in c:
...: print('%.60f' % item)
...:
1.780000000000000248689957516035065054893493652343750000000000
0.780000000000000248689957516035065054893493652343750000000000
1.780000000000000248689957516035065054893493652343750000000000
-1.219999999999999751310042483964934945106506347656250000000000
-0.219999999999999751310042483964934945106506347656250000000000
-1.219999999999999751310042483964934945106506347656250000000000
I successfully added TensorFlow with
using Pkg
Pkg.add("TensorFlow")
But when I
using TensorFlow
I get Failed to precompile TensorFlow. In more detail, I get something like below.
[ Info: Precompiling TensorFlow
ERROR: LoadError: UndefVarError: warn not defined
Stacktrace:
[1] top-level scope at none:0
[2] include at ./boot.jl:317 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1038
[4] include(::Module, ::String) at ./sysimg.jl:29
[5] top-level scope at none:2
[6] eval at ./boot.jl:319 [inlined]
[7] eval(::Expr) at ./client.jl:389
[8] top-level scope at ./none:3
in expression starting at
/home/...
I appreciate your help.
It is a bit unfortunate, but most packages have not defined any upper bounds on Julia versions (in the past), and thus allow themselves to be installed on Julia 1.0, while they are not ready yet as was pointed out in the comments. If in doubt, I would always check the repository. A quick Google search points to https://github.com/malmaud/TensorFlow.jl.
The badges at the top of the README show that it only tested for Julia 0.5 & 0.6, indicating it might not be ready (or the author did not add the badge, but it is ready)
The last release is from May 30th, Julia 0.7 and 1.0 (1.0 = 0.7 minus the deprecation warnings) are just weeks old, so that will definitely not work unless the package is trivial (and this one is not).
There is plenty of activity to port it to 1.0, particularly in this pull request: https://github.com/malmaud/TensorFlow.jl/pull/419. If you would like to contribute, I would start from that work, it seems a lot has been sorted out, but not all of it
Say I have a graph with 10 million nodes and 100 million edges. I would like to compute the largest Eigen value on the adjacency matrix of this graph. Which Eigen value solvers should work for the graph this big. Note that the matrix is sparse.
You can use Arpack [1], it requires just a function that computes a matrix-vector product (thus it works well for sparse matrices).
Arpack has different operating modes, for computing either the high frequencies (small eigenvalues) or the low frequencies (large eigenvalues). Unfortunately, it works in general much faster for the high frequencies, but what you can do is pre-factoring your matrix using a sparse LU factorization algorithm, e.g., SuperLU [2], then compute the high frequencies of M^-1, by solving a linear system instead of computing the sparse matrix vector product, then the eigenvalue is just the inverse of the one computed by Arpack.
I tryed that with meshes with tenths of million nodes, and it works quite well. Details are in my article [3] and companion source-code [4]
References:
[1] http://www.caam.rice.edu/software/ARPACK/
[2] http://crd-legacy.lbl.gov/~xiaoye/SuperLU/
[3] http://alice.loria.fr/index.php/publications.html?redirect=0&Paper=ManifoldHarmonics#2007
[4] http://alice.loria.fr/WIKI/index.php/Graphite/ManifoldHarmonics
After running a script to populate my database i ran a rake ts:rebuild but sphinx is partially rebuilding the indexes.
Stopped searchd daemon (pid: 23309).
Generating configuration to /home/guest_dp/config/development.sphinx.conf
Sphinx 2.1.4-id64-release (rel21-r4421)
Copyright (c) 2001-2013, Andrew Aksyonoff
Copyright (c) 2008-2013, Sphinx Technologies Inc (http://sphinxsearch.com)
using config file '/home/guest_dp/config/development.sphinx.conf'...
indexing index 'episode_core'...
collected 4469 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4469 docs, 8938 bytes
total 0.071 sec, 124488 bytes/sec, 62244.07 docs/sec
indexing index 'episode_delta'...
collected 0 docs, 0.0 MB
total 0 docs, 0 bytes
total 0.013 sec, 0 bytes/sec, 0.00 docs/sec
indexing index 'organization_core'...
.
.
.
skipping non-plain index 'episode'...
skipping non-plain index 'organization'...
skipping non-plain index 'person'...
skipping non-plain index 'position'...
skipping non-plain index 'profession'...
skipping non-plain index 'segment'...
skipping non-plain index 'tv_show'...
total 12816 reads, 0.005 sec, 0.2 kb/call avg, 0.0 msec/call avg
total 116 writes, 0.020 sec, 52.3 kb/call avg, 0.1 msec/call avg
Started searchd successfully (pid: 23571).
What does it mean skipping non-plain index ?
Each of those are distributed indices, which contain the _core and _delta plain indices (e.g. episode contains both episode_core and episode_delta). There's nothing to do to index them directly, because distributed indices don't contain data, they just point to other indices.
In other words: what you're seeing is completely normal. All of your indices are being processed appropriately.
Sphinx used to have a slightly different message: Distributed index 'episode' can not be directly indexed; skipping - same deal.
I have a USB webcam (unknown make, no markings) thats been detected fine on my Raspberry Pi.
This is the output of lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0c45:608f Microdia PC Camera (SN9C103 + OV7630)
Bus 001 Device 005: ID 1267:0103 Logic3 / SpectraVideo plc G-720 Keyboard
However when i run motion, using /dev/video0 with the only default config changed the resolution and setting the webcam host off so that i can stream it on a network.
This is my log when i run motion
Log of motion -n
[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] ffmpeg LIBAVCODEC_BUILD 3482368 LIBAVFORMAT_BUILD 3478784
[0] Thread 1 is from /etc/motion/motion.conf
[0] motion-httpd/3.2.12 running, accepting connections
[0] motion-httpd: waiting for data on port TCP 8080
[1] Thread 1 started
[1] cap.driver: "sonixb"
[1] cap.card: "USB camera"
[1] cap.bus_info: "usb-bcm2708_usb-1.2"
[1] cap.capabilities=0x05000001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: S910 (S910)
[1] 1: BA81 (BA81)
[1] Selected palette BA81
[1] Test palette BA81 (480x640)
[1] Adjusting resolution from 480x640 to 160x120.
[1] Using palette BA81 (160x120) bytesperlines 160 sizeimage 19200 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255
[1] "Brightness", default 127, current 127
[1] found control 0x00980911, "Exposure", range 0,1023
[1] "Exposure", default 66, current 66
[1] found control 0x00980912, "Automatic Gain (and Exposure)", range 0,1
[1] "Automatic Gain (and Exposure)", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,255
[1] "Gain", default 127, current 127
[1] mmap information:
[1] frames=4
[1] 0 length=20480
[1] 1 length=20480
[1] 2 length=20480
[1] 3 length=20480
[1] Using V4L2
[1] Resizing pre_capture buffer to 1 items
[1] v4l2_next: VIDIOC_DQBUF: EIO (s->pframe 0): Input/output error
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] Error capturing first image
[1] Started stream webcam server in port 8081
[1] v4l2_next: VIDIOC_QBUF: Invalid argument
[1] Video device fatal error - Closing video device
[1] Closing video device /dev/video0
[1] Retrying until successful connection with camera
[1] cap.driver: "sonixb"
[1] cap.card: "USB camera"
[1] cap.bus_info: "usb-bcm2708_usb-1.2"
[1] cap.capabilities=0x05000001
[1] - VIDEO_CAPTURE
[1] - READWRITE
[1] - STREAMING
[1] Config palette index 8 (YU12) doesn't work.
[1] Supported palettes:
[1] 0: S910 (S910)
[1] 1: BA81 (BA81)
[1] Selected palette BA81
[1] Test palette BA81 (480x640)
[1] Adjusting resolution from 480x640 to 160x120.
[1] Using palette BA81 (160x120) bytesperlines 160 sizeimage 19200 colorspace 00000008
[1] found control 0x00980900, "Brightness", range 0,255
[1] "Brightness", default 127, current 127
[1] found control 0x00980911, "Exposure", range 0,1023
[1] "Exposure", default 66, current 66
[1] found control 0x00980912, "Automatic Gain (and Exposure)", range 0,1
[1] "Automatic Gain (and Exposure)", default 1, current 1
[1] found control 0x00980913, "Gain", range 0,255
[1] "Gain", default 127, current 127
[1] mmap information:
[1] frames=4
[1] 0 length=20480
[1] 1 length=20480
[1] 2 length=20480
[1] 3 length=20480
[1] Using V4L2
[1] Camera has finally become available
[1] Camera image has different width and height from what is in the config file. You should fix that
[1] Restarting Motion thread to reinitialize all image buffers to new picture dimensions
[1] Thread exiting
[1] Calling vid_close() from motion_cleanup
[1] Closing video device /dev/video0
[0] Motion thread 1 restart
[1] Thread 1 started
[1] config image height (120) is not modulo 16
[1] Could not fetch initial image from camera
[1] Motion continues using width and height from config file(s)
[1] Resizing pre_capture buffer to 1 items
[1] Started stream webcam server in port 8081
[1] Retrying until successful connection with camera
[1] config image height (120) is not modulo 16
[0] httpd - Finishing
[0] httpd Closing
[0] httpd thread exit
[1] Thread exiting
[0] Motion terminating
The light on the camera comes on at the start and then goes off again, does anyone recognise any of the errors i'm getting?
Thanks!
I think you need to set the height and width for the image in the conf file to your camera specification. Mine didnt work until I set height 640 width 480. Streams great! Just need to figure out the patch for the webstream authentication. currently I have this streaming to my webserver that requires a login but this can be bypassed if someone enters my IP plus the port im streaming on.
Even if configured in the conf file differently, motion uses the possible resolution it detects when it runs (at least in my experience).
Also, it seems an unsupported palette is set in the conf file and motion picks one of the two it detects as supported. Have you tried changing the palette setting to "0" (S910) in the conf file?
Lastly, the Pi's USB support has some known and as of now unsolved issues regarding big chunks of data. Lowering the framerate may also help in other cases (in this case, I think, I wouldn't help, since the process already fails with the first image).
Try v2l4-ctl --list-format-ext to see what combinations of pixel format and image size are supported on your camera. The S910 is a cheap old camera, you might want to upgrade.
Your problem is in the log:
config image height (120) is not modulo 16
So you need a different image resolution.
See what your device supports with
$ uvcdynctrl -f
Pick one that has a y-resolution that is a multiple of 16.
E.g. 640x480 if that one is listed for your camera.
I would suggest you try guvcview instead of motion. It runs faster and gives a far better picture on my Pi. It runs under X.
Two notes of guvcview - set POWER LINE FREQUENCY to your local mains freq.
- set resolution to 640 x 480.
guvcview takes about 50% processor power. Yes, use a USB Hub too!
Unh.