// InferFeatureColumns fill up featureColumn and columnSpec structs
// for all fields.
// if wr is not nil, then write
InferFeatureColumns fill up featureColumn and columnSpec structs
for all fields.
if wr is not nil, then write
// InferFeatureColumns fill up featureColumn and columnSpec structs // for all fields . // if wr is not nil then write
func InferFeatureColumns(trainStmt *TrainStmt, db *database.DB) error {
	fcMap := makeColumnMap(trainStmt.Features)
	fmMap := makeFieldDescMap(trainStmt.Features)
	rows, err := verifier.FetchSamples(db, trainStmt.Select)
	if err != nil {
		return err
	}
	defer rows.Close()
	columnTypes, err := rows.ColumnTypes()
	if err != nil {
		return err
	}
	selectFieldTypeMap := make(fieldTypes)
	selectFieldNames := []string{}
	for _, ct := range columnTypes {
		_, fld := decomp(ct.Name())
		typeName := ct.DatabaseTypeName()
		if _, ok := selectFieldTypeMap[fld]; ok {
			return fmt.Errorf("duplicated field name %s", fld)
		}
		selectFieldTypeMap[fld] = typeName
		selectFieldNames = append(selectFieldNames, fld)
	}
	err = fillFieldDescs(rows, columnTypes, fmMap)
	if err != nil {
		return err
	}
	columnTargets := getFeatureColumnTargets(trainStmt)
	err = deriveFeatureColumn(fcMap, columnTargets, fmMap, selectFieldTypeMap, trainStmt)
	if err != nil {
		return err
	}
	setDerivedFeatureColumnToIR(trainStmt, fcMap, columnTargets, selectFieldNames)
	return deriveLabel(trainStmt, fmMap)
}
func InferFeatureColumns ( trainStmt * TrainStmt , db * database . DB ) error { fcMap := makeColumnMap ( trainStmt . Features ) fmMap := makeFieldDescMap ( trainStmt . Features ) rows , err := verifier . FetchSamples ( db , trainStmt . Select ) if err != nil { return err } defer rows . Close ( ) columnTypes , err := rows . ColumnTypes ( ) if err != nil { return err } selectFieldTypeMap := make ( fieldTypes ) selectFieldNames := [ ] string { } for _ , ct := range columnTypes { _ , fld := decomp ( ct . Name ( ) ) typeName := ct . DatabaseTypeName ( ) if _ , ok := selectFieldTypeMap [ fld ] ; ok { return fmt . Errorf ( " " , fld ) } selectFieldTypeMap [ fld ] = typeName selectFieldNames = append ( selectFieldNames , fld ) } err = fillFieldDescs ( rows , columnTypes , fmMap ) if err != nil { return err } columnTargets := getFeatureColumnTargets ( trainStmt ) err = deriveFeatureColumn ( fcMap , columnTargets , fmMap , selectFieldTypeMap , trainStmt ) if err != nil { return err } setDerivedFeatureColumnToIR ( trainStmt , fcMap , columnTargets , selectFieldNames ) return deriveLabel ( trainStmt , fmMap ) }
InferFeatureColumns fill up featureColumn and columnSpec structs
for all fields.
InferFeatureColumns fill up featureColumn and columnSpec structs for all fields .
// TODO(typhoonzero): find a way to using subqueries like select * from (%s) AS a LIMIT 100 // q := trainStmt.Select // set back trainStmt.Features in the order of select and update trainStmt.Label