Class TimeSeriesRegressionPredictorImpl
- java.lang.Object
-
- com.datarobot.prediction.internal.TimeSeriesBase
-
- com.datarobot.prediction.internal.TimeSeriesRegressionPredictorImpl
-
- All Implemented Interfaces:
IEventProvider<TimeSeriesRegressionScoreEventInfo>,IPredictorInfo,ITimeSeriesModelInfo,ITimeSeriesRegressionPredictor,Serializable
public class TimeSeriesRegressionPredictorImpl extends TimeSeriesBase implements ITimeSeriesRegressionPredictor
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected LinkedHashMap<String,Class>featuresprotected Map<String,Integer>featuresIndexesprotected StringmodelIdprotected Map<String,String>modelInfoprotected intnumDoublesprotected intnumStringsprotected ConcurrentHashMap<String,String>sanitizedFeaturesCacheprotected com.datarobot.prediction.internal.PredictorBase.GenericEvent<ScoreEventT>scoreEventprotected StringtargetName-
Fields inherited from class com.datarobot.prediction.internal.TimeSeriesBase
dateColumnName, dateFormat, fdw, fw, seriesIdColumnName, timeStep
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedTimeSeriesRegressionPredictorImpl(TimeSeriesPredictor predictor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RowextractFeatures(Iterable<?> row)protected RowextractFeatures(Map<String,?> row)Extracts features that are needed from initial row.protected Map<String,?>extractFeaturesMap(Iterable<?> row)StringgetDateColumnName()Getter for Date Column Name.StringgetDateFormat()Expected date format for the input dates.protected StringgetDefaultEmptyColumnName()Return label for empty column.protected ExplanationParamsgetDefaultParams()ExplanationParamsgetDefaultPredictionExplanationParams()Retrieves default prediction explanation parameters.protected Set<String>getDoubleMissingValuesLabels()Returns the set of null labels.protected DoublegetDoubleValue(String featureName, Object value)Replaces double missing value with NaN.Map.Entry<Integer,Integer>getFeatureDerivationWindow()Getter for Feature Derivation Interval (FDW).LinkedHashMap<String,Class>getFeatures()Model specific features that are required for scoring.protected FieldgetField(Class<?> clazz, String fieldName)Map.Entry<Integer,Integer>getForecastWindow()Getter for Forecast Interval.StringgetModelId()DataRobot Model ID.Map<String,String>getModelInfo()Map with different model information.Class<?>getPredictorClass()What the type of the modelprotected MethodgetPredictorMethod(String methodName, Class<?>... signature)Event<TimeSeriesRegressionScoreEventInfo>getScoreEvent()Returns the event that is invoked for each of the score calculated by the model.StringgetSeriesIdColumnName()Getter for Series ID Column Name.Map.Entry<Integer,String>getTimeStep()Getter for Time Step.protected Map<String,String>initializeModelInfo(PredictorT predictor)protected Stringsanitize(String name)Some pre-processing for feature name.List<TimeSeriesScore<Double>>score(ArrayList<Map<String,?>> rows)Calculates score for the Time-Seriesrows.List<TimeSeriesScore<Double>>score(ArrayList<Map<String,?>> rows, TimeSeriesOptions options)Generalized method for calculating predictons could be used for any type of predictions.List<TimeSeriesScore<Double>>score(ArrayList<Map<String,?>> rows, String forecastPoint)Calculates score for the Time-Seriesrows.List<TimeSeriesScore<Double>>score(ArrayList<Map<String,?>> rows, String startDate, String endDate)Calculates historical scores for the Time-Seriesrows.protected voidsendScoreInfo(ScoreEventT eventInfo)-
Methods inherited from class com.datarobot.prediction.internal.TimeSeriesBase
extractRows
-
-
-
-
Field Detail
-
numDoubles
protected int numDoubles
-
numStrings
protected int numStrings
-
features
protected LinkedHashMap<String,Class> features
-
sanitizedFeaturesCache
protected ConcurrentHashMap<String,String> sanitizedFeaturesCache
-
modelId
protected String modelId
-
targetName
protected String targetName
-
scoreEvent
protected final com.datarobot.prediction.internal.PredictorBase.GenericEvent<ScoreEventT extends EventInfo> scoreEvent
-
-
Constructor Detail
-
TimeSeriesRegressionPredictorImpl
protected TimeSeriesRegressionPredictorImpl(TimeSeriesPredictor predictor)
-
-
Method Detail
-
score
public List<TimeSeriesScore<Double>> score(ArrayList<Map<String,?>> rows)
Description copied from interface:ITimeSeriesRegressionPredictorCalculates score for the Time-Seriesrows. NOTE:rowswill be sorted lexicographical order by series_id then by date so adds linear overhead if all data is already sorted and historic data is extracted from the rows to predict by the setted/unsetted to not NaN target values.- Specified by:
scorein interfaceITimeSeriesRegressionPredictor- Parameters:
rows- time-series that contains both historic data and points to predict.- Returns:
- collection of scores only for the rows to predict.
-
score
public List<TimeSeriesScore<Double>> score(ArrayList<Map<String,?>> rows, String forecastPoint)
Description copied from interface:ITimeSeriesRegressionPredictorCalculates score for the Time-Seriesrows. NOTE:rowswill be sorted lexicographical order by series_id then by date so adds linear overhead if all data is already sorted. Historic data is extracted from the rows to predict by theforecastPoint.- Specified by:
scorein interfaceITimeSeriesRegressionPredictor- Parameters:
rows- time-series that contains both historic data and points to predict.forecastPoint- date from which to start predictions.- Returns:
- collection of scores only for the rows to predict.
-
score
public List<TimeSeriesScore<Double>> score(ArrayList<Map<String,?>> rows, String startDate, String endDate)
Description copied from interface:ITimeSeriesRegressionPredictorCalculates historical scores for the Time-Seriesrows. NOTE:rowsis expected to be sorted by the date, and contains only historic data.- Specified by:
scorein interfaceITimeSeriesRegressionPredictor- Parameters:
rows- history time-series.startDate- start date for historical predictions.endDate- end date for historical predictions.- Returns:
- collection of scores only for the rows between
startDateandendDate.
-
score
public List<TimeSeriesScore<Double>> score(ArrayList<Map<String,?>> rows, TimeSeriesOptions options)
Description copied from interface:ITimeSeriesRegressionPredictorGeneralized method for calculating predictons could be used for any type of predictions.- Specified by:
scorein interfaceITimeSeriesRegressionPredictor- Parameters:
rows- - time series to use for calculate predictions.options- - ts scoring options- Returns:
- predictions according to the options provided.
-
getSeriesIdColumnName
public String getSeriesIdColumnName()
Description copied from interface:ITimeSeriesModelInfoGetter for Series ID Column Name.- Specified by:
getSeriesIdColumnNamein interfaceITimeSeriesModelInfo- Returns:
- series id used during training.
-
getDateColumnName
public String getDateColumnName()
Description copied from interface:ITimeSeriesModelInfoGetter for Date Column Name.- Specified by:
getDateColumnNamein interfaceITimeSeriesModelInfo- Returns:
- date column name used for indexing.
-
getTimeStep
public Map.Entry<Integer,String> getTimeStep()
Description copied from interface:ITimeSeriesModelInfoGetter for Time Step. Pair of quantity to time unit. Time Unit could be: - ROW - MILLISECOND - SECOND - MINUTE - HOUR - DAY - WEEK - MONTH - QUARTER - YEAR- Specified by:
getTimeStepin interfaceITimeSeriesModelInfo- Returns:
- time step used for the time series processing.
-
getFeatureDerivationWindow
public Map.Entry<Integer,Integer> getFeatureDerivationWindow()
Description copied from interface:ITimeSeriesModelInfoGetter for Feature Derivation Interval (FDW). See documentation https://app.datarobot.com/docs/time/time-series.html#framework Pair of min units number and max units number. So window is calculated date based formulas similar to: [ forecast_point - max * time_step_millis, forecast_point - min * time_step_millis ]- Specified by:
getFeatureDerivationWindowin interfaceITimeSeriesModelInfo- Returns:
- feature derivation window used for feature extraction.
-
getForecastWindow
public Map.Entry<Integer,Integer> getForecastWindow()
Description copied from interface:ITimeSeriesModelInfoGetter for Forecast Interval. Pair of min units number and max units number So window is calculated date based formulas similar to: [ forecast_point + min * time_step_millis, forecast_point + max * time_step_millis ]- Specified by:
getForecastWindowin interfaceITimeSeriesModelInfo- Returns:
- feature derivation window used for feature extraction.
-
getDateFormat
public String getDateFormat()
Description copied from interface:ITimeSeriesModelInfoExpected date format for the input dates.- Specified by:
getDateFormatin interfaceITimeSeriesModelInfo- Returns:
- date format.
-
getModelId
public String getModelId()
Description copied from interface:IPredictorInfoDataRobot Model ID.- Specified by:
getModelIdin interfaceIPredictorInfo- Returns:
- string model id.
-
getFeatures
public LinkedHashMap<String,Class> getFeatures()
Description copied from interface:IPredictorInfoModel specific features that are required for scoring. The order of entries is important.- Specified by:
getFeaturesin interfaceIPredictorInfo- Returns:
- Map of feature names and expected type in the order.
-
getPredictorClass
public Class<?> getPredictorClass()
Description copied from interface:IPredictorInfoWhat the type of the model- Specified by:
getPredictorClassin interfaceIPredictorInfo- Returns:
- interface class that implements that particular model.
-
getDefaultPredictionExplanationParams
public ExplanationParams getDefaultPredictionExplanationParams()
Description copied from interface:IPredictorInfoRetrieves default prediction explanation parameters.- Specified by:
getDefaultPredictionExplanationParamsin interfaceIPredictorInfo- Returns:
- Default prediction explanation params, null if no defaults available.
-
getModelInfo
public Map<String,String> getModelInfo()
Description copied from interface:IPredictorInfoMap with different model information.- Specified by:
getModelInfoin interfaceIPredictorInfo- Returns:
- Map with different model information
-
getScoreEvent
public Event<TimeSeriesRegressionScoreEventInfo> getScoreEvent()
Description copied from interface:IEventProviderReturns the event that is invoked for each of the score calculated by the model.- Specified by:
getScoreEventin interfaceIEventProvider<TimeSeriesRegressionScoreEventInfo>- Returns:
- scoring event information.
-
extractFeatures
protected Row extractFeatures(Map<String,?> row)
Extracts features that are needed from initial row.- Parameters:
row- - Map of initial feature name to its value.- Returns:
- - internal type for scoring.
-
sanitize
protected String sanitize(String name)
Some pre-processing for feature name.- Parameters:
name- - original feature name.- Returns:
- - sanitized name.
-
getDoubleValue
protected Double getDoubleValue(String featureName, Object value)
Replaces double missing value with NaN.- Parameters:
featureName- - name of the feature.value- - object feature value.- Returns:
- - parsed Double value.
-
getDefaultEmptyColumnName
protected String getDefaultEmptyColumnName()
Return label for empty column.- Returns:
- - empty column name.
-
getDoubleMissingValuesLabels
protected Set<String> getDoubleMissingValuesLabels()
Returns the set of null labels.- Returns:
- - set of null labels.
-
sendScoreInfo
protected void sendScoreInfo(ScoreEventT eventInfo)
-
getDefaultParams
protected ExplanationParams getDefaultParams()
-
-