🎉 🎉 RAPIDMINER 9.10 IS OUT!!! 🎉🎉

Download the latest version helping analytics teams accelerate time-to-value for streaming and IIOT use cases.

CLICK HERE TO DOWNLOAD

"Write.csv operator saves integer values as float.."

Fred12Fred12 Member Posts: 344   Unicorn
edited June 2019 in Help

hi,

When I save a dataset with the write.csv operator, it stores integer numbers with a ".0" at the end, as float number so to say.. but I need to upload them as integer, is there a way to avoid that type of formatting?

otherwise, I always have to reformat the files in R, its quick but somehow still annoying..

Tagged:

Best Answers

  • SGolbertSGolbert RapidMiner Certified Analyst, Member Posts: 344   Unicorn
    Solution Accepted

    Hi Fred,

     

    I have found a workaround: Convert all integer attributes to polynominal before writing the CSV, using the Numerical to Polynominal operator with the "quote nominal values" option unticked. 

     

    Although it is probably better just to specify the format in R, because you may have to do it anyways (the default values for read.table() rarely do what you want).

     

    Best,

    Sebastian

    sgenzer
  • Telcontar120Telcontar120 Moderator, RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 1,625   Unicorn
    Solution Accepted

    You can also use "Format Numbers" operator and specify the exact pattern you need (it will also convert numerical to nominal as part of its work).  I have to do that all the time when preparing datasets for Kaggle competition submissions, for example.

    Brian T.
    Lindon Ventures 
    Data Science Consulting from Certified RapidMiner Experts
    gabriela_sanche
  • sgenzersgenzer 12Administrator, Moderator, Employee, RapidMiner Certified Analyst, Community Manager, Member, University Professor, PM Moderator Posts: 2,959  Community Manager
    Solution Accepted

    sure that works fine.  I cheat and just convert the integer attributes to polynominals and then export (unchecking the quote nominal values box).  The csv does not know the difference.  :)

     

    <?xml version="1.0" encoding="UTF-8"?><process version="7.6.001">
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="7.6.001" expanded="true" name="Process">
    <process expanded="true">
    <operator activated="true" class="generate_data" compatibility="7.6.001" expanded="true" height="68" name="Generate Data" width="90" x="45" y="34">
    <parameter key="number_of_attributes" value="1"/>
    </operator>
    <operator activated="true" class="generate_attributes" compatibility="7.6.001" expanded="true" height="82" name="Generate Attributes" width="90" x="179" y="34">
    <list key="function_descriptions">
    <parameter key="integers" value="rint(att1)"/>
    </list>
    </operator>
    <operator activated="true" class="numerical_to_polynominal" compatibility="7.6.001" expanded="true" height="82" name="Numerical to Polynominal" width="90" x="313" y="34">
    <parameter key="attribute_filter_type" value="single"/>
    <parameter key="attribute" value="integers"/>
    </operator>
    <operator activated="true" class="write_csv" compatibility="7.6.001" expanded="true" height="82" name="Write CSV" width="90" x="447" y="34">
    <parameter key="csv_file" value="/Users/sgenzer/Desktop/foo.csv"/>
    <parameter key="column_separator" value=","/>
    <parameter key="quote_nominal_values" value="false"/>
    </operator>
    <connect from_op="Generate Data" from_port="output" to_op="Generate Attributes" to_port="example set input"/>
    <connect from_op="Generate Attributes" from_port="example set output" to_op="Numerical to Polynominal" to_port="example set input"/>
    <connect from_op="Numerical to Polynominal" from_port="example set output" to_op="Write CSV" to_port="input"/>
    <connect from_op="Write CSV" from_port="through" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>

     

    Scott

     

Sign In or Register to comment.