# Problem with unbalanced data with examples attached

**URL:** <https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227>\
**Category:** KNIME Analytics Platform\
**Created:** [August 19, 2020, 8:50pm UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227 "2020-08-19T20:50:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tw349](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@tw349](https://forum.knime.com/u/tw349)\
**Post date:** [August 19, 2020, 8:50pm UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227/1 "2020-08-19T20:50:33Z")

</div>

I am having a real problem with unbalanced data. Model ends with good scores (i.e. “accuracy”), but essentially all the the prediction models do is “put all chips on black” and the ones that are actually white are just “wrong classified”.

I tried 3 different predictor models and SMOTE and Row Sampling but no luck?!?

Anyone have any ideas or suggestions for very unbalanced data?

Thank you in advance!

I will attach workflow and database in next posts.

---

<div class="post-metadata">

**Author:** ![tw349](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@tw349](https://forum.knime.com/u/tw349)\
**Post date:** [August 19, 2020, 9:01pm UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227/2 "2020-08-19T21:01:45Z")

</div>

See workflow.

[https://drive.google.com/file/d/1wrUzVHJZRY\_SoM9xTnfblOzmxoVWKGSm/view?usp=sharing](https://drive.google.com/file/d/1wrUzVHJZRY_SoM9xTnfblOzmxoVWKGSm/view?usp=sharing)

See database:

> **[Boston Fire Proof houses](https://docs.google.com/spreadsheets/d/1RiK7P35eZZil-2yrRYpmmO_slwEp2CPQoRcO32WZic4/edit?usp=sharing)**
>
> Boston Fire Proof...

---

<div class="post-metadata">

**Author:** ![tw349](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/t/a4c791/32.png) [@tw349](https://forum.knime.com/u/tw349)\
**Post date:** [August 19, 2020, 9:08pm UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227/3 "2020-08-19T21:08:49Z")

</div>

I put the workflow on the Knime public hub at:

> **[UnbalancedData1 – tw349](https://hub.knime.com/tw349/spaces/Public/latest/UnbalancedData1)**
>
> The place to find and collaborate on KNIME workflows and nodes. Here you can find solutions for your data science questions.

You can also go to public hub and search for: UnbalancedData1

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [August 19, 2020, 9:58pm UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227/4 "2020-08-19T21:58:47Z")

</div>

You could try these things.

Read this article about imbalanced data

> **[Tour of Evaluation Metrics for Imbalanced Classification](https://machinelearningmastery.com/tour-of-evaluation-metrics-for-imbalanced-classification/)**
>
> A classifier is only as good as the metric used to evaluate it. If you choose the wrong metric to evaluate your models, you are likely to choose a poor model, or in the worst case, be misled about the expected performance of your model. Choosing an...

Use the h2o auto-machine learning approach with knime wrapper

> **[H2O.ai AutoML (wrapped with R) in KNIME for classification problems – mlauber71](https://hub.knime.com/mlauber71/spaces/Public/latest/automl/kn_automl_h2o_classification_r)**
>
> H2O.ai AutoML (wrapped with R) in KNIME for classification problems - a powerful auto-machine-learning framework https://hub.knime.com/mlauber71/spaces/Public/…

and choose AUCPR as sort metric  
[http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/sort\_metric.html](http://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/sort_metric.html)

Also you could try and tell the algorithm to use balanced data. You might have to be careful with that and only balance your training data, not the validation data  
[https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/balance\_classes.html](https://docs.h2o.ai/h2o/latest-stable/h2o-docs/data-science/algo-params/balance_classes.html)

See if H2O comes up with a good cutoff point.

In addition you could try R vtreat and tell it which one is the positive class and see if this in combination with other measures is of any help.

> **[H2O.ai AutoML (wrapped with R) with vtreat data preparation in KNIME for...](https://hub.knime.com/mlauber71/spaces/Public/latest/automl/kn_automl_h2o_classification_r_vtreat)**
>
> H2O.ai AutoML (wrapped with R) with vtreat data preparation in KNIME for classification problems (with R vtreat) - a powerful auto-machine-learning framework (…

I will see if I can put together an ‘unbalanced’ version of my H2O.ai automl wrapper.

---

<div class="post-metadata">

**Author:** ![beginner](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://forum.knime.com/u/beginner)\
**Post date:** [August 20, 2020, 6:02am UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227/5 "2020-08-20T06:02:23Z")

</div>

Some comments:

1. Data needs some cleaning and data preparation (different spellings for same thing)
2. Why are you converting the number fields to string?
3. Explanation of features? Hard to tell why you choose some and not others. Unclear manual feature selection
4. SMOTE is crap, don’t use it
5. Try xgboost with scale\_pos\_weight

Some data simply doesn’t have a good signal which makes a lot of sense here. Fire simply has a very high random aspect to it. Still, depending on what the models goal is, a poor model can still be of some help (reduced risk).

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [February 18, 2021, 6:02pm UTC](https://forum.knime.com/t/problem-with-unbalanced-data-with-examples-attached/26227/6 "2021-02-18T18:02:25Z")

</div>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.
