all | Learn for Master - Part 2
  • Using Azure ML to Build Clickthrough Prediction Models

    Using Azure ML to Build Clickthrough Prediction Models

    This blog post is by Girish Nathan, a Senior Data Scientist at Microsoft.

    Ad click prediction is a multi-billion dollar industry, and one that is still growing rapidly. In this post, we build ML models on the largest publicly available ad click prediction dataset, from Criteo. The Criteo dataset consists of some 4.4 billion advertising feedback events. In Criteo’s words, “…this dataset contains feature values and click feedback for millions of display ads. Its purpose is to benchmark algorithms for clickthrough rate (CTR) prediction.”

    Azure services provide the tools needed to build a predictive model using this data.

    [Read More...]
  • Data Transformation methods: one hot encoding, learning with counts

    Data Transformation

    One hot encoding transforms categorical features to a format that works better with classification and regression algorithms.

    Let’s take the following example. I have seven sample inputs of categorical data belonging to four categories. Now, I could encode these to nominal values as I have done here, but that wouldn’t make sense from a machine learning perspective. We can’t say that the category of “Penguin” is greater or smaller than “Human”. Then they would be ordinal values, not nominal.

    What we do instead is generate one boolean column for each category. Only one of these columns could take on the value 1 for each sample.

    [Read More...]
  • 用python参加Kaggle的经验总结

    from: http://www.jianshu.com/p/32def2294ae6

    最近挤出时间,用python在kaggle上试了几个project,有点体会,记录下。

    Step1: Exploratory Data Analysis

    EDA,也就是对数据进行探索性的分析,一般就用到pandas和matplotlib就够了。EDA一般包括:

    1. 每个feature的意义,feature的类型,比较有用的代码如下
    2. 看是否存在missing value
    3. 每个特征下的数据分布,可以用boxplot或者hist来看
    4. 如果想看几个feature之间的联立情况,则可以用pandas的groupby,
      temp = pd.crosstab([df.Pclass, df.Sex], df.Survived.astype(bool))
      temp.plot(kind=’bar’, stacked=True, color=[‘red’,’blue’], grid=False)

    在这步完成之后,要对以下几点有大致了解

    • 理解每个特征的意义
    • 要知道哪些特征是有用的,这些特征哪些是直接可以用的,哪些需要经过变换才能用,为之后的特征工程做准备

    Step2: Data Preprocessing

    数据预处理,就是将数据处理下,为模型输入做准备,其中包括:

    • 处理missing value:这里学问有点深,如果各位有好的经验可以跟我交流下。以我浅薄的经验来说我一般会分情况处理
      1. 如果missing value占总体的比例非常小,那么直接填入平均值或者众数
      2. 如果missing value所占比例不算小也不算大,那么可以考虑它跟其他特征的关系,如果关系明显,那么直接根据其他特征填入;也可以建立简单的模型,比如线性回归,随机森林等。
      3. 如果missing value所占比例大,那么直接将miss value当做一种特殊的情况,另取一个值填入
    • 处理Outlier:这个就是之前EDA的作用了,通过画图,找出异常值
    • 处理categorical feature:一般就是通过dummy variable的方式解决,也叫one hot encode,可以通过pandas.get_dummies()或者 sklearn中preprocessing.OneHotEncoder(), 我个人倾向于用pandas的get_dummies()
      看个例子吧,

      dummy variable

      将一列的month数据展开为了12列,用0、1代表类别。
      另外在处理categorical feature有两点值得注意:

      1. 如果特征中包含大量需要做dummy variable处理的,那么很可能导致得到一个稀疏的dataframe,这时候最好用下PCA做降维处理。
      2. 如果某个特征有好几万个取值,那么用dummy variable就并不现实了,这时候可以用Count-Based Learning.
    [Read More...]
  • An Introduction to Stock Market Data Analysis with Python

    Here are some best article for stock data analysis using python.
    An Introduction to Stock Market Data Analysis with Python (Part 1)

    from: https://ntguardian.wordpress.com/2016/09/19/introduction-stock-market-data-python-1/

    This post is the first in a two-part series on stock data analysis using Python, based on a lecture I gave on the subject for MATH 3900 (Data Science) at the University of Utah. In these posts, I will discuss basics such as obtaining the data from Yahoo! Finance using pandas, visualizing stock data, moving averages, developing a moving-average crossover strategy, backtesting, and benchmarking. The final post will include practice problems.

    [Read More...]
  • use spark to calculate moving average for time series data

    Spark Window Functions for DataFrames and SQL

    from: http://xinhstechblog.blogspot.de/2016/04/spark-window-functions-for-dataframes.html

    Introduced in Spark 1.4, Spark window functions improved the expressiveness of Spark DataFrames and Spark SQL. With window functions, you can easily calculate a moving average or cumulative sum, or reference a value in a previous row of a table. Window functions allow you to do many common calculations with DataFrames, without having to resort to RDD manipulation.

    Aggregates, UDFs vs. Window functions

    Window functions are complementary to existing DataFrame operations: aggregates, such as sumand avg, and UDFs. To review,

    [Read More...]
  • How to send email on linux terminal

    You may want to send email using linux terminal.

    The easiest way is to use mail tool.

    for example, you can use the following command to send an email easily.

    echo “content the email” | mail -s “subject of this email” [email protected]

    You can also use -a option to attach a file:

    echo “content the email” | mail -s “subject of this email” -a ~/filename [email protected]

    However, you may want to specify the sender’s email address. Then a good tool is sendEmail.

    About SendEmail
    SendEmail is a lightweight,

    [Read More...]
  • Good Articles to learn how to implement a neural network 1

    This series of post will list some good articles about how to implement a neural network. Thanks for the authors for the excellent work.
    If you are the author and you don’t want your articles listed here. Please email to learn4master, we will remove it from the site.

    How to implement a neural network Part 1

    From: http://peterroelants.github.io/posts/neural_network_implementation_part01/

    This page is part of a 5 (+2) parts tutorial on how to implement a simple neural network model. You can find the links to the rest of the tutorial here:

    The tutorials are generated from Python 2 IPython Notebook files,

    [Read More...]
  • Good Articles to learn how to implement a neural network 2

    Vectorization

    This part will cover:

    The previous tutorial described a very simple neural network with only one input, one hidden neuron and one output. This tutorial will describe a neural network that takes 2-dimensional input samples, projects them onto a 3-dimensional hidden layer, and classifies them with a 2-dimensional softmax output classfier, this softmax function is explained in intermezzo 2 . While we didn’t add the bias parameters to the previous 2 models, we will add them to this model.

    [Read More...]
  • shell script replace variable of linux path

    sed is a popular tool to be used to replace a string in a file.

    For example, give a file, we can use the following command to replace all the string XXX into YY

    sed -i s/XXX/YY/g fileName

    or sed s/XXX/YY/g fileName > newFile

    but when you want to replace linux path, the above method doesn’t work. You can try it your self.

    here is a workable solution:

    pathA=”/user/xx/zz/”

    pathB=”/user/aa/zz/dd”

    sed “s,$pathA,$pathB,g” fileName > newFileName

    then all the path of /user/xx/zz/ will be replaced by /user/aa/zz/dd.

    [Read More...]
  • funny gif pictures 1

    收藏各种搞笑的gif动画
    不到最后,你永远不知道你是棋子还是目标

    1759

    这速度,真的也是没谁了

    3204

    你永远也不知道炫耀路上会出现什么样的意外

    20515

    沈王爷突然一声吼,吓得滚滚腿发抖 吓死宝宝了

    2128189

    被海狮壁咚是一种什么样的感受

    163044

    当饲养员给了猴哥一块榴莲干

    150173

    爸爸辛苦那么久,一定渴了

    84046

    万万没想到,你是这样的相扑

    25727

    我就这样静静地,慢慢地抱着吃

    6347

    一失足成千古恨啊,白跳了

    [Read More...]
Page 2 of 2912345...101520...Last »