-
Notifications
You must be signed in to change notification settings - Fork 28.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPARK-6083] [MLLib] [DOC] Make Python API example consistent in NaiveBayes #4834
Conversation
Test build #28130 has started for PR 4834 at commit
|
cc: @mengxr Would you be able to verify this? |
Hmm. I get an a accuracy of zero for the given example. Not sure where I'm going wrong though :( |
Test build #28130 has finished for PR 4834 at commit
|
Test PASSed. |
I changed the randomSplit seed and it works better. It should look good now. |
Test build #28139 has started for PR 4834 at commit
|
Test build #28139 has finished for PR 4834 at commit
|
Test PASSed. |
@MechCoder Thanks for the update! We only have 6 lines in |
Great. Do you have any more comments? |
|
||
# Preprocessing | ||
splitData = data.map(lambda line: line.split(',')) | ||
parsedData = splitData.map( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can define a parse function to make the code more readable. Btw, we use 4 space indentation in Python, following PEP8.
def parseLine(line):
parts = line.split(',')
label = float(parts[0])
features = Vector.dense([float(x) for x in parts[1].split(' ')])
return LabeledPoint(label, features)
data = sc.textFile('data/mllib/sample_naive_bayes_data.txt').map(parseLine)
@mengxr fixed ! |
Test build #28152 has started for PR 4834 at commit
|
LGTM. |
Test build #28152 has finished for PR 4834 at commit
|
Test PASSed. |
…eBayes Author: MechCoder <[email protected]> Closes #4834 from MechCoder/spark-6083 and squashes the following commits: 1cdd7b5 [MechCoder] Add parse function 65bbbe9 [MechCoder] [SPARK-6083] Make Python API example consistent in NaiveBayes (cherry picked from commit 3f00bb3) Signed-off-by: Xiangrui Meng <[email protected]>
Merged into master and branch-1.3. Thanks! |
No description provided.