Pyspark ALS recommendForAllUsers().first() hangsWhy do people write the #!/usr/bin/env python shebang on the first line of a Python script?How to remove the first Item from a list?importing pyspark in python shellHow to change dataframe column names in pyspark?Convert pyspark string to date formatFiltering a pyspark dataframe using isin by exclusionPySpark: when function with multiple outputsHow to solve Py4JJavaError:calling None.org.apache.spark.api.java.JavaSparkContextPyspark: find first occurrence of maximum valuePyspark hangs on simple command

Why is the battery jumpered to a resistor in this schematic?

Unsolved Problems due to Lack of Computational Power

What does a comma signify in inorganic chemistry?

What if a restaurant suddenly cannot accept credit cards, and the customer has no cash?

Output the list of musical notes

Adding things to bunches of things vs multiplication

Understanding theorem 15.12 in Kosniovski's A first course in algebraic topology

The Lucky House

Can I use images from my published papers in my thesis without copyright infringment?

What was the intention with the Commodore 128?

Number of matrices with bounded products of rows and columns

May the tower use the runway while an emergency aircraft is inbound?

Ending a line of dialogue with "?!": Allowed or obnoxious?

Interaction between Leonin Warleader and Divine Visitation

When does The Truman Show take place?

Build a mob of suspiciously happy lenny faces ( ͡° ͜ʖ ͡°)

Do I need to start off my book by describing the character's "normal world"?

If it isn't [someone's name]!

Photoshop older default brushes

Are there any OR challenges that are similar to kaggle's competitions?

How do I answer an interview question about how to handle a hard deadline I won't be able to meet?

programming a recursive formula into Mathematica and find the nth position in the sequence

Parse a simple key=value config file in C

Have made several mistakes during the course of my PhD. Can't help but feel resentment. Can I get some advice about how to move forward?



Pyspark ALS recommendForAllUsers().first() hangs


Why do people write the #!/usr/bin/env python shebang on the first line of a Python script?How to remove the first Item from a list?importing pyspark in python shellHow to change dataframe column names in pyspark?Convert pyspark string to date formatFiltering a pyspark dataframe using isin by exclusionPySpark: when function with multiple outputsHow to solve Py4JJavaError:calling None.org.apache.spark.api.java.JavaSparkContextPyspark: find first occurrence of maximum valuePyspark hangs on simple command






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I've created an ALS model and called its method .transform(test_data). I now want to view the predictions produced for the data.



userRecs.printSchema() produces:



 |-- ProductID: integer (nullable = false)
|-- recommendations: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- CustomerID: integer (nullable = true)
| | |-- rating: float (nullable = true)


Calling userRecs.first() results in the process hanging at 'Stage 4'



[Stage 4:> (0 + 1) / 1]



Am I handling/reading the data incorrectly? I'm also not sure why calling userRecs.first() requires more processing?



import pandas as pd
from pyspark.ml.evaluation import RegressionEvaluator
from pyspark.ml.recommendation import ALS, ALSModel
from pyspark.ml.tuning import TrainValidationSplit, ParamGridBuilder
from pyspark.context import SparkContext
from pyspark.sql.session import SparkSession
from pyspark.sql.functions import explode

sc = SparkContext('local')
spark = SparkSession(sc)

# load the model
data = pd.read_csv('matric-out-small-SMALL.csv', sep=',')
df = spark.createDataFrame(data)
(training, test) = df.randomSplit([0.8, 0.2]) # seed , 50
model = ALSModel.load("modelSaveOut")

# predict test ata
model.transform(test)

# Generate top 10 recommendations for each user
userRecs = model.recommendForAllUsers(3)

userRecs.printSchema()

userRecs.first()


Additionally, I would like to know if there another way to get the model to provide predictions for just a single data point?
I believe there is a better solution to get a prediction for a certain value)?










