Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. amount gender_num marital_num
  2. 10000 1 1
  3. 20000 1 2
  4. 1400 2 1
  5.  
  6. val df1 = df("loan_amount", 'loan_amount.cast("Double")).withColumn("gender_num", 'gender_num.cast("String")).
  7. withColumn("marital_num", 'marital_num.cast("String"))
  8.  
  9. val labeled = df1.map(row => LabeledPoint(df1.gender_num, Vectors.dense(df1.loan_amount, df1.marital_num)))
  10.  
  11. val numClasses = 7
  12. val categoricalFeaturesInfo = Map[Int, Int]()
  13. val numTrees = 3 // Use more in practice.
  14. val featureSubsetStrategy = "auto" // Let the algorithm choose.
  15. val impurity = "gini"
  16. val maxDepth = 4
  17. val maxBins = 32
  18.  
  19. val model = RandomForest.trainClassifier(labeled, categoricalFeaturesInfo,
  20. numTrees, featureSubsetStrategy, impurity, maxDepth, maxBins)
  21.  
  22. 138: error: value gender_num is not a member of org.apache.spark.sql.DataFrame
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement