Skip to content
Closed
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions examples/src/main/python/ml/dataframe_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

"""
An example of how to use DataFrame for ML. Run with::
bin/spark-submit examples/src/main/python/ml/dataframe_example.py <input>
bin/spark-submit examples/src/main/python/ml/dataframe_example.py <dataset>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change dataset to like .. input_path or path? I think the name dataset is usually used for Dataset instance.

"""
from __future__ import print_function

Expand All @@ -35,18 +35,18 @@
print("Usage: dataframe_example.py <libsvm file>", file=sys.stderr)
sys.exit(-1)
elif len(sys.argv) == 2:
input = sys.argv[1]
dataset = sys.argv[1]
else:
input = "data/mllib/sample_libsvm_data.txt"
dataset = "data/mllib/sample_libsvm_data.txt"

spark = SparkSession \
.builder \
.appName("DataFrameExample") \
.getOrCreate()

# Load input data
print("Loading LIBSVM file with UDT from " + input + ".")
df = spark.read.format("libsvm").load(input).cache()
# Load dataset
print("Loading LIBSVM file with UDT from " + dataset + ".")
df = spark.read.format("libsvm").load(dataset).cache()
print("Schema from LIBSVM:")
df.printSchema()
print("Loaded training data as a DataFrame with " +
Expand Down