<?xml version="1.0" encoding="UTF-8"?>
  <!-- PDS4 XML/Schema for Name Space Id:ml  Version:1.0.1.0 - Sat May 21 00:39:02 UTC 2022 -->
  <!-- Generated from the PDS4 Information Model Version 1.18.0.0 - System Build 12.1 -->
  <!-- *** This PDS4 product schema is an operational deliverable. *** -->
  <!--                                                                           -->
  <!--               Dictionary Stack                                            -->
  <!-- 1.18.0.0 - pds: - Common Dictionary                                       -->
  <!-- 1.0.1.0 - ml: - Machine Learning Analysis                                 -->
  <!--                                                                           -->
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
    targetNamespace="http://pds.nasa.gov/pds4/ml/v1"
    xmlns:ml="http://pds.nasa.gov/pds4/ml/v1"
    xmlns:pds="http://pds.nasa.gov/pds4/pds/v1"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified"
    version="1.0.1.0">
 
    <xs:import namespace="http://pds.nasa.gov/pds4/pds/v1" schemaLocation="https://pds.nasa.gov/pds4/pds/v1/PDS4_PDS_1I00.xsd"/>
 
  <xs:annotation>
    <xs:documentation>
This namespace enables the specification of metadata that
    describes products generated by the use of a machine learning
    model.  It captures information about how the model was trained
    and evaluated. 
  
    ## CHANGE LOG ##
    1.0.1.0
    - Address Oxygen-flagged errors.
    - Make data_set_size a ASCII_NonNegative_Integer.
    - Update some attribute and class definitions.
    - Update README file per latest template.
    - Use PDS Information Model 1.18 (I).

    1.0.0.0
    - Initial release.
  
    </xs:documentation>
  </xs:annotation>
 
  <xs:element name="Machine_Learning" type="ml:Machine_Learning"> </xs:element>

  <xs:complexType name="Data_Set">
    <xs:annotation>
      <xs:documentation>The Data_Set class is the container for classes
        and attributes describing the size and version of data sets used
        by the machine learning model.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="data_set_version_id" type="ml:data_set_version_id" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="data_set_size" type="ml:data_set_size" minOccurs="1" maxOccurs="1"> </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Machine_Learning">
    <xs:annotation>
      <xs:documentation>The Machine_Learning class is a container for
        all machine learning information in the label.
        </xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="Trained_Machine_Learning_Model" type="ml:Trained_Machine_Learning_Model" minOccurs="1" maxOccurs="unbounded"> </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Machine_Learning_Algorithm">
    <xs:annotation>
      <xs:documentation>The Machine_Learning_Algorithm class is a
        container for classes and and attributes describing the
        algorithm type and learning style used. An external reference to
        a citation for the algorithm is required.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="algorithm_learning_style" type="ml:algorithm_learning_style" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="algorithm_type" type="ml:algorithm_type" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="algorithm_name" type="ml:algorithm_name" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element ref="pds:External_Reference" minOccurs="1" maxOccurs="unbounded"> </xs:element>
    </xs:sequence>
    <!-- Begin assert statements for schematron - Enumerated Values -->
    <!-- <xs:assert test="ml:algorithm_learning_style = ('Semisupervised_Learning', 'Supervised_Learning', 'Unsupervised_Learning')"/> -->
    <!-- <xs:assert test="ml:algorithm_type = ('Convolutional_Neural_Network_Classifier')"/> -->
    <!-- End assert statements for schematron - Enumerated Values -->
  </xs:complexType>

  <xs:complexType name="Test_Performance">
    <xs:annotation>
      <xs:documentation>The Test_Performance class contains information
        about a trained model's performance on the test
        set.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="performance_measure" type="ml:performance_measure" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="performance_score" type="ml:performance_score" minOccurs="1" maxOccurs="1"> </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Test_Set">
    <xs:annotation>
      <xs:documentation>The Test_Set class belongs to the Data_Set class
        family and contains attributes describing the size and version
        of the machine learning model test set.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:restriction base="ml:Data_Set">
        <xs:sequence>
          <xs:element name="data_set_version_id" type="ml:data_set_version_id" minOccurs="1" maxOccurs="1"> </xs:element>
          <xs:element name="data_set_size" type="ml:data_set_size" minOccurs="1" maxOccurs="1"> </xs:element>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="Trained_Machine_Learning_Model">
    <xs:annotation>
      <xs:documentation>The Trained_Machine_Learning_Model class is a
        container for information about how a given model was trained
        and evaluated. A Machine_Learning_Algorithm and Training_Set are
        required, while Validation_Set and Test_Set (and
        Test_Performance) are optional.</xs:documentation>
    </xs:annotation>
    <xs:sequence>
      <xs:element name="trained_model_version_id" type="ml:trained_model_version_id" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="trained_model_name" type="ml:trained_model_name" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="Machine_Learning_Algorithm" type="ml:Machine_Learning_Algorithm" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="Training_Set" type="ml:Training_Set" minOccurs="1" maxOccurs="1"> </xs:element>
      <xs:element name="Validation_Set" type="ml:Validation_Set" minOccurs="0" maxOccurs="1"> </xs:element>
      <xs:element name="Test_Set" type="ml:Test_Set" minOccurs="0" maxOccurs="1"> </xs:element>
      <xs:element name="Test_Performance" type="ml:Test_Performance" minOccurs="0" maxOccurs="unbounded"> </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="Training_Set">
    <xs:annotation>
      <xs:documentation>The Training_Set class belongs to the Data_Set
        class family and contains attributes that describe the size and
        version of the machine learning model training
        set.</xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:restriction base="ml:Data_Set">
        <xs:sequence>
          <xs:element name="data_set_version_id" type="ml:data_set_version_id" minOccurs="1" maxOccurs="1"> </xs:element>
          <xs:element name="data_set_size" type="ml:data_set_size" minOccurs="1" maxOccurs="1"> </xs:element>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="Validation_Set">
    <xs:annotation>
      <xs:documentation>The Validation_Set class belongs to the Data_Set
        class family and contains attributes that describe the size and
        version of the machine learning model validation set.
        </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:restriction base="ml:Data_Set">
        <xs:sequence>
          <xs:element name="data_set_version_id" type="ml:data_set_version_id" minOccurs="1" maxOccurs="1"> </xs:element>
          <xs:element name="data_set_size" type="ml:data_set_size" minOccurs="1" maxOccurs="1"> </xs:element>
        </xs:sequence>
      </xs:restriction>
    </xs:complexContent>
  </xs:complexType>

    <xs:annotation>
      <xs:documentation>This section contains the simpleTypes that provide more constraints
        than those at the base data type level. The simpleTypes defined here build on the base data
        types. This is another component of the common dictionary and therefore falls within the
        common namespace.
      </xs:documentation>
    </xs:annotation>

  <xs:simpleType name="algorithm_learning_style">
    <xs:annotation>
      <xs:documentation>The algorithm_learning_style attribute describes
        the type of learning style employed by the algorithm to solve a
        problem.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_Short_String_Collapsed">
     <xs:minLength value="1"/>
     <xs:maxLength value="255"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="algorithm_name">
    <xs:annotation>
      <xs:documentation>The algorithm_name attribute specifies the name
        of the algorithm used.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_Short_String_Collapsed">
     <xs:minLength value="1"/>
     <xs:maxLength value="255"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="algorithm_type">
    <xs:annotation>
      <xs:documentation>The algorithm_type attribute describes the kind
        of algorithm used, such as a regression model, neural network,
        tree, etc.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_Short_String_Collapsed">
     <xs:minLength value="1"/>
     <xs:maxLength value="255"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="data_set_size">
    <xs:annotation>
      <xs:documentation>The data_set_size attribute provides the number
        of items in the data set.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_NonNegative_Integer">
    	<xs:pattern value='[0-9]+'/>
     <xs:minInclusive value="1"/>
     <xs:maxInclusive value="18446744073709551615"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="data_set_version_id">
    <xs:annotation>
      <xs:documentation>The data_set_version_id attribute specifies the
        data set version number.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_VID">
  <!-- format="M.n" -->
     <xs:minLength value="3"/>
     <xs:maxLength value="100"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="performance_measure">
    <xs:annotation>
      <xs:documentation>The performance_measure attribute specifies the
        name of the measure (or metric) used to report performance of
        the model on the test set.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_Short_String_Collapsed">
     <xs:minLength value="1"/>
     <xs:maxLength value="255"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="performance_score">
    <xs:annotation>
      <xs:documentation>The performance_score attribute reports the
        numeric score the model achieved using performance_measure on
        the test set.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_Real">
     <xs:minInclusive value="-1.7976931348623157e308"/>
     <xs:maxInclusive value="1.7976931348623157e308"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="trained_model_name">
    <xs:annotation>
      <xs:documentation>The trained_model_name attribute specifies the
        name of the model used.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_Short_String_Collapsed">
     <xs:minLength value="1"/>
     <xs:maxLength value="255"/>
	   </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="trained_model_version_id">
    <xs:annotation>
      <xs:documentation>The trained_model_version_id attribute specifies
        the trained model version number.</xs:documentation>
    </xs:annotation>
    <xs:restriction base="pds:ASCII_VID">
  <!-- format="M.n" -->
     <xs:minLength value="3"/>
     <xs:maxLength value="100"/>
	   </xs:restriction>
  </xs:simpleType>
</xs:schema>
