liveBook · Manning

Input

As explained in Learn AI-Assisted Python Programming, Second Edition

A parameter is a named input specified by a function definition that receives information when the function is called.

A feature is a measurable characteristic used to describe an object for machine-learning prediction or analysis. In authorship identification, features turn books into numerical descriptions of how their authors write. section 11.1

Useful writing features include:

  • Average words per sentence, calculated by dividing total words by total sentences. section 11.3.1
  • Sentence complexity, estimated with a simple rule that treats commas, semicolons, and colons as phrase separators. section 11.3.1
  • Word-based characteristics such as average word length and patterns of repetition. section 11.3.1 section 11.8
  • A signature, which is a list of features describing one object such as a book. section 11.8

Calculating a sentence-length feature

A passage containing 32 words across two sentences has an average-words-per-sentence feature of 32 ÷ 2 = 16. That number becomes one part of the book’s signature. section 11.3.1 section 11.8

Table 11.1 Calculating the difference between two signatures
Feature Number
Value of Feature in Signature 1
Value of Feature in Signature 2
Weight of Feature
Contribution of Feature
1
4.6
4.3
11
abs(4.6 – 4.3) × 11 = 3.3
2
0.1
0.1
33
abs(0.1 – 0.1) × 33 = 0
3
0.05
0.04
50
abs(0.05 – 0.04) × 50 = .5
4
10
16
0.4
abs(10 – 16) × 0.4 = 2.4
5
2
4
4
abs(2 – 4) × 4 = 8
Sum
14.2

Compare feature values between two signatures and see how each weighted difference contributes to their total difference. section 11.3.1

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Defines features, works through sentence-length calculation, and uses simple punctuation rules while deferring more accurate phrase analysis.
Examples
Uses average sentence length, punctuation-based sentence complexity, average word length, repetition, and weighted signature comparisons.
What you can do after
Apply it by calculating descriptive values and assembling signatures for machine-learning comparisons.
How it connects
Connects features with machine learning, supervised learning, training data, signatures, and prediction.

Also explained in

Compare how 14 books explain input →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.