Skip to content

KNN-Classification

Updated
17 Sept 2026
1 min read
0 sections
Page 74 of 117
Python & Machine Learning
python
df = pd.read_csv('../DATA/gene_expression.csv')
python
df.head()
Out · table
Gene One
Gene Two
Cancer Present
0
4.3
18 more lines
3.9
1
1
2.5
6.3
0
2
5.7
3.9
1
3
6.1
6.2
0
4
7.4
3.4
1
python
sns.scatterplot(x='Gene One', y='Gene Two', hue='Cancer Present', data=df, alpha=0.6)
Out · result
<Axes: xlabel='Gene One', ylabel='Gene Two'>
Out · plot
Output 1
python
sns.scatterplot(x='Gene One',y='Gene Two',hue='Cancer Present',data=df, alpha=0.6)

plt.xlim(2,6)
plt.ylim(3,10)
Out · result
(3.0, 10.0)
Out · plot
Output 2
python
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
python
X = df.drop('Cancer Present',axis=1)
y = df['Cancer Present']
python
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)
python
scaler = StandardScaler()