from sklearn.ensemble import RandomForestRegressor clf = RandomForestRegressor(n_estimators=10) clf.fit(X_train, y_train) print("R^2 of trained regressor: {}".format(clf.score(X_test, y_test))) # Load PhenoAI and make sure EVERYTHING is logged to the screen from phenoai import logger from phenoai import maker logger.to_stream(lvl=0) # Create AInalysis maker m = maker.AInalysisMaker( default_id="my_own_regressor", location="./my_second_ainalysis", overwrite=True) # Add meta information m.set_about("Test AInalysis from example08b", "This AInalysis is created by the 08b example and serves no purpose other than showcasing how AInalyses are made.") m.add_author("Bob Stienen", "*****@*****.**") # Set the estimator and output classes m.set_estimator( estimator=clf, estimator_type='regressor', output='pointvalue') # Set the application box via the training data
import os if not os.path.exists("./my_first_ainalysis"): raise Exception("The AInalysis 'my_first_ainalysis' as created by example 08a could not be found in the 'examples' folder. Run example 08a to create this AInalysis.") # Load PhenoAI and make sure EVERYTHING is logged to the screen from phenoai import logger from phenoai import maker logger.to_stream(lvl=0) # Create AInalysis maker m = maker.AInalysisMaker( default_id="my_own_classifier", location="./my_updated_first_ainalysis_09b", versionnumber=1, overwrite=True) # Add meta information m.set_about("Test AInalysis from example09b", "This AInalysis is created by the 08a example and serves no purpose other than showcasing how AInalyses are made. Only the meta information (this about file) should be different from the 08a AInalysis.") m.add_author("Bob Stienen", "*****@*****.**") m.add_author("Sascha Caron", "*****@*****.**") # Define dependency versions (on top of used versions) m.load("./my_first_ainalysis", load_estimator=True, load_data=True)
clf.fit(X_train, y_train) y_pred = clf.predict_proba(X_test)[:, 1] print("Accuracy of trained classifier: {}".format(clf.score(X_test, y_test))) # Load PhenoAI and make sure EVERYTHING is logged to the screen from phenoai import logger from phenoai import maker from phenoai import __version__ logger.to_stream(lvl=0) # Create AInalysis maker m = maker.AInalysisMaker(default_id="my_own_classifier", location="./my_first_ainalysis", overwrite=True) # Add meta information m.set_about( "Test AInalysis from example08a", "This AInalysis is created by the 08a example and serves no purpose other than showcasing how AInalyses are made." ) m.add_author("Bob Stienen", "*****@*****.**") # Define dependency versions (on top of used versions) m.set_dependency_version("phenoai", [__version__]) m.set_dependency_version("sklearn", sklearn.__version__)