Changeset 2285 for trunk/tools
- Timestamp:
- 08/13/09 17:28:07 (15 years ago)
- Location:
- trunk/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/CedmaDatabaseMerger/CedmaDatabaseMerger.csproj
r2277 r2285 30 30 <ErrorReport>prompt</ErrorReport> 31 31 <WarningLevel>4</WarningLevel> 32 </PropertyGroup> 33 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> 34 <DebugSymbols>true</DebugSymbols> 35 <OutputPath>bin\x86\Debug\</OutputPath> 36 <DefineConstants>DEBUG;TRACE</DefineConstants> 37 <DebugType>full</DebugType> 38 <PlatformTarget>x86</PlatformTarget> 39 <ErrorReport>prompt</ErrorReport> 40 </PropertyGroup> 41 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> 42 <OutputPath>bin\x86\Release\</OutputPath> 43 <DefineConstants>TRACE</DefineConstants> 44 <Optimize>true</Optimize> 45 <DebugType>pdbonly</DebugType> 46 <PlatformTarget>x86</PlatformTarget> 47 <ErrorReport>prompt</ErrorReport> 32 48 </PropertyGroup> 33 49 <ItemGroup> -
trunk/tools/CedmaDatabaseMerger/MergerForm.cs
r2277 r2285 49 49 importButton.Enabled = false; 50 50 BackgroundWorker worker = new BackgroundWorker(); 51 worker.WorkerReportsProgress = true; 51 52 worker.DoWork += CreateDoWorkDelegate(worker, importFileName); 52 53 worker.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged); … … 70 71 DatabaseService sourceDatabase = new DatabaseService("Data Source=" + importFileName); 71 72 73 sourceDatabase.Connect(); 72 74 var models = sourceDatabase.GetAllModels(); 75 var sourceDataset = sourceDatabase.GetDataset(); 73 76 int importCount = 0; 74 77 foreach (HeuristicLab.Modeling.Database.IModel m in models) { 75 HeuristicLab.Modeling.Model model = new HeuristicLab.Modeling.Model(); 78 79 HeuristicLab.Modeling.IAnalyzerModel model = new AnalyzerModel(); 80 model.Predictor = (HeuristicLab.Modeling.IPredictor)PersistenceManager.RestoreFromGZip(sourceDatabase.GetModelData(m)); 76 81 model.TargetVariable = m.TargetVariable.Name; 77 model.Data = (IItem)PersistenceManager.RestoreFromGZip(sourceDatabase.GetModelData(m)); 78 model.Dataset = sourceDatabase.GetDataset(); 82 model.Dataset = sourceDataset; 79 83 model.TrainingSamplesStart = m.TrainingSamplesStart; 80 84 model.TrainingSamplesEnd = m.TrainingSamplesEnd; … … 83 87 model.TestSamplesStart = m.TestSamplesStart; 84 88 model.TestSamplesEnd = m.TestSamplesEnd; 89 model.Predictor.Predict(sourceDataset, 10, 20); 85 90 //get all double properties to save as modelResult 86 91 IEnumerable<PropertyInfo> modelResultInfos = model.GetType().GetProperties().Where( … … 88 93 var modelResults = sourceDatabase.GetModelResults(m); 89 94 foreach (IModelResult result in modelResults) { 90 PropertyInfo matchingPropInfo = modelResultInfos.First(x =>x.Name == result.Result.Name);91 if (matchingPropInfo!=null) matchingPropInfo.SetValue(model, result.Value, null);95 PropertyInfo matchingPropInfo = modelResultInfos.First(x => x.Name == result.Result.Name); 96 if (matchingPropInfo != null) matchingPropInfo.SetValue(model, result.Value, null); 92 97 } 93 98 var inputVariableResults = sourceDatabase.GetInputVariableResults(m); 94 99 foreach (IInputVariableResult result in inputVariableResults) { 95 model.AddInputVariable s(result.Variable.Name);100 model.AddInputVariable(result.Variable.Name); 96 101 if (result.Result.Name == "VariableEvaluationImpact") { 97 102 model.SetVariableEvaluationImpact(result.Variable.Name, result.Value); … … 100 105 } else throw new FormatException(); 101 106 } 102 107 103 108 destiationDatabase.Persist(model, m.Algorithm.Name, m.Algorithm.Description); 104 109 worker.ReportProgress((++importCount * 100) / models.Count()); 105 110 } 111 sourceDatabase.Disconnect(); 106 112 }; 107 113 } -
trunk/tools/CedmaImporter/Importer.cs
r2277 r2285 9 9 using HeuristicLab.GP.StructureIdentification; 10 10 using System.Diagnostics; 11 using HeuristicLab.Modeling; 11 12 12 13 namespace CedmaImporter { … … 62 63 ImportAllModels(dirName, reader, database); 63 64 } 65 database.Disconnect(); 64 66 } 65 67 … … 90 92 string algoName = modelData[ALGORITHM_COLUMN].Trim(); 91 93 try { 92 HeuristicLab.Modeling. Model model = new HeuristicLab.Modeling.Model();94 HeuristicLab.Modeling.IAnalyzerModel model = new AnalyzerModel(); 93 95 model.TargetVariable = targetVariableName; 94 96 model.Dataset = problem.Dataset; … … 100 102 model.TestSamplesEnd = problem.TestSamplesEnd; 101 103 102 103 model.Data = ParseModel(dirName, modelData[FILENAME_COLUMN].Trim(), algoName);104 105 104 SetModelResults(model, modelData); 106 105 SetInputVariableResults(model, modelData); 107 106 107 model.Predictor = CreatePredictor(targetVariableName, dirName, modelData[FILENAME_COLUMN].Trim(), algoName); 108 108 database.Persist(model, algoName, null); 109 109 } … … 113 113 } 114 114 115 private void SetInputVariableResults(HeuristicLab.Modeling. Model model, string[] modelData) {115 private void SetInputVariableResults(HeuristicLab.Modeling.IAnalyzerModel model, string[] modelData) { 116 116 for (int i = VARIABLE_IMPACTS; i < modelData.Length; i++) { 117 117 if (!string.IsNullOrEmpty(modelData[i])) { 118 model.AddInputVariable s(inputVariables[i]);118 model.AddInputVariable(inputVariables[i]); 119 119 if (results[i] == EVALUATION_IMPACT) { 120 120 model.SetVariableEvaluationImpact(inputVariables[i], double.Parse(modelData[i])); … … 126 126 } 127 127 128 private void SetModelResults(HeuristicLab.Modeling. Model model, string[] modelData) {128 private void SetModelResults(HeuristicLab.Modeling.IAnalyzerModel model, string[] modelData) { 129 129 model.TrainingMeanSquaredError = double.Parse(modelData[TRAINING_MSE]); 130 130 model.ValidationMeanSquaredError = double.Parse(modelData[VALIDATION_MSE]); … … 148 148 } 149 149 150 private HeuristicLab. Core.IItem ParseModel(string dirName, string modelFileName, string algoName) {150 private HeuristicLab.Modeling.IPredictor CreatePredictor(string targetVariable, string dirName, string modelFileName, string algoName) { 151 151 foreach (char c in Path.GetInvalidFileNameChars()) { 152 152 modelFileName = modelFileName.Replace(c, '_'); 153 153 } 154 154 if (algoName == "SupportVectorRegression") { 155 HeuristicLab. Data.SVMModel model = new HeuristicLab.Data.SVMModel();155 HeuristicLab.SupportVectorMachines.SVMModel model = new HeuristicLab.SupportVectorMachines.SVMModel(); 156 156 model.Model = SVM.Model.Read(Path.Combine(dirName, modelFileName) + ".svm.model.txt"); 157 157 model.RangeTransform = SVM.RangeTransform.Read(Path.Combine(dirName, modelFileName) + ".svm.transform.txt"); 158 return model;158 return new HeuristicLab.SupportVectorMachines.Predictor(model, targetVariable); 159 159 } else { 160 160 SymbolicExpressionImporter sexpImporter = new SymbolicExpressionImporter(); … … 163 163 model.FunctionTree = sexpImporter.Import(reader); 164 164 } 165 return model;165 return new HeuristicLab.GP.StructureIdentification.Predictor(new HL2TreeEvaluator(), model); 166 166 } 167 167 } -
trunk/tools/Tools.sln
r2277 r2285 50 50 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 51 51 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Debug|Any CPU.Build.0 = Debug|Any CPU 52 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Debug|x86.ActiveCfg = Debug|Any CPU 52 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Debug|x86.ActiveCfg = Debug|x86 53 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Debug|x86.Build.0 = Debug|x86 53 54 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Release|Any CPU.ActiveCfg = Release|Any CPU 54 55 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Release|Any CPU.Build.0 = Release|Any CPU 55 56 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Release|x86.ActiveCfg = Release|Any CPU 57 {D1D66C9C-5B65-4348-B8B5-528A513695E4}.Release|x86.Build.0 = Release|Any CPU 56 58 EndGlobalSection 57 59 GlobalSection(SolutionProperties) = preSolution
Note: See TracChangeset
for help on using the changeset viewer.