首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Rapidminer中神经网络输出的约束

Rapidminer中神经网络输出的约束
EN

Stack Overflow用户
提问于 2017-02-26 12:50:46
回答 2查看 376关注 0票数 0

我在Rapidminer中开发了一个简单的神经网络模型来预测每小时在高速公路上行驶的汽车数量。很明显,在清晨(从凌晨2点到早上6点),高速公路上很少有汽车,有时我的模型预测汽车数量为负数(比如-2或-3),这在统计学上是可以理解的,但当你想在某个地方报告时,这是不酷的。

我正在寻找一种对模型施加约束的方法,以便它只能预测正数。我怎么能这么做?

谢谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-03-02 20:35:47

它总是取决于数据和你想要做什么,但是一种方法是把数字转换成多项式。所以0变成字符串"0",1变成"1“等等。这迫使神经网络仅使用可用的值。

下面是一个使用虚拟数据的示例过程。

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?><process version="7.3.001">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.3.001" expanded="true" name="Process">
    <process expanded="true">
      <operator activated="true" class="subprocess" compatibility="7.3.001" expanded="true" height="82" name="Subprocess" width="90" x="246" y="34">
        <process expanded="true">
          <operator activated="true" class="generate_data" compatibility="7.3.001" expanded="true" height="68" name="Generate Data" width="90" x="45" y="34">
            <parameter key="target_function" value="polynomial"/>
            <parameter key="attributes_lower_bound" value="0.0"/>
            <parameter key="attributes_upper_bound" value="3.0"/>
          </operator>
          <operator activated="true" class="normalize" compatibility="7.3.001" expanded="true" height="103" name="Normalize" width="90" x="179" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="label"/>
            <parameter key="include_special_attributes" value="true"/>
            <parameter key="method" value="range transformation"/>
            <parameter key="max" value="4.99"/>
          </operator>
          <operator activated="true" class="real_to_integer" compatibility="7.3.001" expanded="true" height="82" name="Real to Integer" width="90" x="313" y="34">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="label"/>
            <parameter key="include_special_attributes" value="true"/>
          </operator>
          <connect from_op="Generate Data" from_port="output" to_op="Normalize" to_port="example set input"/>
          <connect from_op="Normalize" from_port="example set output" to_op="Real to Integer" to_port="example set input"/>
          <connect from_op="Real to Integer" from_port="example set output" to_port="out 1"/>
          <portSpacing port="source_in 1" spacing="0"/>
          <portSpacing port="sink_out 1" spacing="0"/>
          <portSpacing port="sink_out 2" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="numerical_to_polynominal" compatibility="7.3.001" expanded="true" height="82" name="Numerical to Polynominal" width="90" x="380" y="34">
        <parameter key="attribute_filter_type" value="single"/>
        <parameter key="attribute" value="label"/>
        <parameter key="include_special_attributes" value="true"/>
      </operator>
      <operator activated="true" class="concurrency:cross_validation" compatibility="7.3.001" expanded="true" height="145" name="Validation" width="90" x="514" y="34">
        <parameter key="sampling_type" value="shuffled sampling"/>
        <process expanded="true">
          <operator activated="true" class="neural_net" compatibility="7.3.001" expanded="true" height="82" name="Neural Net" width="90" x="323" y="34">
            <list key="hidden_layers"/>
          </operator>
          <connect from_port="training set" to_op="Neural Net" to_port="training set"/>
          <connect from_op="Neural Net" from_port="model" to_port="model"/>
          <portSpacing port="source_training set" spacing="0"/>
          <portSpacing port="sink_model" spacing="0"/>
          <portSpacing port="sink_through 1" spacing="0"/>
        </process>
        <process expanded="true">
          <operator activated="true" class="apply_model" compatibility="7.3.001" expanded="true" height="82" name="Apply Model" width="90" x="45" y="34">
            <list key="application_parameters"/>
          </operator>
          <operator activated="true" class="performance" compatibility="7.3.001" expanded="true" height="82" name="Performance" width="90" x="179" y="34"/>
          <connect from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
          <connect from_op="Performance" from_port="performance" to_port="performance 1"/>
          <connect from_op="Performance" from_port="example set" to_port="test set results"/>
          <portSpacing port="source_model" spacing="0"/>
          <portSpacing port="source_test set" spacing="0"/>
          <portSpacing port="source_through 1" spacing="0"/>
          <portSpacing port="sink_test set results" spacing="0"/>
          <portSpacing port="sink_performance 1" spacing="0"/>
          <portSpacing port="sink_performance 2" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="nominal_to_numerical" compatibility="7.3.001" expanded="true" height="103" name="Nominal to Numerical (2)" width="90" x="715" y="136">
        <parameter key="attribute_filter_type" value="subset"/>
        <parameter key="attribute" value="label"/>
        <parameter key="attributes" value="prediction(label)|label"/>
        <parameter key="include_special_attributes" value="true"/>
        <parameter key="coding_type" value="unique integers"/>
        <list key="comparison_groups"/>
      </operator>
      <connect from_op="Subprocess" from_port="out 1" to_op="Numerical to Polynominal" to_port="example set input"/>
      <connect from_op="Numerical to Polynominal" from_port="example set output" to_op="Validation" to_port="example set"/>
      <connect from_op="Validation" from_port="model" to_port="result 1"/>
      <connect from_op="Validation" from_port="example set" to_port="result 2"/>
      <connect from_op="Validation" from_port="test result set" to_op="Nominal to Numerical (2)" to_port="example set input"/>
      <connect from_op="Validation" from_port="performance 1" to_port="result 4"/>
      <connect from_op="Nominal to Numerical (2)" from_port="example set output" to_port="result 3"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
      <portSpacing port="sink_result 3" spacing="0"/>
      <portSpacing port="sink_result 4" spacing="0"/>
      <portSpacing port="sink_result 5" spacing="0"/>
    </process>
  </operator>
</process>

它生成虚拟数据,并将数值转换为多项式。Cross Validation的预测示例集输出包含多项式,并将这些多项式转换为数字。

不用说,这可能不适合你想要的,但这是一个开始。

安德鲁

票数 1
EN

Stack Overflow用户

发布于 2017-03-02 01:10:42

您已经重新调整了您的神经网络参数,否则您就无法访问RapidMiner中算法的细节。另一个想法是在神经网络模型之后使用阈值算子,这样你就可以改变决策的边界,这样它就能比现在更少地预测负面。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42468738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档