Scikit中截断的SVD-learn:如何获取输出数据?

时间:2017-06-27 17:35:09

标签: python scikit-learn svd

我正在尝试使用 Scikit-learn 中的df_SVD来减少数据框中的列数。

下面的代码运行但我不知道如何访问转换后的数据帧。

我的原始数据框称为df_SVD,其形状为(8844,1159)。当我运行下面的代码并在转换后查找svd=TruncatedSVD(n_components=20, n_iter=10) svd.fit_transform(df_SVD) df_SVD.head() df_SVD.shape df_SVD_new.shape 的形状时,形状保持不变。

      <thead id="table_row">
            <tr id="h_td">

                <th></th>
                <th>product 2</th>
                <th>product 3</th>
                <th>product 2</th>
                <th><a href="#" id="add_table">add</a></th>
            </tr>

      </thead>
      <tbody id="pro_table">    
            <tr class="visible-xs " aria-hidden="true" id="collapse" >                   
              <td colspan="5" >Fature 1</td>
            </tr>
              <tr  id="h_td">
                <td>Fature 1</td>
              </tr>
            <tr class="visible-xs" aria-hidden="true" id="collapse">
              <td colspan="5">Fature 2</td>
            </tr>
              <tr id="h_td">
                <td>Fature 2</td>
              </tr>
            <tr class="visible-xs" aria-hidden="true" id="collapse">                    
              <td colspan="5">Fature 3</td>
            </tr>  
              <tr id="h_td">
                <td>Fature 3</td>
              </tr>
            <tr class="visible-xs" aria-hidden="true" id="collapse">

              <td colspan="5">Fature 4</td>
            </tr>  
              <tr id="h_td">
                <td>Fature 4</td>
              </tr>

      </tbody>


    <?php 
            $con = mysqli_connect("localhost","root","","COMPARES");
            $b_title = array();
            $sql="SELECT * from brands";
            $run=mysqli_query($con,$sql);
            $num_row=mysqli_num_rows($run);
            while($row=mysqli_fetch_assoc($run)){
            $rows[] = $row;
                foreach($rows as $row){
                    $b_title =$row['brand_id'];
                    $b_title =$row['brand_title'];

                $data =' '.$b_title.' ';

                }
            }

    ?>


    <script type="text/javascript">
                var tables = document.getElementsByTagName('tbody');
                var table = tables[tables.length - 1];
                var rows = table.rows;
                for(var i = 0, td; i < rows.length; i++ ){                      
                    td = document.createElement('td');
                    td.appendChild(document.createTextNode("<?php echo data ?>"));
                    rows[i].insertBefore(td, rows[i].lastChild);
                }
    </script>

0 个答案:

没有答案