Meta tags:
Headings (most frequently used words):
data, worker, dask, training, incrementally, train, large, datasets, create, and, learn, model, info, scheduler, examples, documentation, contents, setup, split, for, testing, persist, in, memory, precompute, classes, scikit, wrap, with, ml, incremental, meta, estimator, pass, over, the, many, times, predict, score, more, client, cluster, localcluster, workers,
Text of the page (most frequently used words):
dask (63), the (38), data (30), and (24), incremental (23), learn (21), score (19), scikit (17), with (17), this (17), #estimator (16), 127 (16), memory (15), for (14), #training (14), examples (14), worker (12), datasets (11), partial_fit (11), dashboard (11), large (10), over (10), our (10), classes (10), inc (9), 100 (9), many (9), from (9), dataframes (9), tcp (9), train (8), model (8), meta (8), that (8), you (8), x_test (8), predict (8), fit (8), will (8), http (8), machine (8), client (8), learning (8), status (8), total (8), more (7), array (7), arrays (7), est (7), sgdclassifier (7), import (7), work (7), create (7), documentation (6), method (6), y_test (6), results (6), y_train (6), x_train (6), scoring (6), pass (6), use (6), dataset (6), dask_ml (6), persist (6), distributed (6), gib (6), threads (6), models (5), split (5), chunks (5), can (5), testing (5), times (5), not (5), comm (5), user (5), notebook (4), want (4), compute (4), type (4), chunk (4), implements (4), which (4), wrappers (4), wrap (4), but (4), example (4), computation (4), mib (4), scheduler (4), home (4), runner (4), space (4), local (4), directory (4), nanny (4), incrementally (4), info (3), test (3), see (3), estimators (3), api (3), using (3), process (3), implement (3), call (3), 10000 (3), numpy (3), ndarray (3), tasks (3), count (3), shape (3), bytes (3), accuracy (3), log (3), loss (3), calling (3), all (3), batches (3), does (3), precompute (3), small (3), enough (3), 100000 (3), run (3), workers (3), 8787 (3), cluster (3), setup (3), survey (3), workloads (3), developers (2), text (2), vectorization (2), pipeline (2), evaluation (2), list (2), org (2), html (2), automate (2), might (2), 637 (2), get (2), kib (2), tol (2), penalty (2), may (2), loop (2), one (2), each (2), above (2), handle (2), when (2), management (2), while (2), underlying (2), now (2), sgdclassifer (2), here (2), any (2), csv (2), files (2), then (2), have (2), read (2), computations (2), 90000 (2), float64 (2), train_test_split (2), base (2), running (2), make_classification (2), 000 (2), localcluster (2), view (2), handles (2), batch (2), time (2), live (2), contents (2), toggle (2), navigation (2), web (2), scale (2), custom (2), copyright, 2018, next, previous, hyperparameters, validation, compatible, https, stable, computing, scaling_strategies, went, about, investigate, following, int64, 1000, produces, lazy, finally, also, 6102, 5896, 5897, 6159, 6154, 6254, 6394, 6345, print, range, passes, once, however, cases, 5942, watch, during, sequential, fitting, perform, note, set, parameter, tell, works, better, recall, only, leaving, actual, algorithm, modules, generated, available, sklearn, linear_model, make, unique, pre, required, classification, preserve, needed, came, was, persisted, would, desirable, ram, slows, down, otherwise, are, working, situation, where, your, should, skip, step, everything, still, slower, less, ask, execute, keep, 9000, model_selection, into, aid, making, sure, fair, information, creating, real, usr, share, miniconda3, envs, lib, python3, site, packages, 1283, userwarning, single, active, lead, unexpected, warnings, warn, flip_y, n_features, n_samples, has, features, synthetic, interesting, quickly, pxcnehmb, 33679, 43331, 37923, _7hesy4q, 44935, 44433, 40821, g873798m, 33129, 43051, 35171, pf961cd2, 43431, 43969, 43257, just, started, 38373, 55b9e8e1, 2630, 4f2c, b9a8, 94f5f1e77a1c, true, processes, 85c11ebe, object, connection, 6fe04c8e, 0de1, 11ed, a3a3, 000d3a8f7959, threads_per_worker, n_workers, clicking, link, after, cell, first, start, order, access, provide, progress, performance, metrics, although, uses, class, predicting, wrapped, wrapping, shows, demonstrates, automates, loading, moving, necessary, allows, scaling, across, machines, familiar, workflow, discusses, approach, depth, their, guide, y_train_2, x_train_2, y_train_1, x_train_1, enable, github, session, pdf, ipynb, theme, executable, book, project, 2019, 2020, 2021, surveys, series, forecasting, stencil, numba, etl, pipelines, prefect, image, processing, evolving, workflows, embarrassingly, parallel, asynchronous, servers, async, await, non, blocking, execution, analyze, hosted, json, applications, singular, value, decomposition, generalized, linear, tpot, voting, classifiers, xgboost, hyperparameter, optimization, prediction, pytorch, problems, blockwise, ensemble, methods, reading, messy, gotcha, pandas, groupby, write, resilience, against, hardware, failures, xarray, operating, sql, futures, delayed, bags, basic, sidebar, community, ecosystem,
Text of the page (random words):
incrementally train large datasets dask examples documentation dask distributed dask ml examples ecosystem community toggle navigation sidebar dask examples documentation basic examples dask arrays dask bags dask dataframes custom workloads with dask delayed custom workloads with futures dask for machine learning operating on dask dataframes with sql xarray with dask arrays resilience against hardware failures dataframes dataframes read and write data dataframes groupby gotcha s from pandas to dask dataframes reading in messy data machine learning blockwise ensemble methods scale scikit learn for small data problems score and predict large datasets batch prediction with pytorch train models on large datasets incrementally train large datasets text vectorization pipeline hyperparameter optimization with dask scale xgboost use voting classifiers automate machine learning with tpot generalized linear models singular value decomposition applications analyze web hosted json data async await and non blocking execution asynchronous computation web servers dask embarrassingly parallel workloads handle evolving workflows image processing etl pipelines with prefect stencil computations with numba time series forecasting user surveys 2021 dask user survey results 2020 dask user survey results 2019 dask user survey results theme by the executable book project toggle navigation ipynb pdf contents setup dask create data split data for training and testing persist data in memory precompute classes create scikit learn model wrap with dask ml s incremental meta estimator model training pass over the training data many times predict and score learn more incrementally train large datasets contents setup dask create data split data for training and testing persist data in memory precompute classes create scikit learn model wrap with dask ml s incremental meta estimator model training pass over the training data many times predict and score learn more live notebook you can run this notebook in a live session or view it on github incrementally train large datasets we can train models on large datasets one batch at a time many scikit learn estimators implement a partial_fit method to enable incremental learning in batches est sgdclassifier est partial_fit x_train_1 y_train_1 est partial_fit x_train_2 y_train_2 the scikit learn documentation discusses this approach in more depth in their user guide this notebook demonstrates the use of dask ml s incremental meta estimator which automates the use of scikit learn s partial_fit over dask arrays and dataframes scikit learn handles all of the computation while dask handles the data management loading and moving batches of data as necessary this allows scaling to large datasets distributed across many machines or to datasets that do not fit in memory all with a familiar workflow this example shows wrapping a scikit learn estimator that implements partial_fit with the dask ml incremental meta estimator training predicting and scoring on this wrapped estimator although this example uses scikit learn s sgdclassifer the incremental meta estimator will work for any class that implements partial_fit and the scikit learn base estimator api setup dask we first start a dask client in order to get access to the dask dashboard which will provide progress and performance metrics you can view the dashboard by clicking on the dashboard link after you run the cell 1 from dask distributed import client client client n_workers 4 threads_per_worker 1 client 1 client client 6fe04c8e 0de1 11ed a3a3 000d3a8f7959 connection method cluster object cluster type distributed localcluster dashboard http 127 0 0 1 8787 status cluster info localcluster 85c11ebe dashboard http 127 0 0 1 8787 status workers 4 total threads 4 total memory 6 78 gib status running using processes true scheduler info scheduler scheduler 55b9e8e1 2630 4f2c b9a8 94f5f1e77a1c comm tcp 127 0 0 1 38373 workers 4 dashboard http 127 0 0 1 8787 status total threads 4 started just now total memory 6 78 gib workers worker 0 comm tcp 127 0 0 1 43257 total threads 1 dashboard http 127 0 0 1 43969 status memory 1 70 gib nanny tcp 127 0 0 1 43431 local directory home runner work dask examples dask examples machine learning dask worker space worker pf961cd2 worker 1 comm tcp 127 0 0 1 35171 total threads 1 dashboard http 127 0 0 1 43051 status memory 1 70 gib nanny tcp 127 0 0 1 33129 local directory home runner work dask examples dask examples machine learning dask worker space worker g873798m worker 2 comm tcp 127 0 0 1 40821 total threads 1 dashboard http 127 0 0 1 44433 status memory 1 70 gib nanny tcp 127 0 0 1 44935 local directory home runner work dask examples dask examples machine learning dask worker space worker _7hesy4q worker 3 comm tcp 127 0 0 1 37923 total threads 1 dashboard http 127 0 0 1 43331 status memory 1 70 gib nanny tcp 127 0 0 1 33679 local directory home runner work dask examples dask examples machine learning dask worker space worker pxcnehmb create data we create a synthetic dataset that is large enough to be interesting but small enough to run quickly our dataset has 1 000 000 examples and 100 features 2 import dask import dask array as da from dask_ml datasets import make_classification n d 100000 100 x y make_classification n_samples n n_features d chunks n 10 flip_y 0 2 x usr share miniconda3 envs dask examples lib python3 9 site packages dask base py 1283 userwarning running on a single machine scheduler when a distributed client is active might lead to unexpected results warnings warn 2 array chunk bytes 76 29 mib 7 63 mib shape 100000 100 10000 100 count 10 tasks 10 chunks type float64 numpy ndarray 100 100000 for more information on creating dask arrays and dataframes from real data see documentation on dask arrays and dask dataframes split data for training and testing we split our dataset into training and testing data to aid evaluation by making sure we have a fair test 3 from dask_ml model_selection import train_test_split x_train x_test y_train y_test train_test_split x y x_train 3 array chunk bytes 68 66 mib 6 87 mib shape 90000 100 9000 100 count 70 tasks 10 chunks type float64 numpy ndarray 100 90000 persist data in memory this dataset is small enough to fit in distributed memory so we call dask persist to ask dask to execute the computations above and keep the results in memory 4 x_train x_test y_train y_test dask persist x_train x_test y_train y_test if you are working in a situation where your dataset does not fit in memory then you should skip this step everything will still work but will be slower and use less memory calling dask persist will preserve our data in memory so no computation will be needed as we pass over our data many times for example if our data came from csv files and was not persisted then the csv files would have to be re read on each pass this is desirable if the data does not fit in ram but not slows down our computation otherwise precompute classes we pre compute the classes from our training data which is required for this classification example 5 classes da unique y_train compute classes 5 array 0 1 create scikit learn model we make the underlying scikit learn estimator an sgdclassifier 6 from sklearn linear_model import sgdclassifier est sgdclassifier loss log penalty l2 tol 1e 3 here we use sgdclassifier but any estimator that implements the partial_fit method will work a list of scikit learn models that implement this api is available here wrap with dask ml s incremental meta estimator we now wrap our sgdclassifer with the dask_ml wrappers incremental http ml dask org modules generated dask_ml wrappers incremental html dask_ml wrappers incremental __ meta estimator 7 from dask_ml wrappers import incremental inc incremental est scoring accuracy recall that incremental only does data management while leaving the actual algorithm to the underlying scikit learn estimator note we set the scoring parameter above in the dask estimator to tell it to handle scoring this works better when using dask arrays for test data model training incremental implements a fit method which will perform one loop over the dataset calling partial_fit over each chunk in the dask array you may want to watch the dashboard during this fit process to see the sequential fitting of many batches 8 inc fit x_train y_train classes classes 8 incremental estimator sgdclassifier loss log scoring accuracy 9 inc score x_test y_test 9 0 5942 pass over the training data many times calling fit passes over all chunks our data once however in many cases we may want to pass over the training data many times to do this we can use the incremental partial_fit method and a for loop 10 est sgdclassifier loss log penalty l2 tol 0e 3 inc incremental est scoring accuracy 11 for _ in range 10 inc partial_fit x_train y_train classes classes print score inc score x_test y_test score 0 6102 score 0 5896 score 0 5897 score 0 6159 score 0 6154 score 0 62 score 0 6254 score 0 6394 score 0 6345 score 0 637 predict and score finally we can also call incremental predict and incremental score on our testing data 12 inc predict x_test predict produces lazy dask arrays 12 array chunk bytes 78 12 kib 7 81 kib shape 10000 1000 count 20 tasks 10 chunks type int64 numpy ndarray 10000 1 13 inc predict x_test 100 compute call compute to get results 13 array 1 0 0 1 1 0 1 1 0 1 0 0 0 0 0 0 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 1 0 1 0 1 0 0 0 0 1 1 0 0 0 1 1 1 1 0 1 0 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 0 1 1 0 1 0 1 1 1 1 0 0 0 0 0 0 1 1 0 1 0 1 0 1 1 1 0 1 0 1 1 0 14 inc score x_test y_test 14 0 637 learn more in this notebook we went over using dask ml s incremental meta estimator to automate the process of incremental training with scikit learn estimators that implement the partial_fit method if you want to learn more about this process you might want to investigate the following documentation https scikit learn org stable computing scaling_strategies html dask ml incremental api documentation list of scikit learn estimators compatible with dask ml s incremental for more info on the train test split for model evaluation see hyperparameters and model validation previous train models on large datasets next text vectorization pipeline by dask developers copyright 2018 dask developers
|