liveBook · Manning

Dot notation

As explained in Software Engineering for Data Scientists

Dot notation is syntax that accesses an object's attributes or methods by placing a dot between the object expression and member name.

Attribute notation accesses an object's attributes or methods by placing a dot between the object expression and the member name. In Python, the pattern is object.attribute. section 4.1.1

Attributes are values attached to a particular object, often established when the object is created. Reading one uses the object name, a period, and the attribute name. section 4.1.1 section 4.2

Common data-science uses include:

  • Inspecting a scikit-learn model's configuration, such as forest_model.max_features, forest_model.n_estimators, or forest_model.max_depth. section 4.1.1
  • Accessing data stored by a custom class, such as customer_obj.train_data after creating a DataSet object. section 4.2
  • Chaining member access in data-processing expressions, as in train_data.churn.map(...), to transform a column. section 4.2

Inspect a model and dataset

forest_model.max_depth customer_obj.train_data The first expression reads a random forest configuration value; the second reads training data stored on a DataSet instance. section 4.1.1 section 4.2

Listing 4.4 Reference the max_features attributes of our forest_model object
forest_model.max_features #1

Inspect the focused syntax for reading an attribute from a RandomForestClassifier object. section 4.1.1

Listing 4.10 Access the train_data variable that was defined when we created the instance of our DataSet class.
customer_obj.train_data #1

See attribute notation applied to training data stored inside a custom DataSet object. section 4.2

How Software Engineering for Data Scientists covers it

How deep it goes
Defines the object.attribute pattern and demonstrates model and class examples without descending into attribute lookup internals.
Examples
Demonstrates RandomForestClassifier configuration, customer_obj.train_data, and chained pandas column transformation.
What it assumes
Assumes basic Python expressions and introduces attributes through existing model objects before creating custom classes.
What you can do after
Apply it by reading attributes from scikit-learn models and custom Python objects.
How it connects
Connects object-oriented programming with classes, objects, methods, instance variables, constructors, and scikit-learn models.

Also explained in

Compare how 10 books explain dot notation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Engineering for Data Scientists. The section links point to the parts of the book it draws on.