0Pricing
Data Science Academy · レッスン

fitとpredictの契約

すべての推定器に共通するAPI

「fitとpredictの契約」はCoddyKit上の無料Data Science Academyレッスンです。 これはレッスン1/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはData Science Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Data Science Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

Meet the Estimator

In scikit-learn, every model is an estimator: one object you create, teach, and then ask for answers. Same shape, every time. 🤖

Two Verbs to Remember

The whole library rests on two methods: fit to learn from data, and predict to use what it learned. Master these and you can use almost any model.

fit Means Learn

Calling fit shows the model your examples so it can find patterns. Nothing is predicted yet, the model is simply studying the data.

model.fit(X, y)

predict Means Answer

Once trained, predict takes fresh inputs and returns the model's best guesses. This is where the learning finally pays off.

predictions = model.predict(X_new)

One Consistent Contract

This fit-then-predict pattern is a contract every estimator honors. Swap a tree for a linear model and your code barely changes.

Create Before You Train

You always build the estimator first, often with settings, before any data touches it. That blank model is ready to learn.

from sklearn.linear_model import LinearRegression
model = LinearRegression()

Order Always Matters

You must fit before you predict. Asking an untrained model for answers raises an error, since it has learned nothing yet.

fit Returns the Model

The fit call also returns the model itself, so you can chain steps in one line when you want compact, readable code.

model = LinearRegression().fit(X, y)

Learned State Lives Inside

After fitting, the model stores what it learned in attributes ending with an underscore, like coef_. They appear only once training is done.

model.coef_

Same API, Many Models

Because the API is shared, you can try several models by changing one line. The fit and predict calls stay identical.

from sklearn.tree import DecisionTreeRegressor
model = DecisionTreeRegressor()

Why This Design Wins

One predictable interface means less to memorize and faster experiments. You focus on the problem, not on each library's quirks.

Quick Check

Let's lock in the core contract every estimator follows.

Recap

Every estimator follows one contract: create it, call fit to learn, then predict to answer. One pattern unlocks the whole library. 🎯

よくある質問

「fitとpredictの契約」レッスンは無料ですか?

はい。「fitとpredictの契約」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Data Science Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Data Science Academyコースには全4レッスンが含まれています。

「fitとpredictの契約」で何を学びますか?

すべての推定器に共通するAPI ブラウザで直接実行するハンズオンコードでData Science Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

Data Science Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのData Science Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン1/4です。

「fitとpredictの契約」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このData Science Academyレッスンでコードを書いて実行できますか?

はい。すべてのData Science Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. fitとpredictの契約
  2. 特徴量Xと目的変数y
  3. 線形回帰を学習させる
  4. 最初のモデルを評価する
← Data Science Academyに戻る