📄 bimodel.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Created on 2004/12/31
*
* $Author$
* $Date$
* $Revision$
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*
*/
package eti.bi.alphaminer.vo;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import com.prudsys.pdm.Adapters.Weka.WekaSupervisedMiningModel;
import com.prudsys.pdm.Core.MiningAlgorithmSpecification;
import com.prudsys.pdm.Core.MiningAttribute;
import com.prudsys.pdm.Core.MiningException;
import com.prudsys.pdm.Core.MiningModel;
import com.prudsys.pdm.Core.MiningSettings;
import com.prudsys.pdm.Models.AssociationRules.AssociationRulesMiningModel;
import com.prudsys.pdm.Models.Clustering.CDBased.CDBasedClusteringMiningModel;
import eti.bi.common.System.SysConfig;
import eti.bi.exception.SysException;
/**
* This Data Mining Data store run time data produced by the operator
* nodes with the transformation histories, i.e. MiningStoredData, TransformAction, Target Attributes, etc.
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class BIModel implements IBIModel{
protected String m_CaseID;
protected String m_NodeID;
private MiningModel m_MiningModel;
private MiningSettings m_MiningSettings;
private MiningAlgorithmSpecification m_MiningAlgorithmSpecification;
private int m_Type;
private String m_ModelName;
private MiningAttribute m_TargetAttribute;
public BIModel()
{
m_Type = IBIModel.TYPE_UNKNOWN;
m_ModelName = "Unknown Model Name";
}
public BIModel(String aCaseID, String aNodeID, int type)
{
m_CaseID = aCaseID;
m_NodeID = aNodeID;
m_Type = type;
m_ModelName = "Unknown Model Name";
}
public void clear()
{
clearTempBIModel();
m_MiningModel = null;
m_MiningSettings = null;
m_MiningAlgorithmSpecification = null;
m_ModelName = "Unknown Model Name";
}
public boolean hasResult()
{
return (m_MiningModel!=null);
}
public String getTempBIModelPath()
{
return SysConfig.getProperty("TEMP_CASES")+"/case_"+m_CaseID+"/tmp_"+m_NodeID+IBIModel.TEMP_FILE_EXTENSION;
}
public void clearTempBIModel()
{
new File(SysConfig.getProperty("TEMP_CASES")+"/case_"+m_CaseID+"/tmp_"+m_NodeID+IBIModel.TEMP_FILE_EXTENSION).delete();
}
public void writeTempBIModel() throws SysException
{
try
{
File f = new File(SysConfig.getProperty("TEMP_CASES")+"/case_"+m_CaseID);
f.mkdirs();
//File fileToWirte = new File(m_TempFileLocation+"/case_"+getCaseID()+"/tmp_"+getNodeID()+m_TempFileExtension);
FileWriter fwriter = new FileWriter(getTempBIModelPath(), false);
m_MiningModel.writePmml(fwriter);
fwriter.close();
} catch (IOException ie)
{
throw new SysException("Fail in writing temp model file",ie);
} catch (MiningException e) {
throw new SysException("Fail in writing temp model file",e);
}
}
public boolean loadTempBIModel() throws SysException
{
try
{
File f = new File(getTempBIModelPath());
if (f.exists() && f.isFile())
{
FileReader reader = new FileReader(f);
switch (m_Type)
{
case IBIModel.TYPE_CLASSIFIER:
m_MiningModel = new WekaSupervisedMiningModel();
break;
case IBIModel.TYPE_CLUSTERING:
m_MiningModel = new CDBasedClusteringMiningModel();
break;
case IBIModel.TYPE_REGRESSION:
m_MiningModel = new WekaSupervisedMiningModel();
break;
case IBIModel.TYPE_ASSOCIATION:
m_MiningModel = new AssociationRulesMiningModel();
break;
default:
return false;
}
m_MiningModel.readPmml(reader);
reader.close();
// m_InputMetaData = m_ClusteringMiningModel.getMiningSettings().getDataSpecification();
return true;
}else
{
return false;
}
} catch (Exception me)
{
throw new SysException("Error in loading temporary data: " + me.getMessage(),me);
}
}
public File getTempFile()
{
return null;
}
/**
* @return Returns the m_MiningModel.
*/
public MiningModel getMiningModel() {
return m_MiningModel;
}
/**
* @param miningModel The m_MiningModel to set.
*/
public void setMiningModel(MiningModel miningModel) {
m_MiningModel = miningModel;
}
/**
* @return Returns the m_MiningAlgorithmSpecification.
*/
public MiningAlgorithmSpecification getMiningAlgorithmSpecification() {
return m_MiningAlgorithmSpecification;
}
/**
* @param miningAlgorithmSpecification The m_MiningAlgorithmSpecification to set.
*/
public void setMiningAlgorithmSpecification(MiningAlgorithmSpecification a_MiningAlgorithmSpecification) {
m_MiningAlgorithmSpecification = a_MiningAlgorithmSpecification;
}
/**
* @return Returns the m_MiningSettings.
*/
public MiningSettings getMiningSettings() {
return m_MiningSettings;
}
/**
* @param miningSettings The m_MiningSettings to set.
*/
public void setMiningSettings(MiningSettings a_MiningSettings) {
m_MiningSettings = a_MiningSettings;
}
/**
* @return Returns the m_Type.
*/
public int getType() {
return m_Type;
}
/**
* @return Returns the m_ModelName.
*/
public String getModelName() {
return m_ModelName;
}
/**
* @param modelName The m_ModelName to set.
*/
public void setModelName(String a_ModelName) {
m_ModelName = a_ModelName;
}
/**
* @return Returns the m_TargetAttribute.
*/
public MiningAttribute getTargetAttribute() {
return m_TargetAttribute;
}
/**
* @param targetAttribute The m_TargetAttribute to set.
*/
public void setTargetAttribute(MiningAttribute targetAttribute) {
m_TargetAttribute = targetAttribute;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -