【问题标题】:execution time of the algorithm to build model建立模型的算法的执行时间
【发布时间】:2020-11-28 09:57:22
【问题描述】:

我想知道构建模型所需的时间。但是,当多次运行算法来构建模型时,我花了很多时间来构建模型。为什么不一样?为什么不花费恒定的时间来构建模型?即使同一算法所用的时间有所波动,我如何比较两种不同算法所用的时间。

Double start_time=System.nanoTime()/Math.pow(10, 9);                     
KMeansModel clusters = KMeans.train(rdd.rdd(), numClusters,numIterations,init_mode,30);        
System.out.println("time taken to build model: "+((System.nanoTime()/Math.pow(10, 9)) - start_time));

【问题讨论】:

    标签: time execution


    【解决方案1】:

    您可以将模型训练时间测量为多次运行的平均值。例如。运行训练 100 次并花费总时间 / 100。这应该在运行之间提供更一致的值(作为一个批次),假设算法在训练期间不使用太多随机性。

    如果您使用的是 spark,启用 spark 的 loginfo 以查看每次运行的统计信息可能会很有用。对于 kmeans,您应该看到:

    logInfo(f"Initialization with $initializationMode took $initTimeInSeconds%.3f seconds.")
    logInfo(f"Iterations took $iterationTimeInSeconds%.3f seconds.")
    logInfo(s"KMeans converged in $iteration iterations.")
    

    【讨论】:

      猜你喜欢
      • 2010-10-31
      • 2021-06-21
      • 2012-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-04
      • 2018-10-31
      • 1970-01-01
      相关资源
      最近更新 更多