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
0a5cacb9
Commit
0a5cacb9
authored
11 years ago
by
Tor Myklebust
Browse files
Options
Downloads
Patches
Plain Diff
Change some docstrings and add some others.
parent
b835ddf3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
python/pyspark/mllib.py
+3
-1
3 additions, 1 deletion
python/pyspark/mllib.py
with
3 additions
and
1 deletion
python/pyspark/mllib.py
+
3
−
1
View file @
0a5cacb9
...
@@ -146,7 +146,7 @@ def _linear_predictor_typecheck(x, coeffs):
...
@@ -146,7 +146,7 @@ def _linear_predictor_typecheck(x, coeffs):
raise
TypeError
(
"
Argument of type
"
+
type
(
x
)
+
"
unsupported
"
);
raise
TypeError
(
"
Argument of type
"
+
type
(
x
)
+
"
unsupported
"
);
class
LinearModel
(
object
):
class
LinearModel
(
object
):
"""
Something
containing
a vector of coefficients and an intercept.
"""
"""
Something
that has
a vector of coefficients and an intercept.
"""
def
__init__
(
self
,
coeff
,
intercept
):
def
__init__
(
self
,
coeff
,
intercept
):
self
.
_coeff
=
coeff
self
.
_coeff
=
coeff
self
.
_intercept
=
intercept
self
.
_intercept
=
intercept
...
@@ -305,6 +305,7 @@ class KMeansModel(object):
...
@@ -305,6 +305,7 @@ class KMeansModel(object):
self
.
centers
=
centers_
self
.
centers
=
centers_
def
predict
(
self
,
x
):
def
predict
(
self
,
x
):
"""
Find the cluster to which x belongs in this model.
"""
best
=
0
best
=
0
best_distance
=
1e75
best_distance
=
1e75
for
i
in
range
(
0
,
self
.
centers
.
shape
[
0
]):
for
i
in
range
(
0
,
self
.
centers
.
shape
[
0
]):
...
@@ -318,6 +319,7 @@ class KMeansModel(object):
...
@@ -318,6 +319,7 @@ class KMeansModel(object):
@classmethod
@classmethod
def
train
(
cls
,
sc
,
data
,
k
,
maxIterations
=
100
,
runs
=
1
,
def
train
(
cls
,
sc
,
data
,
k
,
maxIterations
=
100
,
runs
=
1
,
initialization_mode
=
"
k-means||
"
):
initialization_mode
=
"
k-means||
"
):
"""
Train a k-means clustering model.
"""
dataBytes
=
_get_unmangled_double_vector_rdd
(
data
)
dataBytes
=
_get_unmangled_double_vector_rdd
(
data
)
ans
=
sc
.
_jvm
.
PythonMLLibAPI
().
trainKMeansModel
(
dataBytes
.
_jrdd
,
ans
=
sc
.
_jvm
.
PythonMLLibAPI
().
trainKMeansModel
(
dataBytes
.
_jrdd
,
k
,
maxIterations
,
runs
,
initialization_mode
)
k
,
maxIterations
,
runs
,
initialization_mode
)
...
...
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