share|improve this question






























    0















    I've created an ALS model and called its method .transform(test_data). I now want to view the predictions produced for the data.



    userRecs.printSchema() produces:



     |-- ProductID: integer (nullable = false)
    |-- recommendations: array (nullable = true)
    | |-- element: struct (containsNull = true)
    | | |-- CustomerID: integer (nullable = true)
    | | |-- rating: float (nullable = true)


    Calling userRecs.first() results in the process hanging at 'Stage 4'



    [Stage 4:> (0 + 1) / 1]



    Am I handling/reading the data incorrectly? I'm also not sure why calling userRecs.first() requires more processing?



    import pandas as pd
    from pyspark.ml.evaluation import RegressionEvaluator
    from pyspark.ml.recommendation import ALS, ALSModel
    from pyspark.ml.tuning import TrainValidationSplit, ParamGridBuilder
    from pyspark.context import SparkContext
    from pyspark.sql.session import SparkSession
    from pyspark.sql.functions import explode

    sc = SparkContext('local')
    spark = SparkSession(sc)

    # load the model
    data = pd.read_csv('matric-out-small-SMALL.csv', sep=',')
    df = spark.createDataFrame(data)
    (training, test) = df.randomSplit([0.8, 0.2]) # seed , 50
    model = ALSModel.load("modelSaveOut")

    # predict test ata
    model.transform(test)

    # Generate top 10 recommendations for each user
    userRecs = model.recommendForAllUsers(3)

    userRecs.printSchema()

    userRecs.first()


    Additionally, I would like to know if there another way to get the model to provide predictions for just a single data point?
    I believe there is a better solution to get a prediction for a certain value)?










    share|improve this question


























      0












      0








      0








      I've created an ALS model and called its method .transform(test_data). I now want to view the predictions produced for the data.



      userRecs.printSchema() produces:



       |-- ProductID: integer (nullable = false)
      |-- recommendations: array (nullable = true)
      | |-- element: struct (containsNull = true)
      | | |-- CustomerID: integer (nullable = true)
      | | |-- rating: float (nullable = true)


      Calling userRecs.first() results in the process hanging at 'Stage 4'



      [Stage 4:> (0 + 1) / 1]



      Am I handling/reading the data incorrectly? I'm also not sure why calling userRecs.first() requires more processing?



      import pandas as pd
      from pyspark.ml.evaluation import RegressionEvaluator
      from pyspark.ml.recommendation import ALS, ALSModel
      from pyspark.ml.tuning import TrainValidationSplit, ParamGridBuilder
      from pyspark.context import SparkContext
      from pyspark.sql.session import SparkSession
      from pyspark.sql.functions import explode

      sc = SparkContext('local')
      spark = SparkSession(sc)

      # load the model
      data = pd.read_csv('matric-out-small-SMALL.csv', sep=',')
      df = spark.createDataFrame(data)
      (training, test) = df.randomSplit([0.8, 0.2]) # seed , 50
      model = ALSModel.load("modelSaveOut")

      # predict test ata
      model.transform(test)

      # Generate top 10 recommendations for each user
      userRecs = model.recommendForAllUsers(3)

      userRecs.printSchema()

      userRecs.first()


      Additionally, I would like to know if there another way to get the model to provide predictions for just a single data point?
      I believe there is a better solution to get a prediction for a certain value)?










      share|improve this question














      I've created an ALS model and called its method .transform(test_data). I now want to view the predictions produced for the data.



      userRecs.printSchema() produces:



       |-- ProductID: integer (nullable = false)
      |-- recommendations: array (nullable = true)
      | |-- element: struct (containsNull = true)
      | | |-- CustomerID: integer (nullable = true)
      | | |-- rating: float (nullable = true)


      Calling userRecs.first() results in the process hanging at 'Stage 4'



      [Stage 4:> (0 + 1) / 1]



      Am I handling/reading the data incorrectly? I'm also not sure why calling userRecs.first() requires more processing?



      import pandas as pd
      from pyspark.ml.evaluation import RegressionEvaluator
      from pyspark.ml.recommendation import ALS, ALSModel
      from pyspark.ml.tuning import TrainValidationSplit, ParamGridBuilder
      from pyspark.context import SparkContext
      from pyspark.sql.session import SparkSession
      from pyspark.sql.functions import explode

      sc = SparkContext('local')
      spark = SparkSession(sc)

      # load the model
      data = pd.read_csv('matric-out-small-SMALL.csv', sep=',')
      df = spark.createDataFrame(data)
      (training, test) = df.randomSplit([0.8, 0.2]) # seed , 50
      model = ALSModel.load("modelSaveOut")

      # predict test ata
      model.transform(test)

      # Generate top 10 recommendations for each user
      userRecs = model.recommendForAllUsers(3)

      userRecs.printSchema()

      userRecs.first()


      Additionally, I would like to know if there another way to get the model to provide predictions for just a single data point?
      I believe there is a better solution to get a prediction for a certain value)?







      python apache-spark pyspark pyspark-sql apache-spark-dataset






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 27 at 12:53









      atomsatoms

      2,2111 gold badge12 silver badges25 bronze badges




      2,2111 gold badge12 silver badges25 bronze badges

























          0






          active

          oldest

          votes










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377708%2fpyspark-als-recommendforallusers-first-hangs%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes




          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







          Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55377708%2fpyspark-als-recommendforallusers-first-hangs%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

          Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript