Thursday, December 13, 2018

CPU profiler


1. CPU profilter
1. 1 gprof, Valgrind and gperftools - an evaluation of some tools for application level CPU profiling on Linux

1.2 List of performance analysis tools

2. Valgrind
 - memory leak profiling: $ valgrind ./sample
 - cache profileing: $ valgrind --tool==cachegrind ./sample
 - function profiling: $ valgrind --tool==callgrind ./sample
 - kcachegrind (GUI tool)

3. gprof
 - WIKI
 - tutorial: https://www.thegeekstuff.com/2012/08/gprof-tutorial/
 - What is gprof?
 - How to install and use profiling tool Gprof on Linux
 - GPROF Tutorial
    To write the gmon.out file properly, your program must exit normally. _exit()
    Call graph: gprof2dot
 - gprof Quick-Start Guide


  • use the makefile (edit CFLAGS / FFLAGS first) or call compiler at the shell
  • required flags for profiling: -pg -g
  • try with and without inlining: -finline / -fno-inline


4. gprof2dot

Saturday, September 1, 2018

The history of "foo" & "bar"


http://programmers.stackexchange.com/questions/69788/using-foo-and-bar-in-examples

Start Python for C, C++ programmmer


Python Tutorial
http://docs.python.org/2/tutorial/index.html

Matplot Lib.
http://coreapython.hosting.paran.com/manual/Matplotlib%20-%20pylab%20-%20matlab%20style%20python%20plotting%20(plots,%20graphs,%20charts).htm (Korean Version)


Python: Tips 1

sprintf in Python
------------------------------

How to do a sprintf in Python
http://www.johnkerl.org/python/sprintf.html

[Tutor] sprintf-like functionality in Python
http://mail.python.org/pipermail/tutor/2003-August/024921.html

Python/파이썬] C언어의 sprintf 함수 구현 예제
http://mwultong.blogspot.com/2007/01/python-c-sprintf.html


gmtime conversion in Python
------------------------------

Python time gmtime() Method

http://www.tutorialspoint.com/python/time_gmtime.htm


import time
time.gmtime(xxxxxxxxx.xxx)


Python isNumber
------------------------------



http://mwultong.blogspot.com/2007/01/python-isnumber-isnum-isnumeric.html

def isNumber(s):
  try:
    float(s)
    return True
  except ValueError:
    return False

Case Ranges

in the Linux kernel, you can find below code

switch (val) { case 1 ... 10:         /* ... */         break; case 11 ... 20:         /* ... */         break; default:         /* ... */ }
It is a GCC extension.




CPU load & CPU stat

     user    nice   system  idle      iowait irq   softirq  steal  guest  guest_nice
cpu  74608   2520   24433   1117073   6176   4054  0        0      0      0

Algorithmically, we can calculate the CPU usage percentage like:
PrevIdle = previdle + previowait
Idle = idle + iowait

PrevNonIdle = prevuser + prevnice + prevsystem + previrq + prevsoftirq + prevsteal
NonIdle = user + nice + system + irq + softirq + steal

PrevTotal = PrevIdle + PrevNonIdle
Total = Idle + NonIdle

# differentiate: actual value minus the previous one
totald = Total - PrevTotal
idled = Idle - PrevIdle

CPU_Percentage = (totald - idled)/totald


cpu  114466 58760 208131 183612 1490 18 5178 0 0 0
cpu0 20966 6912 72976 161278 1200 3 3263 0 0 0
cpu1 18880 6959 39092 4213 20 5 112 0 0 0
cpu2 18665 6782 29917 4321 21 2 50 0 0 0
cpu3 18134 6434 27657 4442 21 2 62 0 0 0
cpu4 10008 8231 10491 2308 63 0 1003 0 0 0
cpu5 9338 8080 9868 2382 64 0 240 0 0 0
cpu6 9210 7570 9186 2392 40 2 226 0 0 0
cpu7 9265 7792 8944 2276 61 4 222 0 0 0



http://stackoverflow.com/questions/23367857/accurate-calculation-of-cpu-usage-given-in-percentage-in-linux

Notpad++ plugin x64

[Release]
- Add Library
Property > Linker > Input > Additional Dependencies
add the library full path (include file name)

- Add preprocessor define
Property > C/C++ > Preprocessor > Preprocessor Definitions
add define word e.g., __TEST_DEF__


[Debug]
error D8016: '/Ox' and '/RTC1' command-line options are incompatible
- Property > C/C++ > Code Generation > Basic Runtime Checks
from "Both (/RTC1, equiv. to /RTCsu) (/RTC1)" to "default"


About source code
how to use zlib in C++
http://windrealm.org/tutorials/decompress-gzip-stream.php
Base64, open source in apple
https://opensource.apple.com/source/QuickTimeStreamingServer/QuickTimeStreamingServer-452/CommonUtilitiesLib/base64.c


// display string in new tab window
::SendMessage(nppData._nppHandle, NPPM_MENUCOMMAND, 0, IDM_FILE_NEW);

HWND hCurrScintilla = getCurrentScintillaHandle();
::SendMessage(hCurrScintilla, SCI_SETTEXT, 0, (LPARAM)SSRM_log);

[Change Project Name]
open editor and change file name and directory path
 - XXX.sln
 - XXX.vcxproj




Machine Learning

Russ Salakhutdinov


Russ Salakhutdinov,
 Professor at Carnegie Mellon University, Director of AI Research at Apple

http://www.cs.cmu.edu/~rsalakhu/talk_Simons_part1_pdf.pdf
http://www.cs.cmu.edu/~rsalakhu/talk_Simons_part2_pdf.pdf
http://www.cs.cmu.edu/~rsalakhu/talk_Simons_part3_pdf.pdf
http://www.cs.cmu.edu/~rsalakhu/talk_Simons_part4_pdf.pdf

Friday, August 31, 2018

Python: DataFrame2

Basic
Starting out with Python Pandas DataFrames
The Pandas DataFrame – loading, editing, and viewing data in Python

1. head(), tail()
 is it possible mid data, not head or tail?
 df.iloc[[row_start:row_end],[column_start:column_end]]
2. describe()
 separate data each type, and then use the describe() function
3. selecting column
 df.column_name
 df['column_name']
 df.iloc[:, ]
4. selecting row
 df.iloc[0:10, :] - select data first 10 rows.
 df.loc[44, :]
 df[df["Area"] == "Ireland"] – select the rows where Area value is ‘Ireland’.
5. From DataFrame to list values
 df.column_name.values
 df.column_name.tolist()
6. Some columns data
 new = old[['A', 'C', 'D']].copy()
 new = old.filter(['A', 'C', 'D'], axis=1)
 Extracting specific selected columns from a DataFrame to new DataFrame
 * remove column
 new = old.drop('B', axis=1)
7. Change, update index
 df.index = [list_value]

Visualization
Pandas DataFrame Visualization
Data Visualization & Exploration using Pandas Only: Beginner
Modern Pandas (Part 6): Visualization
Visualization with Seaborn
Visualize data with Pandas

Errorbar or box plot, Histogram
Box plot with min, max, average and standard deviation
Python Histograms, Box Plots, & Distributions

Scattering graph
draw box plot & draw all real value (point)
Matplotlib: avoiding overlapping datapoints in a “scatter/dot/beeswarm” plot

Seaborn

DataFrame plot
Understand df.plot in pandas
Data Frames and Plotting
Plotting Series and DataFrame objects

Others
Creating Pandas DataFrames from Lists and Dictionaries
Python에서 데이터 시각화하는 다양한 방법
Create multiple dataframes in loop


Thursday, August 2, 2018

Source Insight - presettings

1. background color
 - Options > Preferences > Colors > Window Background
   [Color...] select color

2. Select Font & Font setting
 - Consolas from Microsoft
   https://www.microsoft.com/en-us/download/details.aspx?id=17879
 - Options > Document Options
   [Screen Fonts...]

3. Disable display formatting
 - Options > Preferences > Basics
   check: Use only color formatting

4. Show right margin: 80 column
 - Options > Document Options > Edition Options
   check: Show right margin

5. Show line number
 - Options > Document Options > Edition Options
   check: Show line number

6. Display full file path in title bar
 - Options > Preference > Display 
    check: Trim Long Path Names With ellipses
   https://stackoverflow.com/questions/8309701/source-insight-is-not-displaying-full-path-of-a-file-in-title-bar

7. add a new keyword, such as "defined"
 - mouse right button click > Keyword List... > Add Word...

Monday, May 28, 2018

Linear Regression

1. Scaling
In the Linear Regression,
Why do it need scaler function, such as
 fit()
 transform()
 or fit_transform()
in Scikit-Learn

1.1 Compare the effect of different scalers on data with outliers
http://scikit-learn.org/stable/auto_examples/preprocessing/plot_all_scaling.html

What is the "gradient-based estimators"?

1.2 Machine Learning FAQ
https://sebastianraschka.com/faq/docs/closed-form-vs-gd.html
1.3 Types of Optimization Algorithms used in Neural Networks and Ways to Optimize Gradient Descent
https://towardsdatascience.com/types-of-optimization-algorithms-used-in-neural-networks-and-ways-to-optimize-gradient-95ae5d39529f


2. Linear Regression

2.0 A comprehensive beginners guide for Linear, Ridge and Lasso Regression
https://www.analyticsvidhya.com/blog/2017/06/a-comprehensive-guide-for-linear-ridge-and-lasso-regression/

2.1 What Is R Squared And Negative R Squared
http://www.fairlynerdy.com/what-is-r-squared/
2.2 So Why Is It Called "Regression," Anyway?
http://blog.minitab.com/blog/statistics-and-quality-data-analysis/so-why-is-it-called-regression-anyway

2.3 sklearn.linear_model.LinearRegression
http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.LinearRegression.html

2.4 Linear Regression Example
http://scikit-learn.org/stable/auto_examples/linear_model/plot_ols.html#sphx-glr-auto-examples-linear-model-plot-ols-py
2.5 How to run Linear regression in Python scikit-Learn
http://bigdata-madesimple.com/how-to-run-linear-regression-in-python-scikit-learn/
2.6 Artificial Neural Networks: Linear Regression (Part 1), ANN
http://briandolhansky.com/blog/artificial-neural-networks-linear-regression-part-1
2.7 Neural Networks A Simple Problem (Linear Regression), Gradient Descent
https://www.cs.cmu.edu/afs/cs.cmu.edu/academic/class/15381-s06/www/nn.pdf
2.8 LINEAR REGRESSION IN PYTHON USING SCIKIT-LEARN (Good example)
http://benalexkeen.com/linear-regression-in-python-using-scikit-learn/

3. Linear Rression for TensorFlow
3.1 TensorFlow를 이용한 linear regression
https://www.joinc.co.kr/w/man/12/tensorflow/linearRegression