《Hands-On Machine Learning with Scikit-Learn and TensorFlow》附录B:机器学习项目清单

Machine Learning Project Checklist

  1. Frame the problem and look at the big picture.
  2. Get the data.
  3. Explore the data to gain insights.
  4. Prepare the data to better expose the underlying data patterns to Machine Learning algorithms.
  5. Explore many different models and short-list the best ones.
  6. Fine-tune your models and combine them into a great solution.
  7. Present your solution.
  8. Launch, monitor, and maintain your system

Frame the Problem and Look at the Big Picture

  1. Define the objective in business terms.
  2. How will your solution be used?
  3. What are the current solutions/workarounds (if any)?
  4. How should you frame this problem (supervised/unsupervised, online/offline,etc.)?
  5. How should performance be measured?
  6. Is the performance measure aligned with the business objective?
  7. What would be the minimum performance needed to reach the business objective?
  8. What are comparable problems? Can you reuse experience or tools?
  9. Is human expertise available?
  10. How would you solve the problem manually?
  11. List the assumptions you (or others) have made so far.
  12. Verify assumptions if possible.

Get the Data

Note: automate as much as possible so you can easily get fresh data.

  1. List the data you need and how much you need.
  2. Find and document where you can get that data.
  3. Check how much space it will take.
  4. Check legal obligations, and get authorization if necessary.
  5. Get access authorizations.
  6. Create a workspace (with enough storage space).
  7. Get the data.
  8. Convert the data to a format you can easily manipulate (without changing the data
    itself).
  9. Ensure sensitive information is deleted or protected (e.g., anonymized).
  10. Check the size and type of data (time series, sample, geographical, etc.).
  11. Sample a test set, put it aside, and never look at it (no data snooping!).

Explore the Data

Note: try to get insights from a field expert for these steps.

  1. Create a copy of the data for exploration (sampling it down to a manageable size if
    necessary).
  2. Create a Jupyter notebook to keep a record of your data exploration.
  3. Study each attribute and its characteristics:
    • Name
    • Type (categorical, int/float, bounded/unbounded, text, structured, etc.)
    • % of missing values
    • Noisiness and type of noise (stochastic, outliers, rounding errors, etc.)
    • Possibly useful for the task?
    • Type of distribution (Gaussian, uniform, logarithmic, etc.)
  4. For supervised learning tasks, identify the target attribute(s).
  5. Visualize the data.
  6. Study the correlations between attributes.
  7. Study how you would solve the problem manually.
  8. Identify the promising transformations you may want to apply.
  9. Identify extra data that would be useful
  10. Document what you have learned.

Prepare the Data

Notes:
• Work on copies of the data (keep the original dataset intact).
• Write functions for all data transformations you apply, for five reasons:
—So you can easily prepare the data the next time you get a fresh dataset
—So you can apply these transformations in future projects
—To clean and prepare the test set
—To clean and prepare new data instances once your solution is live
—To make it easy to treat your preparation choices as hyperparameters

  1. Data cleaning:
    • Fix or remove outliers (optional).
    • Fill in missing values (e.g., with zero, mean, median…) or drop their rows
    (orcolumns).

  2. Feature selection (optional):
    • Drop the attributes that provide no useful information for the task.

  3. Feature engineering, where appropriate:
    • Discretize continuous features.
    • Decompose features (e.g., categorical, date/time, etc.).
    • Add promising transformations of features (e.g., log(x), sqrt(x), x^2, etc.).
    • Aggregate features into promising new features.

  4. Feature scaling: standardize or normalize features.

Short-List Promising Models

Notes:
• If the data is huge, you may want to sample smaller training sets so you can
train many different models in a reasonable time (be aware that this penalizes
complex models such as large neural nets or Random Forests).
• Once again, try to automate these steps as much as possible.

  1. Train many quick and dirty models from different categories (e.g., linear,
    naive Bayes, SVM, Random Forests, neural net, etc.) using standard parameters.

  2. Measure and compare their performance.
    • For each model, use N-fold cross-validation and compute the mean
    and standarddeviation of the performance measure on the N folds.

  3. Analyze the most significant variables for each algorithm.

  4. Analyze the types of errors the models make.
    • What data would a human have used to avoid these errors?

  5. Have a quick round of feature selection and engineering.

  6. Have one or two more quick iterations of the five previous steps.

  7. Short-list the top three to five most promising models, preferring models
    that make different types of errors.

Fine-Tune the System

Notes:
• You will want to use as much data as possible for this step, especially
as you movetoward the end of fine-tuning.
• As always automate what you can.

  1. Fine-tune the hyperparameters using cross-validation.
    • Treat your data transformation choices as hyperparameters, especially
    when you are not sure about them (e.g., should I replace missing values
    with zero or with the median value? Or just drop the rows?).
    • Unless there are very few hyperparameter values to explore, prefer
    random search over grid search. If training is very long, you may prefer
    a Bayesianoptimization approach (e.g., using Gaussian process priors).

  2. Try Ensemble methods. Combining your best models will often perform
    better than running them individually.

  3. Once you are confident about your final model, measure its performance
    on thetest set to estimate the generalization error.

Present Your Solution

  1. Document what you have done.

  2. Create a nice presentation.
    • Make sure you highlight the big picture first.

  3. Explain why your solution achieves the business objective.

  4. Don’t forget to present interesting points you noticed along the way.
    • Describe what worked and what did not.
    • List your assumptions and your system’s limitations.

  5. Ensure your key findings are communicated through beautiful visualizations
    or easy-to-remember statements (e.g., “the median income is the number-one
    predictor of housing prices”).

Launch!

  1. Get your solution ready for production (plug into production data inputs,
    write unit tests, etc.).

  2. Write monitoring code to check your system’s live performance at regular
    interval sand trigger alerts when it drops.
    • Beware of slow degradation too: models tend to “rot” as data evolves.
    • Measuring performance may require a human pipeline (e.g., via a crowd
    sourcing service).
    • Also monitor your inputs’ quality (e.g., a malfunctioning sensor sending
    random values, or another team’s output becoming stale). This is particularly
    important for online learning systems.

  3. Retrain your models on a regular basis on fresh data (automate as
    much as possible).

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 221,820评论 6 515
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 94,648评论 3 399
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 168,324评论 0 360
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 59,714评论 1 297
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 68,724评论 6 397
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 52,328评论 1 310
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,897评论 3 421
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,804评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 46,345评论 1 318
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 38,431评论 3 340
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,561评论 1 352
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 36,238评论 5 350
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,928评论 3 334
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,417评论 0 24
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,528评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,983评论 3 376
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,573评论 2 359

推荐阅读更多精彩内容