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

📄 dataextractor.cs

📁 利用人工智能算法对财务数据进行分析
💻 CS
字号:
using System;
using System.Data.Linq;

using FinanceAI.AI;
using FinanceAI.Data.Samples;

namespace FinanceAI.Predictor
{  
    class FinancialDataExtractor : IExtractor, IDisposable
    {
        // Connection with the database
        private DataContext dc;

        // Data extracted from the database
        private ClassificationData data = new ClassificationData( );

        public ClassificationData Data
        {
            get
            {
                return data;
            }
        }

        // Initialize the connection with the database
        public void Initialize( string source )
        {
            // TODO: Add checks in the source string
            dc = new DataContext( source );
        }

        // Performance extraction optimizations
        // Must be called explcitly as DatabaseCompanyExtractor, not IExtractor

        // Extract all labeled samples, all features
        public void Extract( SampleSelectorLabeled s, FeatureSelectorAll f )
        {
            throw new NotImplementedException( );
        }

        // Extract all non labeled samples, all features
        public void Extract( SampleSelectorNonLabeled s, FeatureSelectorAll f )
        {
            throw new NotImplementedException( );
        }

        // Extract data with the given generic criteria
        public void Extract( 
            ISampleSelector sampleSelector,
            IFeatureSelector featureSelector )
        {
            // TODO: Change to Q or Y data
            // Get the table of financial data
            Table<QLSample> qlSamples = dc.GetTable<QLSample>( );

            // copy the data to the list of training cases
            data = new ClassificationData( );
            foreach (QLSample sample in qlSamples)
            {
                // Apply the sample selection criteria
                if (sampleSelector.Select( sample ))
                {
                    // Apply the feature selection criteria
                    data.Samples.Add( featureSelector.Select( sample ) );
                }
            }
        }

        // TODO: Remove? We don't want to eliminate an external data context
        public void Dispose( )
        {
            // Close the connection
            dc.Dispose( );
        }
    }
}

⌨️ 快捷键说明

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