What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-30 16:21:05
Word2Vec trains a model of Map
# Word2Vec trains a model of Map sent = ("a b " * 100 + "a c " * 10).split(" ") doc = spark.createDataFrame([(sent,), (sent,)], ["sentence"]) word2Vec = Word2Vec(vectorSize=5, seed=42, inputCol="sentence"... Add solution -
Python 2021-09-29 19:38:05
model pickle file create
import pickle # save the model to disk filename = 'finalized_model.sav' pickle.dump(model, open(filename, 'wb')) # some time later... # load the model from disk loaded_model = pickle.load(open(filename, 'rb')) result = loaded_model.score(X_test, Y_te... Add solution -
-
Python 2021-09-17 18:24:02
Decision tree learning algorithm for classification
# Decision tree learning algorithm for classification from pyspark.ml.linalg import Vectors from pyspark.ml.feature import StringIndexer df = spark.createDataFrame([ (1.0, Vectors.dense(1.0)), (0.0, Vectors.sparse(1, [], []))], ["label", &q... Add solution -
Python 2021-09-12 14:16:02
PCA trains a model to project vectors to a lower dimensional space of the top k principal components
# PCA trains a model to project vectors to a lower dimensional space of the top k principal components from pyspark.ml.linalg import Vectors data = [(Vectors.sparse(5, [(1, 1.0), (3, 7.0)]),), (Vectors.dense([2.0, 0.0, 3.0, 4.0, 5.0]),), ... Add solution -
Python 2021-09-06 12:43:03
Decision tree learning algorithm for regression
# Decision tree learning algorithm for regression from pyspark.ml.linalg import Vectors df = spark.createDataFrame([ (1.0, Vectors.dense(1.0)), (0.0, Vectors.sparse(1, [], []))], ["label", "features"]) dt = DecisionTreeRegressor(m... Add solution
Best helpers
Ranking is empty