Giter VIP home page Giter VIP logo

Comments (4)

yzhao062 avatar yzhao062 commented on June 8, 2024 1

this appears to be good!

from pyod.

yzhao062 avatar yzhao062 commented on June 8, 2024

given your model is clf = KNN()
at any moment you can

clf.contamination = 0.01

from pyod.

jesuinovieira avatar jesuinovieira commented on June 8, 2024

The predicted output remains unchanged despite these adjustments, as you can see below:

from pyod.models.iforest import IForest
from pyod.utils.data import generate_data

contamination = 0.5
X_train, X_test, _, _ = generate_data(
    n_train=1000, n_test=500, n_features=5, contamination=contamination, random_state=42
)

# Train clf with default contamination (0.1)
clf = IForest()
clf.fit(X_train)

y_hat = clf.predict(X_test)

print(f"Contamination: {round(clf.contamination, 5)}")
print(f"Test: {(y_hat == 1).sum()} out of {len(X_test)}\n")

# Update contamination to 0.5 and predict again
clf.contamination = contamination
y_hat = clf.predict(X_test)

print(f"Contamination: {round(clf.contamination, 5)}")
print(f"Test: {(y_hat == 1).sum()} out of {len(X_test)}")
Contamination: 0.1
Test: 65 out of 500

Contamination: 0.5
Test: 65 out of 500

Upon inspecting the codebase, I wonder if I should invoke _process_decision_scores or a similar method to update clf.threshold_, which is utilized in predict()?

from pyod.

jesuinovieira avatar jesuinovieira commented on June 8, 2024

The modifications made to the code seem to be producing the desired results. By inserting clf._process_decision_scores() immediately after updating the contamination parameter, the new output is as follows:

Contamination: 0.1
Test: 61 out of 500

Contamination: 0.5
Test: 244 out of 500

Could you kindly verify if these modifications are safe and the approach is appropriate?

from pyod.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.