我使用scikit-learn Multinomial Naive Bayes分类器进行二进制文本分类(分类器告诉我文档是否属于X类).我使用平衡数据集训练我的模型和平衡测试集来测试它,结果很有希望.
该分类器需要实时运行并不断分析随机抛出的文档.
但是,当我在生产中运行我的分类器时,误报的数量非常高,因此我的精度非常低.原因很简单:在实时场景中(大约90%的时间),分类器会遇到更多负面样本,这与我用于测试和培训的理想平衡数据集不对应.
有没有办法可以在训练期间模拟这个实时案例,或者我可以使用任何技巧(包括对文档进行预处理以查看它们是否适合于分类器)?
我计划使用不平衡的数据集来训练我的分类器,其比例与我在实时案例中的比例相同,但我担心这可能会使朴素贝叶斯偏向负面阶级而失去对正面课程的回忆.
任何建议表示赞赏.
python classification machine-learning scikit-learn text-classification
我在Matlab中有一个Epoch毫秒数组(数组).我想将它们转换为UTC日期时间格式,例如DD-MM-YYYY HH:MM.
是否有预先定义的Matlab方法来执行此操作,还是必须编写自己的函数?
我使用WEKA gui训练并创建了一个J48模型.我将模型文件保存到我的计算机上,现在我想用它来分类我的Java代码中的单个实例.我想获得属性"cluster"的预测.我所做的是以下内容:
public void classify(double lat, double lon, double co)
{
// Create attributes to be used with classifiers
Attribute latitude = new Attribute("latitude");
Attribute longitude = new Attribute("longitude");
Attribute carbonmonoxide = new Attribute("co");
// Create instances for each pollutant with attribute values latitude, longitude and pollutant itself
inst_co = new DenseInstance(4);
// Set instance's values for the attributes "latitude", "longitude", and "pollutant concentration"
inst_co.setValue(latitude, lat);
inst_co.setValue(longitude, lon);
inst_co.setValue(carbonmonoxide, co);
inst_co.setMissing(cluster);
Classifier cls_co = (Classifier) weka.core.SerializationHelper.read("/CO_J48Model.model");//load classifier from file
// …Run Code Online (Sandbox Code Playgroud) classification machine-learning prediction decision-tree weka
我正在为Android制作计算器应用程序,并且用户要求使用衍生计算器.是否有预加载功能或自定义方法?谢谢.
我使用以下代码在我的PC应用程序上序列化HashMap:
private void serialize(HashMap<Integer, Integer> map2write, String name_ser)
{// serializes fphlist into .ser file called name_ser
FileOutputStream fileOut = null;
try {
fileOut = new FileOutputStream(project_dir + "/" + name_ser + ".ser");
} catch (FileNotFoundException ex) {
Logger.getLogger(AdminConsoleUI.class.getName()).log(Level.SEVERE, null, ex);
}
ObjectOutputStream out;
try {
out = new ObjectOutputStream(fileOut);
out.writeObject(map2write);
out.reset();
out.flush();
out.close();
fileOut.close();
} catch (IOException ex) {
Logger.getLogger(AdminConsoleUI.class.getName()).log(Level.SEVERE, null, ex);
}
}
Run Code Online (Sandbox Code Playgroud)
然后我使用以下代码在我的Android应用程序中对其进行反序列化:
private HashMap<Integer,Integer> deserialize_Map(String fn)
{// deserializes fn into HashMap
HashMap<Integer,Integer> hm = new HashMap<Integer,Integer>();
try …Run Code Online (Sandbox Code Playgroud) private void setFPAlarm()
{
Intent intent = new Intent(this, FPService.class);
PendingIntent pi = PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
long nextSearchTimeMillis = DateUtils.MINUTE_IN_MILLIS/2;
Time nextSearchTime = new Time();
nextSearchTime.set(nextSearchTimeMillis);
AlarmManager FPAlarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
FPAlarm.setRepeating(AlarmManager.RTC, System.currentTimeMillis(), nextSearchTimeMillis, pi);
}
Run Code Online (Sandbox Code Playgroud)
我使用上面的代码每30秒运行一次我的IntentService.有时,服务过程需要超过30秒,因此另一个必须在前一个完成之前启动.我想知道在那种情况下前一个会发生什么.它被搁置了吗?第二个是否等待前一个完成?
我的第二个问题是:我不希望他们互相等待.我想要两个服务同时运行.因此,无论前一个服务在做什么,都应该开始下一个服务.以上代码是实现这一目标的正确方法吗?
我正在使用java.util HashMap的OOM问题所以我正在寻找标准Java Hashmap的内存友好HashMap替代品.我尝试了Trove并且它有所改进,但仍然不时地与OOM结束.如果内存有效,我可以适应一些速度损失.
我不是在找DB.只要它们脱机工作,基于文件的HashMap实现也很好.我正在存储像int和byte这样的原语.
此外,请说明您是否有任何经验以及您在记忆方面的改进程度.
通常情况下,我有一个更技术性的问题,但我会用一个计数球的例子为你简化它.
假设我有不同颜色的球和为每种颜色保留的阵列的一个索引(初始化为全0).每次我选球时,我都会将相应的索引增加1.
球是随机挑选的,我一次只能挑一个球.我唯一的目的是计算每种颜色的球数,直到我用完球.
我想计算不同颜色的球数的标准偏差,而我正在计算它们.在完成对所有球的计数之后,我不想再次遍历数组来计算它.
想象:
球以随机顺序:( BBGRRYYBBGGGGGGB每个字母代表一种颜色的第一个字母)从0到3的数组索引分别对应于颜色B,G,R和Y. 当我完成拾球时,我的阵列看起来像[5,7,2,2].
在得到最终数组后计算标准偏差非常简单,但我想在填充此数组时这样做.
我想用Java做,我有大约1000种颜色.
实现这一目标的最有效方法是什么?或者在掌握最终阵列之前是否有办法做到这一点?
java algorithm statistics standard-deviation online-algorithm
android ×4
java ×4
hashmap ×2
alarmmanager ×1
algorithm ×1
concurrency ×1
derivative ×1
epoch ×1
matlab ×1
prediction ×1
python ×1
scikit-learn ×1
service ×1
statistics ×1
utc ×1
weka ×1