doubt.datasets.servo

Servo data set.

This data set is from the UCI data set archive, with the description being the original description verbatim. Some feature names may have been altered, based on the description.

  1"""Servo data set.
  2
  3This data set is from the UCI data set archive, with the description being the original
  4description verbatim. Some feature names may have been altered, based on the
  5description.
  6"""
  7
  8import io
  9
 10import pandas as pd
 11
 12from .dataset import BASE_DATASET_DESCRIPTION, BaseDataset
 13
 14
 15class Servo(BaseDataset):
 16    __doc__ = f"""
 17    Data was from a simulation of a servo system.
 18
 19    Ross Quinlan:
 20
 21    This data was given to me by Karl Ulrich at MIT in 1986. I didn't record his
 22    description at the time, but here's his subsequent (1992) recollection:
 23
 24    "I seem to remember that the data was from a simulation of a servo system involving
 25    a servo amplifier, a motor, a lead screw/nut, and a sliding carriage of some sort.
 26    It may have been on of the translational axes of a robot on the 9th floor of the AI
 27    lab. In any case, the output value is almost certainly a rise time, or the time
 28    required for the system to respond to a step change in a position set point."
 29
 30    (Quinlan, ML'93)
 31
 32    "This is an interesting collection of data provided by Karl Ulrich. It covers an
 33    extremely non-linear phenomenon - predicting the rise time of a servomechanism in
 34    terms of two (continuous) gain settings and two (discrete) choices of mechanical
 35    linkages."
 36
 37    {BASE_DATASET_DESCRIPTION}
 38
 39    Features:
 40        motor (int):
 41            Motor, ranges from 0 to 4 inclusive
 42        screw (int):
 43            Screw, ranges from 0 to 4 inclusive
 44        pgain (int):
 45            PGain, ranges from 3 to 6 inclusive
 46        vgain (int):
 47            VGain, ranges from 1 to 5 inclusive
 48
 49    Targets:
 50        class (float):
 51            Class values, ranges from 0.13 to 7.10 inclusive
 52
 53    Source:
 54        https://archive.ics.uci.edu/ml/datasets/Servo
 55
 56    Examples:
 57        Load in the data set::
 58
 59            >>> dataset = Servo()
 60            >>> dataset.shape
 61            (167, 5)
 62
 63        Split the data set into features and targets, as NumPy arrays::
 64
 65            >>> X, y = dataset.split()
 66            >>> X.shape, y.shape
 67            ((167, 4), (167,))
 68
 69        Perform a train/test split, also outputting NumPy arrays::
 70
 71            >>> train_test_split = dataset.split(test_size=0.2, random_seed=42)
 72            >>> X_train, X_test, y_train, y_test = train_test_split
 73            >>> X_train.shape, y_train.shape, X_test.shape, y_test.shape
 74            ((131, 4), (131,), (36, 4), (36,))
 75
 76        Output the underlying Pandas DataFrame::
 77
 78            >>> df = dataset.to_pandas()
 79            >>> type(df)
 80            <class 'pandas.core.frame.DataFrame'>
 81    """
 82
 83    _url = (
 84        "https://archive.ics.uci.edu/ml/machine-learning-databases/" "servo/servo.data"
 85    )
 86
 87    _features = range(4)
 88    _targets = [4]
 89
 90    def _prep_data(self, data: bytes) -> pd.DataFrame:
 91        """Prepare the data set.
 92
 93        Args:
 94            data (bytes): The raw data
 95
 96        Returns:
 97            Pandas dataframe: The prepared data
 98        """
 99        # Convert the bytes into a file-like object
100        csv_file = io.BytesIO(data)
101
102        # Load in the dataframe
103        cols = ["motor", "screw", "pgain", "vgain", "class"]
104        df = pd.read_csv(csv_file, names=cols)
105
106        # Encode motor and screw
107        codes = ["A", "B", "C", "D", "E"]
108        df["motor"] = df.motor.map(lambda x: codes.index(x))
109        df["screw"] = df.screw.map(lambda x: codes.index(x))
110
111        return df
class Servo(doubt.datasets.dataset.BaseDataset):
 16class Servo(BaseDataset):
 17    __doc__ = f"""
 18    Data was from a simulation of a servo system.
 19
 20    Ross Quinlan:
 21
 22    This data was given to me by Karl Ulrich at MIT in 1986. I didn't record his
 23    description at the time, but here's his subsequent (1992) recollection:
 24
 25    "I seem to remember that the data was from a simulation of a servo system involving
 26    a servo amplifier, a motor, a lead screw/nut, and a sliding carriage of some sort.
 27    It may have been on of the translational axes of a robot on the 9th floor of the AI
 28    lab. In any case, the output value is almost certainly a rise time, or the time
 29    required for the system to respond to a step change in a position set point."
 30
 31    (Quinlan, ML'93)
 32
 33    "This is an interesting collection of data provided by Karl Ulrich. It covers an
 34    extremely non-linear phenomenon - predicting the rise time of a servomechanism in
 35    terms of two (continuous) gain settings and two (discrete) choices of mechanical
 36    linkages."
 37
 38    {BASE_DATASET_DESCRIPTION}
 39
 40    Features:
 41        motor (int):
 42            Motor, ranges from 0 to 4 inclusive
 43        screw (int):
 44            Screw, ranges from 0 to 4 inclusive
 45        pgain (int):
 46            PGain, ranges from 3 to 6 inclusive
 47        vgain (int):
 48            VGain, ranges from 1 to 5 inclusive
 49
 50    Targets:
 51        class (float):
 52            Class values, ranges from 0.13 to 7.10 inclusive
 53
 54    Source:
 55        https://archive.ics.uci.edu/ml/datasets/Servo
 56
 57    Examples:
 58        Load in the data set::
 59
 60            >>> dataset = Servo()
 61            >>> dataset.shape
 62            (167, 5)
 63
 64        Split the data set into features and targets, as NumPy arrays::
 65
 66            >>> X, y = dataset.split()
 67            >>> X.shape, y.shape
 68            ((167, 4), (167,))
 69
 70        Perform a train/test split, also outputting NumPy arrays::
 71
 72            >>> train_test_split = dataset.split(test_size=0.2, random_seed=42)
 73            >>> X_train, X_test, y_train, y_test = train_test_split
 74            >>> X_train.shape, y_train.shape, X_test.shape, y_test.shape
 75            ((131, 4), (131,), (36, 4), (36,))
 76
 77        Output the underlying Pandas DataFrame::
 78
 79            >>> df = dataset.to_pandas()
 80            >>> type(df)
 81            <class 'pandas.core.frame.DataFrame'>
 82    """
 83
 84    _url = (
 85        "https://archive.ics.uci.edu/ml/machine-learning-databases/" "servo/servo.data"
 86    )
 87
 88    _features = range(4)
 89    _targets = [4]
 90
 91    def _prep_data(self, data: bytes) -> pd.DataFrame:
 92        """Prepare the data set.
 93
 94        Args:
 95            data (bytes): The raw data
 96
 97        Returns:
 98            Pandas dataframe: The prepared data
 99        """
100        # Convert the bytes into a file-like object
101        csv_file = io.BytesIO(data)
102
103        # Load in the dataframe
104        cols = ["motor", "screw", "pgain", "vgain", "class"]
105        df = pd.read_csv(csv_file, names=cols)
106
107        # Encode motor and screw
108        codes = ["A", "B", "C", "D", "E"]
109        df["motor"] = df.motor.map(lambda x: codes.index(x))
110        df["screw"] = df.screw.map(lambda x: codes.index(x))
111
112        return df

Data was from a simulation of a servo system.

Ross Quinlan:

This data was given to me by Karl Ulrich at MIT in 1986. I didn't record his description at the time, but here's his subsequent (1992) recollection:

"I seem to remember that the data was from a simulation of a servo system involving a servo amplifier, a motor, a lead screw/nut, and a sliding carriage of some sort. It may have been on of the translational axes of a robot on the 9th floor of the AI lab. In any case, the output value is almost certainly a rise time, or the time required for the system to respond to a step change in a position set point."

(Quinlan, ML'93)

"This is an interesting collection of data provided by Karl Ulrich. It covers an extremely non-linear phenomenon - predicting the rise time of a servomechanism in terms of two (continuous) gain settings and two (discrete) choices of mechanical linkages."

Arguments:
  • cache (str or None, optional): The name of the cache. It will be saved to cache in the current working directory. If None then no cache will be saved. Defaults to '.dataset_cache'.
Attributes:
  • cache (str or None): The name of the cache.
  • shape (tuple of integers): Dimensions of the data set
  • columns (list of strings): List of column names in the data set
Features:

motor (int): Motor, ranges from 0 to 4 inclusive screw (int): Screw, ranges from 0 to 4 inclusive pgain (int): PGain, ranges from 3 to 6 inclusive vgain (int): VGain, ranges from 1 to 5 inclusive

Targets:

class (float): Class values, ranges from 0.13 to 7.10 inclusive

Source:

https://archive.ics.uci.edu/ml/datasets/Servo

Examples:

Load in the data set::

>>> dataset = Servo()
>>> dataset.shape
(167, 5)

Split the data set into features and targets, as NumPy arrays::

>>> X, y = dataset.split()
>>> X.shape, y.shape
((167, 4), (167,))

Perform a train/test split, also outputting NumPy arrays::

>>> train_test_split = dataset.split(test_size=0.2, random_seed=42)
>>> X_train, X_test, y_train, y_test = train_test_split
>>> X_train.shape, y_train.shape, X_test.shape, y_test.shape
((131, 4), (131,), (36, 4), (36,))

Output the underlying Pandas DataFrame::

>>> df = dataset.to_pandas()
>>> type(df)
<class 'pandas.core.frame.DataFrame'>