Spark Streaming - 可以对数据流使用离线模型(Spark Streaming - Can an offline model be used against a data stream)
在这个链接--LINK中 ,提到已经离线构建的机器学习模型可以用于对流数据进行测试。
摘自Apache Spark Streaming MLlib链接:
“ 你也可以轻松使用MLlib提供的机器学习算法。首先,有流媒体机器学习算法(例如Streaming Linear Regression,Streaming KMeans等),它们可以同时学习流数据以及应用模型流媒体数据。 除此之外,对于更大类的机器学习算法,您可以离线学习学习模型(即使用历史数据),然后在线应用流数据模型。有关详细信息,请参阅MLlib指南。
这是否意味着可以使用像Spark中构建的Random Forest模型这样的复杂学习模型来测试Spark Streaming程序中的流数据? 它是否像引用已构建的“模型”一样简单,并在Spark Streaming程序中调用“predictOnValues()”?
在这种情况下,现有的火花流机器学习算法(AND)之间的主要区别是这种方法是流式算法将随着时间的推移而演变,而离线(对抗)在线流式方法仍然会使用它的见解早些时候学过没有任何在线学习的可能性?
我做对了吗? 如果我对上述两点的理解是正确的,请告诉我。
In this link - LINK, it is mentioned that a machine learning model which has been constructed offline can be used against streaming data for testing.
Excerpt from the Apache Spark Streaming MLlib link:
" You can also easily use machine learning algorithms provided by MLlib. First of all, there are streaming machine learning algorithms (e.g. Streaming Linear Regression, Streaming KMeans, etc.) which can simultaneously learn from the streaming data as well as apply the model on the streaming data. Beyond these, for a much larger class of machine learning algorithms, you can learn a learning model offline (i.e. using historical data) and then apply the model online on streaming data. See the MLlib guide for more details. "
Does this mean that one can use a complex learning model like Random Forest model built in Spark for testing against streaming data in Spark Streaming program? Is it as simple as referring to the "Model" which has been built and calling "predictOnValues()" over it in Spark Streaming program?
In this case, would the main difference between the existing spark streaming machine learning algorithms (AND) this approach be the fact that the streaming algorithms will evolve over time and the offline(against)online stream approach would still be using the insights from what it had learnt earlier without any possibility of online learning?
Am I getting this right? Please let me know if my understanding for both the points mentioned above is correct.
原文:https://stackoverflow.com/questions/40188693
最满意答案
您应该使用Handler进行此类操作。
让runnable在完成操作后发布消息,然后执行hview.postInvalidate(); 方法调用。
有很多指南如何做到这一点。
一些链接包括: http : //developer.android.com/reference/android/os/Handler.html
http://www.vogella.com/tutorials/AndroidBackgroundProcessing/article.html
You should really use a Handler for this kind of operation.
Have the runnable post a message once it's done with it's operation and then do the hview.postInvalidate(); method call.
There are tons of guides how to do it.
Some links include: http://developer.android.com/reference/android/os/Handler.html
http://www.vogella.com/tutorials/AndroidBackgroundProcessing/article.html
相关问答
更多-
当在“主”线程中发生一些长时间的操作时,会发生ANR。 这是事件循环线程,如果它很忙,Android无法处理应用程序中的任何其他GUI事件,从而抛出ANR对话框。 现在,在你发布的跟踪中,主线程似乎做得很好,没有问题。 它在MessageQueue中空闲,等待另一个消息进来。在您的情况下,ANR可能是更长的操作,而不是永久阻止线程的事情,因此事件线程在操作完成后恢复,并且您的跟踪已经过去在ANR之后。 检测ANR发生的地方如果是永久性块(例如僵尸获取某些锁)是容易的,但如果只是暂时的延迟,则更难。 首先,查 ...
-
将代码移动到runnable后,Android应用程序在没有ANR的情况下冻结(Android app freezes without ANR after moving code into runnable)[2022-12-31]
您应该使用Handler进行此类操作。 让runnable在完成操作后发布消息,然后执行hview.postInvalidate(); 方法调用。 有很多指南如何做到这一点。 一些链接包括: http : //developer.android.com/reference/android/os/Handler.html http://androidexample.com/Thread_With_Handlers_-_Android_Example/index.php?view=article_discrip ... -
看起来像带有layout_height="wrap_content" NestedScrollView会破坏子级RecyclerViews所有优化。 无论来自具有layout_height="match_parent"的父视图( SwipeRefreshLayout )的约束如何,它都为它们提供了无限空间。 因此, RecyclerView会立即为适配器中的所有模型创建视图持有者。 记录显示,它们每个需要20-60ms才能为100行带来2-5秒滞后。 我们将记录添加到onCreateViewHolder() ...
-
RuntimeException导致ANR而不是在android中崩溃(RuntimeException causes ANR instead of crash in android)[2022-07-29]
我面临着同样的问题,当我在调试时遇到代码“抛出RuntimeException”,但我也有一个ANR。 我拥有的唯一线索是它在我的应用程序中配置Google Analytics时开始发生。 这是你的情况吗,@ Alpha? 我没有超越,因为我有点像这样处理,但有一天我会用分析专门为这个问题进行调试。 编辑:该问题已在Google Play Services 8.4中解决。 我们终于可以报告未捕获的异常! 该应用程序似乎被阻止了几秒钟,但最终抛出异常并报告没有ANR。 I am facing the same ... -
What is this leaked window? 您的案例中出现WindowLeaked exception是因为您在完成活动之前未MyProgressDialog 。 因此它泄漏了与之相关的内存。 一般情况: WindowLeaked exception通常发生在当某些异步任务在开始它的活动被完成之后完成时发生。这种类型的异常主要发生在Dialogs ,在活动上下文之前我们没有关闭对话框销毁。 因此,最好在显示对话框之前进行检查,如下所示: if(getActivity()!= null && ...
-
为什么bindservice在将其移动到工作线程后仍会导致应用ANR(why bindservice still causes app ANR after moving it to a worker thread)[2022-06-09]
根据您的描述,似乎在UI线程内调用bindService不是ANR的根本原因。 您应该调用bindService而不生成用户线程。 一个主要原因是,这会导致内存泄漏。 当配置发生变化时,只要线程仍处于活动状态,它就不会给Activity执行垃圾收集的机会。 这是因为您的用户线程仍然保持对Activity引用。 ANR根本原因应来自Recognizer或mConnection 。 如果您可以发布它们的实施细节,这可以帮助我们帮助您。 问自己以下问题 您是否在mConnection的onServiceConne ... -
由com.google.android.gms.DynamiteModules引起的ANR(ANR caused by com.google.android.gms.DynamiteModules)[2022-12-11]
我使用与Firebase和Google Play服务完全相同的ANR。 我在升级到Google Play Services 9.0.0,App Hangs in DynamiteModulesC中的答案解决了我的问题 - 删除了常规播放服务,只包含了您需要的特定播放服务库。 I had the exact same ANR as you using Firebase and Google Play Services. I solved my problem with the answer in After ... -
这个Runnable怎么能在这里阻止UI线程? Runnable没有阻塞主应用程序线程(又名“UI线程”)。 onSensorChanged()阻塞了主应用程序线程,因为在主应用程序线程上调用onSensorChanged() ,因此您在主应用程序线程上执行磁盘I / O. How could this Runnable be blocking the UI thread here? The Runnable is not blocking the main application thread (a.k. ...
-
这似乎是游戏服务9+的问题。 我的第一个解决方法是回滚游戏服务到8.4.0,一切都恢复正常。 我一直在寻找解决方案,因为上面的内容并不能让我满意 我发现问题是具体的'通用游戏服务',我不明白为什么它适用于8.4.0而不是9+。 我的解决方案是删除下面的行 compile "com.google.android.gms:play-services:9.0.2" 并保持具体(这是最好的方式,无论问题有多少) compile "com.google.android.gms:play-services-analy ...
-
ANR(应用程序无响应)意味着您要锁定UI线程太长时间。 通常,这意味着您要在UI线程上进行网络调用或类似的事情。 Well don't I feel like a git this is the cause: at au.com.shiftyjelly.pocketcasts.server.x.onPostExecute(SourceFile:1) at android.os.AsyncTask.finish(AsyncTask.java:417) So everything is asynchr ...