/**
 * Prediction types for ML model inference
 */

export interface PredictionSpan {
  label: string;
  start_time: number;
  end_time: number;
  avg_confidence: number;
  candle_count: number;
}

export interface PerCandlePrediction {
  time: number;
  label: string;
  confidence: number;
}

export interface PerClassMetrics {
  label: string;
  precision: number;
  recall: number;
  f1_score: number;
  support: number;
}

export interface ModelInfoResponse {
  model_name: string;
  model_version: string | null;
  model_type: string;
  trained_at: string | null;
  dataset_version: string | null;
  feature_engineering_enabled: boolean;
  labels: string[];
  per_class_metrics: PerClassMetrics[];
}

export interface PredictRequest {
  candles: {
    time: number;
    open: number;
    high: number;
    low: number;
    close: number;
    volume?: number;
  }[];
}

export interface PredictResponse {
  predictions: PerCandlePrediction[];
  spans: PredictionSpan[];
  model_info: {
    model_name: string;
    model_version: string;
  };
}

export interface BatchPredictRequest {
  pair: string;
  timeframe: string;
  start_time: number;
  end_time: number;
  batch_size?: number;
}

export interface PredictionState {
  spans: PredictionSpan[];
  perCandlePredictions: PerCandlePrediction[];
  isLoading: boolean;
  error: string | null;
  modelInfo: ModelInfoResponse | null;
  visible: boolean;
  confidenceThreshold: number;
  selectedLabels: Set<string>;
  autoPredict: boolean;
  cacheKey: string | null;
}

export type DisagreementType = 
  | 'missed_by_model'    // Human annotation but no prediction
  | 'missed_by_human'    // Prediction but no human annotation
  | 'label_mismatch';    // Both present but different labels

export interface Disagreement {
  type: DisagreementType;
  humanSpan?: {
    id: number;
    label: string;
    start_time: number;
    end_time: number;
  };
  predictionSpan?: PredictionSpan;
  overlap_ratio?: number;
}

export interface PredictionSummary {
  total_predictions: number;
  total_human_annotations: number;
  agreements: number;
  disagreements: Disagreement[];
}
