AIML Laboratory Set-B
AIML Laboratory Set-B
Import pandas as pd
# Load datasets
Data2 = pd.DataFrame({‘key’: [1, 2, 3], ‘B’: [0, 1, 1], ‘C’: [1, 0, 1]})
# Combine data
Model.fit(data)
# Perform inference
Print(result)
Expected Output :
7.Develop a code to understand and predict an outcome variable based on the
inputRegression models.
Import numpy as np
X = 2 * np.random.rand(100, 1)
Y = 4 + 3 * X + np.random.randn(100, 1)
Model = LinearRegression().fit(X, y)
Y_pred = model.predict(X)
Plt.scatter(X, y)
Plt.show()
Expected Output :
8.Develop a code to Build a decision trees to predict the expected output from the
desiredinput.
X, y = make_classification(n_samples=100, n_features=4)
Plot_tree(model, filled=True)
Plt.show()
Expected Output :
9.Develop a code to build random forests for the dataset by understand the
differencebetween Random and Decision Tree.
X, y = make_classification(n_samples=100, n_features=4)
Expected Output:
X, y = make_classification(n_samples=100, n_features=2)
Print(f’Accuracy: {accuracy:.2f}’)
Expected Output:
Accuracy: 0.95