Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions python/pyspark/mllib/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ class LogisticRegressionModel(LinearClassificationModel):
1
>>> sameModel.predict(SparseVector(2, {0: 1.0}))
0
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except:
... pass
>>> multi_class_data = [
Expand Down Expand Up @@ -387,8 +388,9 @@ class SVMModel(LinearClassificationModel):
1
>>> sameModel.predict(SparseVector(2, {0: -1.0}))
0
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except:
... pass
"""
Expand Down Expand Up @@ -515,8 +517,9 @@ class NaiveBayesModel(Saveable, Loader):
>>> sameModel = NaiveBayesModel.load(sc, path)
>>> sameModel.predict(SparseVector(2, {0: 1.0})) == model.predict(SparseVector(2, {0: 1.0}))
True
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except OSError:
... pass
"""
Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/mllib/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ class KMeansModel(Saveable, Loader):
>>> sameModel = KMeansModel.load(sc, path)
>>> sameModel.predict(sparse_data[0]) == model.predict(sparse_data[0])
True
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except OSError:
... pass
"""
Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/mllib/recommendation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ class MatrixFactorizationModel(JavaModelWrapper, JavaSaveable, JavaLoader):
0.4...
>>> sameModel.predictAll(testset).collect()
[Rating(...
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except OSError:
... pass
"""
Expand Down
14 changes: 9 additions & 5 deletions python/pyspark/mllib/regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ class LinearRegressionModel(LinearRegressionModelBase):
True
>>> abs(sameModel.predict(SparseVector(1, {0: 1.0})) - 1) < 0.5
True
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except:
... pass
... pass
>>> data = [
... LabeledPoint(0.0, SparseVector(1, {0: 0.0})),
... LabeledPoint(1.0, SparseVector(1, {0: 1.0})),
Expand Down Expand Up @@ -275,8 +276,9 @@ class LassoModel(LinearRegressionModelBase):
True
>>> abs(sameModel.predict(SparseVector(1, {0: 1.0})) - 1) < 0.5
True
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except:
... pass
>>> data = [
Expand Down Expand Up @@ -389,8 +391,9 @@ class RidgeRegressionModel(LinearRegressionModelBase):
True
>>> abs(sameModel.predict(SparseVector(1, {0: 1.0})) - 1) < 0.5
True
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except:
... pass
>>> data = [
Expand Down Expand Up @@ -500,8 +503,9 @@ class IsotonicRegressionModel(Saveable, Loader):
2.0
>>> sameModel.predict(5)
16.5
>>> from shutil import rmtree
>>> try:
... os.removedirs(path)
... rmtree(path)
... except OSError:
... pass
"""
Expand Down
3 changes: 2 additions & 1 deletion python/pyspark/mllib/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import tempfile
import array as pyarray
from time import time, sleep
from shutil import rmtree

from numpy import array, array_equal, zeros, inf, all, random
from numpy import sum as array_sum
Expand Down Expand Up @@ -398,7 +399,7 @@ def test_classification(self):
self.assertEqual(same_gbt_model.toDebugString(), gbt_model.toDebugString())

try:
os.removedirs(temp_dir)
rmtree(temp_dir)
except OSError:
pass

Expand Down