我正在尝试将分类法转换为一站式服务,但是有问题。要完成转换需要做什么?
我试图进行转换,但是有例外。
Schema schema = new Schema.Builder()
.addColumnInteger("Id")
.addColumnInteger("BsmtFinSF2")
.addColumnsInteger("MSSubClass","LotFrontage", "LotArea","MasVnrArea", "OverallQual", "OverallCond",
"YearBuilt", "YearRemodAdd", "BsmtFinSF1",
"BsmtUnfSF", "TotalBsmtSF", "1stFlrSF",
"2ndFlrSF", "LowQualFinSF", "GrLivArea", "BsmtFullBath", "BsmtHalfBath",
"FullBath", "HalfBath", "KitchenAbvGr", "TotRmsAbvGrd",
"Fireplaces", "GarageCars", "GarageArea", "WoodDeckSF", "OpenPorchSF", "EnclosedPorch",
"3SsnPorch", "ScreenPorch",
"PoolArea", "MiscVal", "MoSold", "YrSold","SalePrice")
.addColumnCategorical("MSZoning","A", "C", "FV", "I", "RH", "RL", "RP", "RM")
.addColumnCategorical("Street","Pave","Grvl")
.addColumnCategorical("Alley","Pave","Grvl","NA")
.addColumnCategorical("LotShape"," Reg", "IR1", " IR2", " IR3")
.addColumnCategorical("LandContour","Lvl" , " Bnk" , " HLS" , " Low")
.addColumnCategorical("Utilities"," AllPub"," NoSewr"," NoSeWa"," ELO")
.addColumnCategorical("LandSlope"," Gtl","Mod","Sev")
.addColumnCategorical("Exterior1st"," AsbShng","AsphShn"," BrkComm","BrkFace","CBlock","CemntBd","HdBoard","ImStucc", "MetalSd","Other","Plywood","PreCast"," Stone",
"Stucco","VinylSd","Wd Sdng"," WdShing")
.addColumnCategorical("Exterior2nd","AsbShng","AsphShn","BrkComm"," BrkFace","CBlock","CemntBd",
"HdBoard","ImStucc","MetalSd","Other","Plywood","PreCast","Stone", "Stucco","VinylSd","Wd Sdng" ,
"WdShing")
.addColumnCategorical("BsmtExposure","Gd","Av","Mn","No","NA")
.addColumnCategorical("BsmtFinType1","GLQ","ALQ","BLQ","Rec","LwQ","Unf","NA")
.addColumnCategorical("BsmtFinType2","GLQ","ALQ","BLQ","Rec","LwQ","Unf","NA")
.addColumnCategorical("Heating","Floor","GasA","GasW","Grav","OthW","Wall")
.addColumnCategorical("KitchenQual","Ex","Gd","TA","Fa","Po")
.addColumnCategorical("Functional","Typ","Min1","Min2","Mod","Maj1","Maj2","Sev","Sal")
.addColumnCategorical("GarageCond","Ex","Gd","TA","Fa","Po","NA")
.addColumnCategorical("PavedDrive","Y","P","N")
.addColumnCategorical("PoolQC","Ex","Gd","TA","Fa","NA")
.addColumnCategorical("Fence"," GdPrv","MnPrv","GdWo","MnWw"," NA")
.addColumnCategorical("SaleCondition","Normal","Abnorml","AdjLand","Alloca","Family","Partial")
.addColumnCategorical("LotConfig","Inside","Corner","CulDSac","FR2","FR3")
.addColumnCategorical("LandSlope","Gtl","Mod","Sev")
.addColumnCategorical("Neighborhood"," Blmngtn","Corner","BrDale","BrkSide","ClearCr","CollgCr","Crawfor",
"Edwards","Gilbert","IDOTRR","MeadowV","Mitchel","Names","NoRidge","NPkVill","NridgHt","NWAmes","OldTown","SWISU",
"Sawyer","SawyerW","Somerst","StoneBr","Timber","Veenker")
.addColumnCategorical("Condition1","Artery"," Feedr","Norm","RRNn","RRAn","PosN","PosA","RRNe","RRAe")
.addColumnCategorical("Condition2","Artery"," Feedr","Norm","RRNn","RRAn","PosN","PosA","RRNe","RRAe")
.addColumnCategorical("BldgType","1Fam","2FmCon","Duplx","TwnhsE","TwnhsI")
.addColumnCategorical("HouseStyle","1Story","1.5Fin","1.5Unf","2Story","2.5Unf","SFoyer","SLvl")
.addColumnCategorical("RoofStyle", " Flat","Gable","Gambrel","Hip","Mansard","Shed")
.addColumnCategorical("MasVnrType", "BrkCmn","BrkFace","CBlock","None","Stone")
.addColumnCategorical("ExterQual","Ex","Gd","TA","Fa","Roll","Po")
.addColumnCategorical("ExterCond","Ex","Gd","TA","Fa","Roll","Po")
.addColumnCategorical("Foundation","BrkTil","CompShg","CBlock","PConc","Slab","Stone","Wood")
.addColumnCategorical("BsmtQual","Ex","Gd","TA","Fa","Po","NA")
.addColumnCategorical("BsmtCond","Ex","Gd","TA","Fa","Po","NA")
.addColumnCategorical("Heating","Floor","GasA","GasW","OthW","Wall")
.addColumnCategorical("HeatingQC","Ex","Gd","TA","Fa","Po")
.addColumnCategorical("CentralAir","N","Y")
.addColumnCategorical("FireplaceQu","Ex","Gd","TA","Fa","Po","NA")
.addColumnCategorical("GarageType","2Types","Attchd","Basment","BuiltIn","CarPort","Detchd","NA")
.addColumnCategorical("GarageFinish","Fin","RFn","Unf","NA")
.addColumnCategorical("GarageQual","Ex","Gd","TA","Fa","Po","NA")
.addColumnCategorical("MiscFeature","Elev","Gar2","Othr","Shed","TenC","NA")
.addColumnCategorical("SaleType","WD","CWD","VWD","New","Con","ConLw","ConLI","ConLD","Oth")
.addColumnCategorical("RoofMatl","ClyTile","CompShg","Membran"," Metal","Roll","Tar&Grv",
"WdShake","WdShngl")
.addColumnCategorical("Electrical","SBrkr","FuseA","FuseF","FuseP","Mix")
/* .addColumnsString("MSZoning","Street","Alley","LotConfig","LotShape","LandContour","RoofMatl","LotConfig",
"BsmtCond",
"Utilities","LandSlope", "Neighborhood", "Condition1", "Condition2", "BldgType",
"HouseStyle", "RoofStyle", "Exterior1st", "Exterior2nd", "MasVnrType", "ExterQual",
"ExterCond", "Foundation", "BsmtQual", "BsmtExposure",
"BsmtFinType1", "BsmtFinType2", "Heating", "HeatingQC", "CentralAir", "KitchenQual",
"Functional", "FireplaceQu", "GarageType",
"GarageFinish", "GarageQual", "GarageCond", "PavedDrive", "PoolQC", "Fence",
"MiscFeature", "SaleType", "SaleCondition","Electrical")*/
.build();
TransformProcess tp = new TransformProcess.Builder(schema)
//.stringToCategorical()
.categoricalToOneHot("MSZoning","Street","Alley","LotConfig","LotShape","LandContour","RoofMatl",
"BsmtCond",
"Utilities","LandSlope", "Neighborhood", "Condition1", "Condition2", "BldgType",
"HouseStyle", "RoofStyle", "Exterior1st", "Exterior2nd", "MasVnrType", "ExterQual",
"ExterCond", "Foundation", "BsmtQual", "BsmtExposure",
"BsmtFinType1", "BsmtFinType2", "Heating", "HeatingQC", "CentralAir", "KitchenQual",
"Functional", "FireplaceQu", "GarageType",
"GarageFinish", "GarageQual", "GarageCond", "PavedDrive", "PoolQC", "Fence",
"MiscFeature", "SaleType", "SaleCondition","Electrical")
.build();
java.lang.IllegalStateException:无法将分类值转换为单值:输入值(“ 0”)不在已知类别(状态名称/类别:[A,C,FV,I,RH, RL,RP,RM])
我希望转换后的文件。