⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datareader.cs

📁 Computational Intelligence IRIS dataset Classification
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CIProject
{
    class DataReader
    {
        public static void ReadData(String fileName,
            int rowCount,
            int columnCount,
            ref Double[][] result,
            ref Double[] target)
        {
            String[] row = null;
            /*result = new double[rowCount][];
            target = new double[rowCount];
            for (int i = 0; i < rowCount; i++)
            {
                result[i] = new double[columnCount - 1];
            }*/
            System.IO.StreamReader streamReader = new StreamReader(fileName);
            for(int i = 0; i < rowCount; i++)
            {
                row = streamReader.ReadLine().Split(" ".ToCharArray());
                for (int j = 0; j < columnCount-1; j++)
                {
                    result[i][j] = Double.Parse(row[j]);
                }
                target[i] = Double.Parse(row[columnCount - 1]);
            }
            streamReader.Close();
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -