import { isPopulatedObject } from '../util/object_utils' ; export type FeatureImportanceClassName = string | number | boolean ; export interface ClassFeatureImportance { class_name : FeatureImportanceClassName ; importance : number ; } export interface FeatureImportance { feature_name : string ; classes ? : ClassFeatureImportance [ ] ; importance ? : number ; } export interface TopClass { class_name : FeatureImportanceClassName ; class_probability : number ; class_score : number ; } export type TopClasses = TopClass [ ] ; export interface ClassFeatureImportanceSummary { class_name : FeatureImportanceClassName ; importance : { max : number ; min : number ; mean_magnitude : number ; } ; } export interface ClassificationTotalFeatureImportance { feature_name : string ; classes : ClassFeatureImportanceSummary [ ] ; } export interface RegressionFeatureImportanceSummary { max : number ; min : number ; mean_magnitude : number ; } export interface RegressionTotalFeatureImportance { feature_name : string ; importance : RegressionFeatureImportanceSummary ; } export type TotalFeatureImportance = ClassificationTotalFeatureImportance | RegressionTotalFeatureImportance ; export interface FeatureImportanceClassBaseline { class_name : FeatureImportanceClassName ; baseline : number ; } export interface ClassificationFeatureImportanceBaseline { classes : FeatureImportanceClassBaseline [ ] ; } export interface RegressionFeatureImportanceBaseline { baseline : number ; } export type FeatureImportanceBaseline = ClassificationFeatureImportanceBaseline | RegressionFeatureImportanceBaseline ; export function isClassificationTotalFeatureImportance ( summary ) { return ( summary as ClassificationTotalFeatureImportance ) . classes !== undefined ; } export function isRegressionTotalFeatureImportance ( summary ) { return ( summary as RegressionTotalFeatureImportance ) . importance !== undefined ; } export function isClassificationFeatureImportanceBaseline ( baselineData ) { return isPopulatedObject ( baselineData , [ 'classes' ] ) && Array . isArray ( baselineData . classes ) ; } export function isRegressionFeatureImportanceBaseline ( baselineData ) { return isPopulatedObject ( baselineData , [ 'baseline' ] ) ; }