0Pricing
Data Science Academy · Aula

Recursos X e alvo y

Moldando as entradas esperadas pela biblioteca.

Recursos X e alvo y é uma aula grátis de Data Science Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Data Science Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Data Science Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Inputs and Outputs

Supervised models learn a mapping from inputs to an output. The inputs are your features, and the output is what you want to predict. 🎯

Meet X and y

By convention, features go in a capital X and the target goes in a lowercase y. This naming shows up in nearly every example you read.

X Is Two-Dimensional

Capital X is a 2D table: one row per sample, one column per feature. scikit-learn always expects this rows-by-columns shape.

X.shape  # (n_samples, n_features)

y Is One-Dimensional

The target y is usually a single column: one value per sample. Its length must match the number of rows in X exactly.

y.shape  # (n_samples,)

Split a DataFrame

From a pandas table, you carve out X and y by selecting columns. The target column becomes y; everything else becomes X.

X = df.drop(columns=['price'])
y = df['price']

Features Should Be Numeric

Most estimators expect numeric features. Text and category columns need encoding into numbers before they can enter X.

Keep the Target Out of X

Never leave the answer inside your features. A target hiding in X is leakage, and it makes a model look perfect but useless.

Rows Must Line Up

Row one of X must correspond to value one of y. This alignment is how the model connects each sample to its correct answer.

Regression vs Classification

If y holds continuous numbers it is regression; if y holds categories it is classification. The target's type decides the model family.

Feed Both Into fit

Once X and y are ready, you hand both to fit together. The model reads features and answers side by side to learn.

model.fit(X, y)

predict Takes X Only

When predicting, you pass new features with the same columns as training X. You never pass y, since that is what you want back.

model.predict(X_new)

Quick Check

Make sure you have the shapes of X and y straight.

Recap

Split your data into X, a 2D feature table, and y, the 1D target. Keep them aligned and leak-free, and fit is ready to learn. ✅

Perguntas Frequentes

A aula “Recursos X e alvo y” é grátis?

Sim — o texto completo de “Recursos X e alvo y” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Data Science Academy, atualize para CoddyKit PRO. O curso de Data Science Academy inclui 4 aulas no total.

O que vou aprender em “Recursos X e alvo y”?

Moldando as entradas esperadas pela biblioteca. Você pratica Data Science Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Data Science Academy?

Nenhuma experiência prévia é necessária. Data Science Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Recursos X e alvo y”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Data Science Academy?

Sim. Cada aula de Data Science Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. O contrato de fit e predict
  2. Recursos X e alvo y
  3. Treinar uma regressão linear
  4. Avaliar seu primeiro modelo
← Voltar para Data Science Academy