Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spark
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cs525-sp18-g07
spark
Commits
0b494c21
Commit
0b494c21
authored
11 years ago
by
Tor Myklebust
Browse files
Options
Downloads
Patches
Plain Diff
Un-semicolon mllib.py.
parent
0a5cacb9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/pyspark/mllib.py
+11
-11
11 additions, 11 deletions
python/pyspark/mllib.py
with
11 additions
and
11 deletions
python/pyspark/mllib.py
+
11
−
11
View file @
0b494c21
...
...
@@ -143,7 +143,7 @@ def _linear_predictor_typecheck(x, coeffs):
elif
(
type
(
x
)
==
RDD
):
raise
RuntimeError
(
"
Bulk predict not yet supported.
"
)
else
:
raise
TypeError
(
"
Argument of type
"
+
type
(
x
)
+
"
unsupported
"
)
;
raise
TypeError
(
"
Argument of type
"
+
type
(
x
)
+
"
unsupported
"
)
class
LinearModel
(
object
):
"""
Something that has a vector of coefficients and an intercept.
"""
...
...
@@ -170,7 +170,7 @@ def _get_unmangled_double_vector_rdd(data):
dataBytes
=
data
.
map
(
_serialize_double_vector
)
dataBytes
.
_bypass_serializer
=
True
dataBytes
.
cache
()
return
dataBytes
;
return
dataBytes
# If we weren't given initial weights, take a zero vector of the appropriate
# length.
...
...
@@ -183,8 +183,8 @@ def _get_initial_weights(initial_weights, data):
if
initial_weights
.
ndim
!=
1
:
raise
TypeError
(
"
At least one data element has
"
+
initial_weights
.
ndim
+
"
dimensions, which is not 1
"
)
initial_weights
=
zeros
([
initial_weights
.
shape
[
0
]
-
1
])
;
return
initial_weights
;
initial_weights
=
zeros
([
initial_weights
.
shape
[
0
]
-
1
])
return
initial_weights
# train_func should take two parameters, namely data and initial_weights, and
# return the result of a call to the appropriate JVM stub.
...
...
@@ -194,14 +194,14 @@ def _regression_train_wrapper(sc, train_func, klass, data, initial_weights):
dataBytes
=
_get_unmangled_double_vector_rdd
(
data
)
ans
=
train_func
(
dataBytes
,
_serialize_double_vector
(
initial_weights
))
if
len
(
ans
)
!=
2
:
raise
RuntimeError
(
"
JVM call result had unexpected length
"
)
;
raise
RuntimeError
(
"
JVM call result had unexpected length
"
)
elif
type
(
ans
[
0
])
!=
bytearray
:
raise
RuntimeError
(
"
JVM call result had first element of type
"
+
type
(
ans
[
0
])
+
"
which is not bytearray
"
)
;
+
type
(
ans
[
0
])
+
"
which is not bytearray
"
)
elif
type
(
ans
[
1
])
!=
float
:
raise
RuntimeError
(
"
JVM call result had second element of type
"
+
type
(
ans
[
0
])
+
"
which is not float
"
)
;
return
klass
(
_deserialize_double_vector
(
ans
[
0
]),
ans
[
1
])
;
+
type
(
ans
[
0
])
+
"
which is not float
"
)
return
klass
(
_deserialize_double_vector
(
ans
[
0
]),
ans
[
1
])
class
LinearRegressionModel
(
LinearRegressionModelBase
):
"""
A linear regression model derived from a least-squares fit.
...
...
@@ -324,11 +324,11 @@ class KMeansModel(object):
ans
=
sc
.
_jvm
.
PythonMLLibAPI
().
trainKMeansModel
(
dataBytes
.
_jrdd
,
k
,
maxIterations
,
runs
,
initialization_mode
)
if
len
(
ans
)
!=
1
:
raise
RuntimeError
(
"
JVM call result had unexpected length
"
)
;
raise
RuntimeError
(
"
JVM call result had unexpected length
"
)
elif
type
(
ans
[
0
])
!=
bytearray
:
raise
RuntimeError
(
"
JVM call result had first element of type
"
+
type
(
ans
[
0
])
+
"
which is not bytearray
"
)
;
return
KMeansModel
(
_deserialize_double_matrix
(
ans
[
0
]))
;
+
type
(
ans
[
0
])
+
"
which is not bytearray
"
)
return
KMeansModel
(
_deserialize_double_matrix
(
ans
[
0
]))
def
_test
():
import
doctest
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment