joblib/joblib-spark
关于
Joblib 的 Apache Spark 后端
其他项目实测星标增长
- 24小时
- 0
- 7天
- 0
- 15天
- 0
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Joblib Apache Spark Backend
This library provides Apache Spark backend for joblib to distribute tasks on a Spark cluster.
Installation
joblibspark requires Python 3.6+, joblib>=0.14 and pyspark>=2.4 to run.
To install joblibspark, run:
pip install joblibspark
The installation does not install PySpark because for most users, PySpark is already installed.
If you do not have PySpark installed, you can install pyspark together with joblibspark:
pip install pyspark>=3.0.0 joblibspark
If you want to use joblibspark with scikit-learn, please install scikit-learn>=0.21.
Examples
Run following example code in pyspark shell:
from sklearn.utils import parallel_backend
from sklearn.model_selection import cross_val_score
from sklearn import datasets
from sklearn import svm
from joblibspark import register_spark
register_spark() # register spark backend
iris = datasets.load_iris()
clf = svm.SVC(kernel='linear', C=1)
with parallel_backend('spark', n_jobs=3):
scores = cross_val_score(clf, iris.data, iris.target, cv=5)
print(scores)
Limitations
joblibspark does not generally support run model inference and feature engineering in parallel.
For example:
from sklearn.feature_extraction import FeatureHasher
h = FeatureHasher(n_features=10)
with parallel_backend('spark', n_jobs=3):
# This won't run parallelly on spark, it will still run locally.
h.transform(...)
from sklearn import linear_model
regr = linear_model.LinearRegression()
regr.fit(X_train, y_train)
with parallel_backend('spark', n_jobs=3):
# This won't run parallelly on spark, it will still run locally.
regr.predict(diabetes_X_test)
Note: for sklearn.ensemble.RandomForestClassifier, there is a n_jobs parameter,
that means the algorithm support model training/inference in parallel,
but in its inference implementation, it bind the backend to built-in backends,
so the spark backend not work for this case.
探索相关项目
加载中…